Syntax highlighting: It comes to mind. I have not actually tried this example, so I can’t say anything about performance, but this is perhaps the easiest way to get the basic syntax highlighted.
Auto-completion: Given a list of possible keywords (which can be filtered based on context), you can quickly drop everything that does not match what the user is currently typing. In most languages, you can safely limit yourself to one “word,” since spaces are usually not legal in an identifier. For example, if I start typing “li,” the autocomplete database may drop everything that doesn't start with the letters “l” and “i” (ignoring the case). As the user continues to type, more and more options may be discarded until only one or at least a few remain. Since you just look at one word at a time, that would be really fast.
Indent: A quick and dirty approach that (sort of) works in C-type languages should have a counter that you increment once for each "{" and decrement once for each "}. When you press enter to start a new line , then the indentation level is counter * indentWidth , where indentWidth is the constant number of spaces or tabs for the indentation, but this has a serious drawback - consider the following:
if(foo) bar();
To handle this, you can look for lines that end with the ')' character, rather than a semicolon.
source share