views:

206

answers:

1

Is there a web (i.e. html) text editor with autocomplete?

Let's say I want to do a web based mini IDE. I want to add it an autocomplete feature, so if you write Str and hit a key combination a javascript method would be invoked that returned possible completions, such as String, StringBuffer, StringBuilder, StreamParser, etc

+1  A: 

You could see at the current position of the cursor move back until the first word boundary and through AJAX search for keywords. You position these keywords in a select like list just under the cursor.

That would be the very general idea, but it could be too costrly to do on every keystroke, so I'd advice,

  • first, that the word is longuer than 3 letters (at least),
  • call every several keystrokes,
  • and third, if the cursor is static for a few seconds, call the function.
voyager