Auto-complete/suggestion popup menu in GtkTextView
Posted
by
Tyler
on Stack Overflow
See other posts from Stack Overflow
or by Tyler
Published on 2010-12-24T19:33:13Z
Indexed on
2010/12/28
2:54 UTC
Read the original article
Hit count: 259
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
© Stack Overflow or respective owner