< Back to IRCAM Forum

Should `ttybox`es offer auto-completion?

I’m used to TAB-completion of symbols in the Lisp Editor, which I think is a feature LispWorks provides. Some user comments have led me to wonder if auto-completion is also supposed to be available when typing in a ttybox (the little box you get by double-clicking inside a Patch). The source code for this class offers further evidence to casual inspection that this is the intent.

I can’t speak to the Mac OS experience, but on Windows and Ubuntu, as of 2023 (OM 7.1) I have not noticed any kind of symbolic completion, TAB- or otherwise, outside of, as I mentioned before, the Lisp Editor window. Is something supposed to happen when hitting TAB in a ttybox? If there’s a problem, I can try to fix it.

-Jonathan

Dear Jonathan,

For auto-completion on linux you should unfortunately use down arrow. I will try to fix that, since Tab is the usual way to have completion on *nix systems. I understand that, and this annoys me also :slight_smile:
Best
K

1 Like

I didn’t think of that. :flushed:

M @haddad–For the preexisting TAB problem, at least on Windows or GNU/Linux, I now can offer a decent solution. It’s non-invasive, in the sense that the following snippet can be dropped into an ‘init/’ script; though it also works, of course, if added to controls.lisp, where the essential class, om:new-fun-enter-view, resides.

(in-package :om)

;; I don't know how much of what follows is dependent on LW 8; thus, to be safe:
#+lispworks
(eval-when (:compile-toplevel :load-toplevel :execute)
  (assert (>= system::*major-version-number* 8)))

(eval-when (:compile-toplevel :load-toplevel :execute)
  #+lispworks (import '(sys:gesture-spec
                        sys:gesture-spec-data
                        sys:coerce-to-gesture-spec
                        capi::gesture-callbacks
                        capi:text-input-pane-complete-text
                        om-api::get-om-character))
  #-lispworks (import 'alexandria:appendf))

;; Sanity check: gesture-spec made from #\Tab has same keycode as :om-key-tab:
(assert (eq :om-key-tab (get-om-character (code-char (gesture-spec-data (coerce-to-gesture-spec #\Tab))))))

;; TAB-completion:
(defmethod shared-initialize ((obj new-fun-enter-view) slot-names
                              &rest keys
                              &key gesture-callbacks
                              &allow-other-keys)
  "GESTURE-CALLBACKS is priority-based: elements passed in the initialization alist override predefined bindings."
  (appendf gesture-callbacks '((#\Tab . text-input-pane-complete-text)))
  (apply #'call-next-method obj slot-names :gesture-callbacks gesture-callbacks keys))

And here is my explanation. Since LispWorks manages text-completion for capi::text-input-pane ingeneral and controls.lisp already gives the OpenMusic-specific behavior, it’s just a question of telling LW when to activate it. You can do by passing (capi::text-input-pane-complete-text) to the :gesture-callbacks initarg or the capi:text-input-pane container (or a subclass, such as new-fun-enter-view is), instantiated whenever (open-ttybox) gets a call.

:gesture-callbacks takes an association list. The format is a little flexible, but in the simplest case, each CDR designates a unary callback and each CAR a keystroke descriptor, which gets canonicalized automatically by (sys:coerce-to-gesture-spec).

-Jonathan

Dear Jonathan,

Thank you a lot for the tip. It appears it works great. I have integrated this in the main class om-editable-text (in api/om-LW/dialog-items.lisp) and is under testing before a push.

The only code is:


(defclass om-editable-text (om-standard-dialog-item text-input-pane) ()
  (:default-initargs
   :visible-border :outline
   :callback 'om-dialog-item-action
   ;; 2017-02-09: navigation-callback not implemented on linux 
   #-linux :navigation-callback #-linux 'text-edit-special-action
   :change-callback 'text-edit-changed-action
   :editing-callback 'text-edited-action
   :gesture-callbacks '((#\Tab . text-input-pane-complete-text))
   ))

with the added :gesture-callbacks.

Thank you again for this suggestion.

Best
K

1 Like

Thank you a lot for the tip. It appears it works great. I have integrated this in the main class om-editable-text (in api/om-LW/dialog-items.lisp) and is under testing before a push.

You’re welcome. Delighted to be able to help a little. :smiling_face:

I saw your commit. Generally speaking, is there a way to incorporate patches into my OM installation without having to rebuild everything from source? I’m afraid I only have the Personal Edition. :woozy_face:

-Jonathan

PS: May I call you ‘Karim’?

Dear Jonathan,

Maybe if you put our lisp addition files in the init folder. But it is better to pull new code from git i presume.
And yes of course you can call me karim.

Best
K

Thank you.

Yep, that’s what I’m doing. :stuck_out_tongue:

For sure. However, my clone of the Git repo is a different directory tree to the one with all the prebuilt binaries.