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

Re: GtkTextMark right gravity



On Wed, Feb 05, 2003 at 02:58:49PM +1100, Darryl Ross wrote:
> I am trying to mark a section of text within a GtkTextBuffer and then 
> later retrieve the text along with any changes made within the section. 
> I have done the following:
> 
>     /* mark the section */
>     start_mark = gtk_text_buffer_create_mark(buffer, NULL, &iter, TRUE);
>     gtk_text_buffer_insert(buffer, &iter, "Hello, this is some text", -1);
>     end_mark = gtk_text_buffer_create_mark(buffer, NULL, &iter, FALSE);
>     /* here is some more text */   
>     gtk_text_buffer_insert(buffer, &iter, "some more text", -1);
> 
>     /* retrieve the section */
>     gtk_text_buffer_get_iter_at_mark(buffer, &start, start_mark);
>     gtk_text_buffer_get_iter_at_mark(buffer, &end, end_mark);
>     text = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
> 
> When I get the text the "some more text" text is included if end_mark 
> has left gravity set to false, but it is not included if end_mark has 
> left gravity set to true. I want end_mark to be right gravity as I want 
> insertions at the end of the section to remain within the marked section.
> 

If end_mark has right gravity and you insert at end_mark, then the
inserted text should be to the left of end_mark, thus inside your
marked section.

Is the problem just how to keep "some more text" from being inside the
section? To do that you probably have to move the end_mark after
inserting "some more text", or create end_mark after inserting it, or
something.

Havoc



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