[Openmcl-devel] How do I move the cursor in a window under program control?

Ron Garret ron at flownet.com
Sat Oct 18 14:54:58 PDT 2014


On Oct 18, 2014, at 2:46 PM, Ron Garret <ron at flownet.com> wrote:

> Just for the record, here’s the code I ended up with:

Oops, just found a bug.  Moving the cursor as the first thing breaks the behavior of these commands when executed in a listener window.  Here’s a fixed version:

; Make sure output is visible on macroexpand and eval-region
(defun fix-front-listener-cursor ()
  (easygui::running-on-main-thread ()
    (hi::handle-hemlock-event
     (gui::front-view-for-buffer (gui::hemlock-buffer (GUI::TOP-LISTENER-DOCUMENT)))
     #k"end")))

(defun macroexpand-expression (expander)
  (in-lisp 
    (let ((expr (with-input-from-region (s (current-form-region)) (read s)))
          (*standard-output* (HEMLOCK-EXT:TOP-LISTENER-OUTPUT-STREAM)))
      (multiple-value-bind (expansion err) (ignore-errors (funcall expander expr))
        (fix-front-listener-cursor)
        (pprint expr)
        (format t "~& ==>")
        (pprint (or expansion (format nil "Error during macroexpansion: ~A" err))))
      (terpri)
      (ccl::print-listener-prompt t))))

(defcommand "Editor Execute Expression" (p)
  "Executes the current region in the editor Lisp. Ensures the result is visible."
  (declare (ignore p))
  (let* ((region (copy-region (current-form-region))))
    (fix-front-listener-cursor)
    (when *echo-expression-to-listener*
      (format (HEMLOCK-EXT:TOP-LISTENER-OUTPUT-STREAM) "~A~&" (region-to-string region)))
    (eval-region region)))




More information about the Openmcl-devel mailing list