[Openmcl-devel] format to a

Arthur Cater arthur.cater at ucd.ie
Wed Feb 1 07:36:09 PST 2012


I am having trouble with cursor position in a programmatic Hemlock view.
The attached (also enclosed) code makes a Hemlock view, creates a stream
to write to it, and writes a few lines using format.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: unclickable.lisp
Type: application/octet-stream
Size: 1389 bytes
Desc: not available
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20120201/37c296a1/attachment.obj>
-------------- next part --------------


Clicking in this view makes the insertion-point cursor blink where you clicked,
but then trying to move the cursor using arrow keys reveals the insertion
point is really still at the end of the buffer.

I don't think my code does anything naughty. Perhaps there is something it
ought to do nice?

Arthur



Welcome to Clozure Common Lisp Version 1.7-r15184M  (DarwinX8664)!



(in-package hemlock)

; --------------------------------------------------------------------------------
; Redefine methods given in ccl:cocoa-ide;hemlock;src;streams.lisp merely
; to ensure that hemlock buffer modification is done in the proper thread
; --------------------------------------------------------------------------------

(defmethod hi::stream-write-char ((stream hi::hemlock-output-stream) char)
  (gui::execute-in-gui
   (lambda nil
     (gui::assume-cocoa-thread)
     (funcall (hi::old-lisp-stream-out stream) stream char))))

(defmethod hi::stream-write-string ((stream hi::hemlock-output-stream) string
                                &optional
                                (start 0)
                                (end (length string)))
  (gui::execute-in-gui
   (lambda nil
     (gui::assume-cocoa-thread)
     (funcall (hi::old-lisp-stream-sout stream) stream string start end))))
                                
(defun cl-user::myview (nlines)
  (gui::execute-in-gui   ; Makes the view
   #'(lambda nil
       (let* ((ccl::*default-file-character-encoding* :utf-8)
              (view (gui::find-or-make-hemlock-view nil))
              (buffer (hemlock-view-buffer view))
              (stream (hi:make-hemlock-output-stream (buffer-start-mark buffer) :none)))
         (dotimes (num nlines) (format stream "Line ~a is here~%" num))))))

(cl-user::myview 7)



More information about the Openmcl-devel mailing list