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



If you look at the source of gtktextview.c, you'll see that the extend_.... function is called from gtk_text_view_start_selection_drag, which in turn is called from the button_press_event handler. Now of course, there is a lot more going on there, but a first idea to fix this could be to connect/overload  the button_press handler and after the textview has done its part, detect the dubble click (GDK_2BUTTON_PRESS) and extend the current selection according to our own criteria.


Jesse

Op 30 nov 2008, om 15:21 heeft Jason Walker het volgende geschreven:

Feel free to correct me if I'm wrong: In 
http://library.gnome.org/devel/gtk/2.14/GtkTextView.html
I don't see any signal that can be used to deduce that a word selection should occur. So, how can we trap the double-click at all? (this is not like the button example). So, if I am not missing something, gsv cannot do it without messing with gtk+ internals.
Any ideas?
Jay


From: Jason Walker <jaywalkie yahoo com>
To: gedit-list gnome org
Sent: Sunday, November 30, 2008 7:49:54 AM
Subject: Re: [gedit-list] Fwd: hiliting words that contain digits and underscores by double clicking

As to the Gtk signal, i found this:
http://library.gnome.org/devel/gtk-faq/stable/x544.html
One learns everyday :)
Regards,
Jay


From: Jason Walker <jaywalkie yahoo com>
To: gedit-list gnome org
Sent: Sunday, November 30, 2008 7:09:45 AM
Subject: Re: [gedit-list] Fwd: hiliting words that contain digits and underscores by double clicking

Honestly I don't know if this same method is called for other cases where the word selection may be triggered. I know it was called when GtkTextView capture GDK_2BUTTON_(something, I don't recall). Well, at least now i know that it's not a simple configuration issue. Maybe gsv should capture (somehow, I don't know) this mouse event, and then signal the managing program (gedit, in our case). In case there is no slot registered, it can return it back to gtk so that it can do whatever it is doing right now. But I don't know how it will capture this mouse event or how to hand it back to gtk. Even a proof of concept would be nice, I think.
 
Regards,
Jay


From: Jesse van den Kieboom <jesse icecrew nl>
To: Jesse van den Kieboom <jesse icecrew nl>
Cc: gedit-list gnome org
Sent: Sunday, November 30, 2008 6:52:08 AM
Subject: Re: [gedit-list] Fwd: hiliting words that contain digits and underscores by double clicking


Op 30 nov 2008, om 12:47 heeft Jesse van den Kieboom het volgende geschreven:

<snip/>
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,

<snip/>

 }


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?


I think we can yes. I haven't looked at the source, but it seems to me that we could act in an appropriate way to the mouse event in either gsv, or in a gedit plugin as a proof of concept. It should be possible to handle the word selection ourselves, though I'm not sure if there might be any nasty side effects (cases where we might disable some other behavior because we cannot detect whether a word selection is triggered by the mouse event, or something else).

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






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




_______________________________________________
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]