Lisp HUG Maillist Archive

Random useful thing: BROWSE-WC

This function makes little windows with the results of the various
who-calls type functions in, from which you can edit things, or click
right to further browse.  

Does anyone know how to make CONTAIN choose a sensible height for
list-panels?  The default is tiny...

--tim

(defun browse-wc (thing &rest types)
  ;; Now less trivial than it was...
  "Browse who-calls, or in fact browse any of the *-WHO or WHO-* functions"
  (setf types (or types '(:who-calls)))
  (let ((selections (loop for type in types
                          appending 
                          (ecase type
                            ((:who-calls) (who-calls thing))
                            ((:calls-who) (calls-who thing))
                            ((:who-binds) (who-binds thing))
                            ((:binds-who) (binds-who thing))
                            ((:who-sets) (who-sets thing))
                            ((:sets-who) (sets-who thing))
                            ((:who-references) (who-references thing))
                            ((:references-who) (references-who thing)))))
        panel)
    (when selections
      (setf panel
            (make-instance 'capi:list-panel
                            :items selections
                            :print-function #'prin1-to-string
                            :callback-type :data
                            :action-callback #'ed
                            :pane-menu 
                            (make-instance 
                             'capi:menu
                             :title "Browse selection"
                             :items '(:who-calls :calls-who
                                      :who-binds :binds-who
                                      :who-sets :sets-who
                                      :who-references :references-who)
                             :print-function
                             #'(lambda (s)
                                   (format nil "~A ~S"
                                           (nstring-capitalize
                                            (substitute 
                                             #\Space #\-
                                             (symbol-name s)))
                                           (capi:choice-selected-item panel)))
                             :callback-type :data
                             :callback
                             #'(lambda (type)
                                 (browse-wc (capi:choice-selected-item panel)
                                            type)))))
      (capi:contain 
       panel
       ;; why is default size all wrong?
       :best-height 120
       :best-width 200
       :title (format nil "~S: ~{~A~^, ~}" 
                      thing
                      (mapcar #'(lambda (type)
                                  (string-downcase
                                   (substitute #\Space #\- 
                                               (symbol-name type))))
                              types))))
    selections))


Re: Random useful thing: BROWSE-WC

Hello Tim,

| This function makes little windows with the results of the various
| who-calls type functions in, from which you can edit things, or click
| right to further browse.  
| 
| Does anyone know how to make CONTAIN choose a sensible height for
| list-panels?  The default is tiny...
|...snip...| 

My recommendation is either something like
    (make-instance 'capi:list-panel
        :visible-min-height `(character ,(min 20 (length selections)))
        ...)
or 
      (capi:contain 
       panel
       :best-height `(character ,(min 20 (length selections)))
        ...)
--
Sincerely,
Dmitri Ivanov
www.aha.ru/~divanov


Re: Random useful thing: BROWSE-WC

* Dmitri Ivanov wrote:

> My recommendation is either something like
>     (make-instance 'capi:list-panel
>         :visible-min-height `(character ,(min 20 (length selections)))
>         ...)


Thanks, that works, although it seems to leave whitespace for some
reason at the bottom.  I wish I understood constraints...

--tim


Re: Random useful thing: BROWSE-WC

* Simon Katz wrote:

> If you remove the :best-height argument to CAPI:CONTAIN, the
> whitespace at the bottom should disappear.

No.  Not sure why.

--tim



Updated at: 2020-12-10 09:00 UTC