GNOME Bugzilla – Bug 617607
Add API for accessing selected text
Last modified: 2021-06-10 14:23:42 UTC
Surprisingly not there.
Created attachment 219918 [details] [review] expose the get_selection function
It's actually possible to get the current selection with the AtkText API, but it would be nice if this was exposed directly. This is what can be done right now: AtkText *text = ATK_TEXT(vte_terminal_accessible_new(vte); char *selection = atk_text_get_selection(text, 0, NULL, NULL); g_free(selection); Attached above is a patch to just expose the _vte_terminal_get_selection function directly with documentation to keep things simple.
*** Bug 723007 has been marked as a duplicate of this bug. ***
Was there a specific use case you had in mind for this? I'd rather not add this just to be 'API complete' :-)
Adding keybindings for opening patterns matched by the search functionality. It wouldn't be usable for that if the search functionality moved away from using text selection as a cursor but that's convenient. There are probably other use cases but I haven't wanted it for anything else myself.
I can *imagine* a lot of usecases, like, one to look up your selection in Google Search or Wikipedia and offer a link, etc...
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vte/-/issues/1801.