PackageDescription: AutoComplete

Auto Complete

Last published: March 7, 2012 by 'tgriggs'

Defines 11 Classes
Extends 17 Classes

AutoComplete adds user triggered text completion to TextEditorController. You can now hit the tab key half way through a word, and it will complete as much of it as it can. It's based off of the SymbolTable and words found in the current paragraph editor's text. In the event multiple completions exist, it opens a menu which you can use to select the desired completion. These menus' controllers are augmented so that you can type the character that begins the completion (indicated by underline) and it will apply that choice. Or if you type a letter that isn't included, it will drop the menu and insert the character into the paragraph (the exceptions being the up/down arrow keys, the return/esc keys, which are used to navigate the menu).

If a completion cannot be performed, because the caret is not positioned at the end of the word, a normal tab will be inserted. It's coded so that if you have *any* keyboard modifiers on the tab, it will also insert the tab. This can be hard on some OSes, because the WindowManager won't let any modified tabs through. There is a boolean (AutoComplete.TabComplete) that can be used to turn off tab completion.

Previous versions of this package set the #Insert key to trigger completion as well. Unfortunately, there really is no good way for a bunch of different tools to do this, except through the MagicKeys package. So, if you want to use a different key sequence (CTRL-Space is popular, though the emacs'er in me insists that's for marking), I suggest you load MagicKeys, and bind your sequence to #completeWordKey:

There is an AutoCompleteTests package that goes along with this for development. Please make sure tests pass before publishing.