Re: Improve word boundaries for text widgets



On 09/26/2014 06:13 AM, Sébastien Wilmet wrote:
I would like to improve the word boundaries for the text widgets:
GtkTextView, GtkEntry and GtkLabel (anything else?). More precisely the
word boundaries used for word movements (Ctrl+arrow) and word selection
(double click). Currently the behavior is not consistent across the text
widgets in GTK+ (and other applications), and the current word
boundaries don't work well with spaces, punctuations,
variables_with_underscores, etc.

Awesome!

By seeing how Vim handles word movements, I think it's a much better
behavior. Deriving the "Vim" word boundaries from the Pango word
boundaries is quite straightforward (I have a workable patch): it uses
only the is_word_start and is_word_end PangoLogAttr attributes,
g_unichar_isspace() and compare if a character is an underscore.

I'm doing exactly this in Builder today for VIM style `w` and `b`.

Another idea for GtkTextView is to add a vfunc to let GtkSourceView
define custom word boundaries for word movements and selection. But
all what GtkSourceView would do is to define the "Vim" word boundaries,
which are generic. The Vim word boundaries are good enough, we don't
need more flexibility. So I prefer to implement directly the Vim word
boundaries in GTK+, and have a consistent behavior with other widgets.

I would really like this to be a vfunc so that it could be handled by
per-language overrides in GtkSourceView/GtkSourceLanguage.

Additionally, I'd like double-click and triple-click to be different
things. Imagine triple-click selecting the whole scope in some C code
for example.

Do you think it's a good plan?

I can't speak for everyone, but clearly useful for me on Builder.

-- Christian




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]