[cl-graph-devel] printing readably and presentation question (SBCL + MCCLIM + CL-GRAPH)

John Morrison morrison at mak.com
Sat Feb 18 14:12:16 UTC 2006


On Sunday 12 February 2006 09:35 pm, Gary King wrote:
> I'm hardly CLIM savvy at all (it's on the great list of things to do
> sometime soon...) so I can't help much. I'll try to do some reading
> tonight and see if that brings me any insight.

Thanks -- I think I figured it out (mostly), and it is, in fact, a
Stupid Newbie question.  I needed to provide a non-default "accept"
method on the presentation type corresponding to the "actual" type.
The default one seems to depend upon being able to read the printed
representation...

The stuff below seems to work -- it's fugly and crufty and not
entirely finished, but it's clearly possible...

I think if you didn't need to do what I do (add slots for
force-directed layout), then you could have a cleaner and simpler
version...

-jm

--- cut here ---

;; The class is derived from graph-container-vertex

(defclass vtx (cl-graph:graph-container-vertex)
  (
     [ snip snip snip]
  ))


;; I needed to provide an "accept" method...
;; Please excuse all the debugging cruft I left in here
;; and the stylistically repulsive c-style parens which
;; are useful for commenting out individual lines as I
;; clearly do when doing my low-tech print-style debugging...


(define-presentation-method accept ((type vtx) stream view &key)
  (values
   (with-application-frame (frame)
     (let ((g (slot-value frame 'current-force-directed-digraph)))
       (describe (cl-graph:vertexes g) *terminal-io*)
       (multiple-value-bind (object success string)
    (handler-case (complete-input stream
      (lambda (so-far mode)
        (format *terminal-io* "lambda ~S ~S~%" so-far mode)
        (complete-from-possibilities
         so-far
         (cl-graph:vertexes g)
         nil
         :action mode
         :predicate (lambda (obj)
;        (format *terminal-io* "pred ~S, type-of ~S~%" obj (type-of obj))
        t)
         :name-key (lambda (obj)
;       (format *terminal-io* "name-key ~S, type-of ~S~%" obj (type-of obj))
;       (describe (format nil "~S" obj) *terminal-io*)
;       (describe (format nil "~A" obj) *terminal-io*)
       (format nil "~S" obj)
       )
         :value-key (lambda (obj)
;        (format *terminal-io* "value-key ~S, type-of ~S~%" obj (type-of obj))
        obj)
         )))
      )
  (format *terminal-io* "mvp object ~S success ~S string ~S~%" object success 
string)
  object
  )
       )
     )
   )
  )

--- cut here ---


-- 
==== John Morrison
==== MAK Technologies Inc.
==== 68 Moulton Street, Cambridge, MA 02138
==== http://www.mak.com/
==== vox:617-876-8085 x115
==== fax:617-876-9208
==== jm at mak.com





More information about the cl-graph-devel mailing list