Auto-complete/suggestion popup menu in GtkTextView
- by Tyler
I'm trying to create a system that will allow me to respond to the current text and auto-complete/suggest what should come next. For example if the user starts to type "Batm" then the system would respond with a menu showing the full completed word "Batman". Think of an IDE like Eclipse or Visual Studio and you get the idea. I understand how to create a popup menu in Gtk+ but what I don't understand is the following:
How do I grab the word that the user is currently typing from a GtkTextView (or SourceView) so that I can do a lookup and offer suggestions?
How do I position the menu in such a way that it sits next to the current text item (like it would in an IDE)?
If anyone could offer suggestions or even a link to a tutorial or example on how to do this correctly I would be forever grateful.
As always thanks for you help!
Programming language: C