Re: [gedit-list] selecting whole words when variables

On Fri, 2007-11-30 at 08:05 +1100, andrew edwards wrote:
> Thanks Curtis - have done.
> I downloaded the source to see if I could find anything relevant - but
> without much luck. If any devs could point me in the right direction
> of where the mouse selection take place in the code that would be
> cool. 
> i imagine its considering a word to be either [A-Za-z] or [0-9] or [_]
> or [any other special character] as it will also break on these items.
> My preferred option would be a word is anything within any type of
> bracket or spaces. 

Gedit Document inherits from GtkSourceView, and it from GtkTextView.

GtkTextView captures the the double click, and calls

	  gtk_text_select_word (text, event->time);

gtk_text_select_word (GtkText *text, guint32 time)
  gtk_text_move_backward_word (text);
  start_pos = text->cursor_mark.index;
  gtk_text_move_forward_word (text);
  end_pos = text->cursor_mark.index;

Both gtk_text_move_forward_word and gtk_text_move_backward_word

Since this is mostly code issue, I think GtkSourceView should capture
the GDK_2BUTTON_PRESS and call it's own gtk_source_view_select_word.
That method should walk forwards and backwards using a wider test word
characters (or the opposite) I'm out of my depth, here. I would be
inclined to test with g_unicode_isalnum | - | _. The opposite would be
g_unicode_is_punct | g_unicode_is_space. 

> Cheers
> Andrew


__C U R T I S  C.  H O V E Y_______
Guilty of stealing everything I am.

Attachment: signature.asc
Description: This is a digitally signed message part

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