Pregunta

Presently I'm trying to build up a text editor for the PHP language which should have the feature of code completion, i.e. if i start to type a word a dynamically created drop down list will display all available keywords starts with my typed letters. Can any body suggest me how it can be done. Idea will be enough for me. If possible please provide me a link to such simple application build in C#.

¿Fue útil?

Solución

Considering that in general it's not an easy task, so there is no some "easy" application.

Even if in general idea is not a rocket science. You need to define a dictionary of words, corresponding to some key. When you type "." (in C#) you have to pick from the dictionary all words corresponding to the key equal to the word found on left side from the "."

To do it real working applicaiton is not so easy. By the way I can recommend to have a look on MonoDevlop look on their editor.

I worked with it years ago to make a simple editor for DSL company needed, and spend not small amount of time to correctly understand intenals, integrate well "my new language", "detach" control from Mono and inject into our applicaitons, like a dockable window.

Otros consejos

If I where you I would really try to avoid the wheel... code completion is something that most IDE's now come with so what you are after is already available...

That being said, what I would try would be to go over the PHP API and construct a Suffix tree. This type of tree usually allow for a fast way to look for a given word. Once you index the API, you would also add in any other variable the user adds while he/she is performing the actual programming.

You could kick the search automatically in your suffix tree after the user has entered the 3rd letter, or maybe provide means for the user to activate it manually, like the Ctrl-Space keyboard most IDE's (Visual Studio, Netbeans, Eclipse, etc) have.

Note that this could get tricky, since you might want to select the appropriate variable type.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top