Re: [gtk-list] Re:Center text



Evan> I'm  not  sure   what exactly  the    find_line_at_point  function in
Evan> gtktext.c does, and why it isn't made public, but if you're trying to
Evan>  find a way to  get  the widget  to jump  to  a certain line versions
Evan>    greater than  0.4.5  of   gEdit   (meaning CVS)  have fixed   that
Evan> problem... Off of GNOME's cvs tree the function is in search.c and is
Evan>  named seek_to_line,  and  in version 0.4.5   it's  at the  bottom of
Evan> commands.c... Basically it just calculates the number of lines in the
Evan> text widget,  and with that  information sets the vertical adjustment
Evan> to  the value that   corresponds to the  specified  line number.. The
Evan> algorithm isn't exact, but seems to work pretty well...

Evan> On 12-Aug-98 Marc wrote:
>> Pelaez Valdes Canek wrote:
>>> Yeah, in fact I'm using that right now, but I dont like it.
>>> 
>>> And I want  that the view  area "jump"  to the  point  in question, not
>>> scrolling to it.
>>  So do I !
>> 
>> Last month, this problem was already  raised (Subject: GtkText: annoying
>> scroll): Some Guy wrote:
>>>  I saw a question  in the archives  about a search+replace function, to
>>> scroll to  a certain point when a  string is found.   The answer posted
>>> was to  just  do a insert_text/delete_text  combo  where the string was
>>> found.  There are two problems with this solution:  one, if the text is
>>> frozen, this doesn't  work. Two, instead of  just zipping down to where
>>> the text is inserted,  it scrolls (which can  take quite a long time if
>>> there is a  lot of  text between the   current point and the  insertion
>>> point).
>>
>>> I  looked  through the gtktext.c   source, and found  a static function
>>> find_line_at_point, which is called by gtk_text_insert_text if the text
>>> is unfrozen. My question is, why is this function static? It seems like
>>> a very  valuable  function,  and if  it   were available to  use  by an
>>> application it would really  help with stuff like search+replace (there
>>> is even a flag to set whether it scrolls to the line or just zaps right
>>> there!).  Can this function be made public  in the next gtk release, or
>>> at least a wrapper function? It would be very useful.
>>  Marc wrote:
>>> I recently posted a question on this subject but no-one answered...
>>  -- Marc ** ERROR **: sigsegv caught
>> 
>> -- To   unsubscribe: mail -s unsubscribe   gtk-list-request@redhat.com <
>> /dev/null

Evan> -- Evan Lawrence

Let me guess:

You take

	gfloat up = GTK_ADJUSTMENT (GTK_TEXT (text)->vadj)->upper;
	gfloat lo = GTK_ADJUSTMENT (GTK_TEXT (text)->vadj)->lower;

then take the lenght of  the text (gint len),  the point where the selected
text are (gint pos), and then calculate

	if (len)
	    gfloat adj = (up-lo)*pos/len; ??? 

That not work pretty well; I'm gonna try your  function (if uses the number
of lines instead length maybe works better). 

Thanks! 

					Canek



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