Lisp HUG Maillist Archive

How to bind the Values->Clip command in IDE/Listener

Hi all,

I'm trying to make a convenient binding for the clip command to Object
Clipboard, available via Values->Clip menu command. This command places
the contents of * into Object Clipboard.

My naive attempt lead to placing the Listener itself into the
clipboard. Is where another way to do so?

(defcommand "Values Clip" (p)
     "Acts like menu Values > Clip"
  (declare (ignore p))
  ;; get the current editor window
  (when-let (cw (current-window))
    ;; extract the capi text pane out of it
    (when (slot-boundp cw 'editor::text-pane)
      ;; capi text pane could be used to get the top level interface -
      ;; the Listener window itself
      (when-let (iface (capi:top-level-interface (slot-value cw 'editor::text-pane)))
        ;; now try to find the "Values" toplevel menu
        (when-let (values-menu (find-if (lambda (m)
                                          (and (slot-boundp m 'capi::title)
                                               (string= "Values"
                                                        (slot-value m 'capi::title))))
                                        (capi:interface-menu-bar-items iface)))
          (let* ((component (elt (capi:menu-items values-menu) 0))
                 (item (capi:get-collection-item component 0))
                 (menu-item (capi:get-collection-item item 2)))
            (when (capi:menu-object-enabled item)
              (funcall (capi:callbacks-selection-callback menu-item)
                       iface))))))))

-- 
Br,
/Alexey

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Updated at: 2020-12-10 08:28 UTC