Code completion in CaScadeS II
By glazou on Thursday 6 October 2005, 17:16 - Nvu - Permalink
How works code completion in CaScadeS II's source editor?
- if the caret is placed inside some text triggering code completion, a code completion popup appears automatically
- all text insertion or deletion there changes the pre-selected option according to the text
- up and down arrow keys do not move the caret when a code completion popup is shown, but change the selected option in the popup
- tab key will not insert a tabulation in the text but choose the option currently selected in the popup, hide the popup and place the selection after the completed code
How is it implemented?
- XBL rulez!
- a new key listener in the capturing phase on the edited document
- that listener calls preventDefault() if it does something special with the event
- if needed, the event is retargeted at the choice in the popup
- the whole things requires c++ code, not only JS
For the time being, CSS property completion works just fine and I must say it is reaaaaaallllllyyyyy cool to see that happen inside Gecko's editor :-) It's also fast, damn fast. You'll like it :-)