Surrounding text is a feature of Gtk and many toolkits that allows input method editors to read and edit the text around the cursor.
To support it, you need to implement handlers for the "delete-surrounding" and "retrieve-surrounding" signals in GtkIMContext.
http://www.gtk.org/api/2.6/gtk/GtkIMContext.html
https://developer.gnome.org/gtk3/stable/GtkIMContext.html
Update:
https://docs.gtk.org/gtk3/class.IMContext.html
GTK+ IME behaviour is a current subject on the mailing list.
https://groups.google.com/forum/#!topic/scintilla-interest/OrUYQm8a8I0
It is unlikely I will work on implementing these handlers myself.
implemented by Colomban Wendling
https://sourceforge.net/p/scintilla/feature-requests/1476/
Now it seems to work good to input thai language.
Diff:
Closing and updating documentation link to work.