How to set completion in a Glamorous Toolkit editor
offers a flexible editor. One of the parts that can be set from the outside is the completion. But how do we go about learning how to set our own completion in an editor?
We can start by searching for examples.
Somewhere in the list, we find the
. In there, we find
Indeed, if we execute it, we get an editor with completion. This is achieved through something called
aScripter which, like the name says, is an object through which we can script the user interface.
Back to our question, we want to learn how our example is made. To this end, we go into the inner examples and, in the end, we find the creation of the element.
So, next we flatten the element creation code in a snippet, and we get our small sample to play with:
anEditor := BrEditor new
aptitude: BrGlamorousCodeEditorAptitude new + BrGlamorousTextAreaSpacingAptitude new;
tree := GtPrefixTree new.
to: $z asInteger
do: [ :i | tree add: (String new: i - $a asInteger + 1 withAll: (Character value: i)) ].
strategy := GtStringsCompletionStrategy new.
strategy completions: tree.
aCompletionController := GtCompletionController on: anEditor strategy: strategy.