Text Editor Autocomplete
Text Editor Autocomplete
How do you store the method names if you want to include a auto-complete feature in a text editor?
For e.g. the VC or VB editors provide a drop down menu of the method names as soon as you type in the object name followed by a "." (dot). How is this done? Do they store the methods in a database and read them off at runtime? or dop they just run through a definitions file and parse the method names there? or is it something else altogether?
And what would be an efficient data structure to have them in memory after you read them from disk?
For e.g. the VC or VB editors provide a drop down menu of the method names as soon as you type in the object name followed by a "." (dot). How is this done? Do they store the methods in a database and read them off at runtime? or dop they just run through a definitions file and parse the method names there? or is it something else altogether?
And what would be an efficient data structure to have them in memory after you read them from disk?
Only Human
Re:Text Editor Autocomplete
What if the method names are from a Java Source file. In this case there is no separate 'header' file where I could look up methods names, isn't it?
Only Human
Re:Text Editor Autocomplete
In C++, using Visual Studio. VS generates that list by parsing the header files that are included in the current file. (On the implementation side, VS parses the files when they are first included and stores the map in a parse database in the project folder, this greatly improves performance from having to reparse each time but can be a problem if you modify the headers)
In VB, Visual Basic looks through the objects (Since everything in VB is related to COM in some way) and enumerates the functions by examining the exported COM symbols, it then reads an associated information file to generate descriptions [I don't think the descriptions are included in the object, but I can't remember].
Java is more or less the same as VB, except instead of enumerating symbols, you use the builtin Reflector.
How to implement Intellisense could be any way you want, I imagine that you could simply examine the current line after each key press, if the line ends in '->'/'.'/'::', then try to determine the parent object then create a list control on top of the text area and add the valid sub objects/functions/variables to it. The most efficent way to store it would probably be a tree where highest parent object holds pointers to the subobjects which hold pointers to their subobjects, etc. (The objects would need to be in a linked list with the other objects in their section of the tree in order to cycle around during lookups)
In VB, Visual Basic looks through the objects (Since everything in VB is related to COM in some way) and enumerates the functions by examining the exported COM symbols, it then reads an associated information file to generate descriptions [I don't think the descriptions are included in the object, but I can't remember].
Java is more or less the same as VB, except instead of enumerating symbols, you use the builtin Reflector.
How to implement Intellisense could be any way you want, I imagine that you could simply examine the current line after each key press, if the line ends in '->'/'.'/'::', then try to determine the parent object then create a list control on top of the text area and add the valid sub objects/functions/variables to it. The most efficent way to store it would probably be a tree where highest parent object holds pointers to the subobjects which hold pointers to their subobjects, etc. (The objects would need to be in a linked list with the other objects in their section of the tree in order to cycle around during lookups)
Re:Text Editor Autocomplete
in a text editor , isnt the area we type in a normal "text box" or is it some other? like in vb we have the inbuilt-tool textbox is it tht wat is used?
Re:Text Editor Autocomplete
The code editors on Windows either use a custom designed textbox, or a subclassed standard text box. It's more likely the former, since hacking that much functionality into a normal textbox would probably be more trouble then it's worth.
Re:Text Editor Autocomplete
So text-editor apps like notepad, context etc.. just use the normal TextBox (or RichTextBox) for text editing?
Only Human
Re:Text Editor Autocomplete
Notepad doesn't have intellisense...
But yes, Notepad is just a Windows standard Textbox, Wordpad is a standard RichTextBox.
But yes, Notepad is just a Windows standard Textbox, Wordpad is a standard RichTextBox.
Re:Text Editor Autocomplete
..
Last edited by Perica on Tue Dec 05, 2006 9:42 pm, edited 1 time in total.
Re:Text Editor Autocomplete
You know that nifty feature that lets you complete coding by filling it in.
For e.g. if you have a class called A with methods as shown
when you use the intelli editor if you create a object of this say A obj1;
then when you type obj1. (with the dot) you get a drop down list of methods or attributes to choose from.
Nice isn't it?
For e.g. if you have a class called A with methods as shown
Code: Select all
class A{
public int fn1();
public char fn2();
...
}
then when you type obj1. (with the dot) you get a drop down list of methods or attributes to choose from.
Nice isn't it?
Only Human
Re:Text Editor Autocomplete
Check out the Visual Basic and Visual C++ editors as an example of this.
Only Human
Re:Text Editor Autocomplete
Used it, didn't like it (mainly the incredible slowdown on the full system right before it gives a useless hint). For me it mostly slows my system down when I'm quickly typing a load of code not caring about hints since I know them like the back of my hand.
On the other hand, nice to know it has a name.
On the other hand, nice to know it has a name.
Re:Text Editor Autocomplete
Oh, didn't see his question. I was answering his first one anyhow. I believe they use a standard text box with the Multiline property enabled. Wordpad uses a RichTextBox .
Re:Text Editor Autocomplete
Yes -- although "text box" sounds more like Visual Basic or C++ Builder speak -- notepad is nothing more than a Windows edit control that is dynamically resized to fill up its parent window and which has the ES_MULTILINE, ES_AUTOVSCROLL, and (depending on whether word-wrap is enabled) the ES_AUTOHSCROLL styles enabled. This is also why in older versions of Windows you'd get a message saying that a file was "too large for Notepad" and asking if you wanted to use Wordpad instead -- edit controls had a 65535-character limit.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/editcontrols/editcontrols.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/editcontrols/editcontrols.asp
Re:Text Editor Autocomplete
In fact, the Using Edit Control section in that link basically has the notepad implementation in it.