[gedit-list] Fwd: hiliting words that contain digits and underscores by double clicking





Begin doorgestuurd bericht:

Van: Jason Walker <jaywalkie yahoo com>
Datum: 30 november 2008 01:41:21 GMT+01:00
Aan: Jesse van den Kieboom <jesse icecrew nl>
Onderwerp: Antw.: [gedit-list] hiliting words that contain digits and underscores by double clicking

I have investigated it a little bit, and indeed the culprit is  in gtktextview.c file of gtk. The following method:

/*
* Move @start and @end to the boundaries of the selection unit (indicated by
* @granularity) which contained @start initially.
* If the selction unit is SELECT_WORDS and @start is not contained in a word
* the selection is extended to all the white spaces between the end of the
* word preceding @start and the start of the one following.
*/
static void
extend_selection (GtkTextView *text_view,
 SelectionGranularity granularity,
 GtkTextIter *start,
 GtkTextIter *end)
{
 *end = *start;

 if (granularity == SELECT_WORDS)
 {
     if (gtk_text_iter_inside_word (start))
     {
 if (!gtk_text_iter_starts_word (start)) {
gtk_text_iter_backward_visible_word_start (start);
 }
 
 if (!gtk_text_iter_ends_word (end)) {
 if (!gtk_text_iter_forward_visible_word_end (end)) {
gtk_text_iter_forward_to_end (end);
 }
 }
 }
 else
 {
 GtkTextIter tmp;

 tmp = *start;
 if (gtk_text_iter_backward_visible_word_start (&tmp))
gtk_text_iter_forward_visible_word_end (&tmp);

 if (gtk_text_iter_get_line (&tmp) == gtk_text_iter_get_line (start))
*start = tmp;
 else
gtk_text_iter_set_line_offset (start, 0);

 tmp = *end;
 if (!gtk_text_iter_forward_visible_word_end (&tmp))
gtk_text_iter_forward_to_end (&tmp);

 if (gtk_text_iter_ends_word (&tmp))
gtk_text_iter_backward_visible_word_start (&tmp);

 if (gtk_text_iter_get_line (&tmp) == gtk_text_iter_get_line (end))
*end = tmp;
 else
gtk_text_iter_forward_to_line_end (end);
}
 }


It seems that medit author solved this by messing with the logic here.

Since GtkTextView is a general purpose widget, gsv sounds like the right place. But does GtkTextView provide a hook so that gsv can change the behavior without changing the gtk source?

Regards,
Jay


--- On Sat, 11/29/08, Jesse van den Kieboom <jesse icecrew nl> wrote:
From: Jesse van den Kieboom <jesse icecrew nl>
Subject: Re: [gedit-list] hiliting words that contain digits and underscores by double clicking
To: "Doug McNutt" <douglist macnauchtan com>
Cc: gedit-list gnome org
Date: Saturday, November 29, 2008, 5:16 PM

This is also something I want to see implemented/changed. There are
several options here. Either we change 'fix'/change it in gsv and make
it a permanent fix, or we can set a string property on gsv setting the
characters which are considered to be word characters. Another option
might be to use triple click to expand further including characters
currently not considered to be word characters (like _), and do
quadruple click for line selection. There could even be an option in
gedit setting which characters are considered word characters.

As an intermediate solution, this could be implemented as a plugin, but
in the end I think it belongs in gsv.


Jesse

Op zaterdag 29-11-2008 om 09:55 uur [tijdzone -0700], schreef Doug
McNutt:
At 05:35 -0800 11/29/08, Jason Walker wrote:
How can I change the behavior of gedit so that when i double click on
a C/C++ identifier, the whole identifier is selected, not just part
of it. For instance, if I double-click on _t|his_is_my_identifier
where | represents my mouse pointer's approximate position, only
"this" is selected. What should I modify to change this?

Date: Fri, 16 Nov 2007 09:55:41 -0200
Subject: [gedit-list] selecting whole words when variables

That posting generated some comparisons to the way terminal behaves.
The general conclusion of the resulting thread was that the operation
is performed not in gedit but by the underlying text methods of GTk.

What's really needed is a variable, set  for each document , that is
a list of the characters that may comprise a word.  $, &nbsp;, -, _,
[0-9], / ,. , and some more need to be included for different
languages. Unicode could make the whole thing non-trivial. The usual
technique is to step backwards until finding a non-word character and
then forward for another.

Auto license plate numbers are my current frustration.

--
Jesse van den Kieboom

Personal: http://www.icecrew.nl
Professional: http://www.novowork.com

_______________________________________________
gedit-list mailing list
gedit-list gnome org
http://mail.gnome.org/mailman/listinfo/gedit-list








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