Re: GtkTextBuffer: how to insert new line?



You cannot use -1 for the length, at least according to the documentation.

void        gtk_text_buffer_insert_at_cursor
                                           (GtkTextBuffer <cid:part1.04040407.06070302@zebradevelopment.com> 
*buffer,
                                            const gchar *text,
                                            gint len);

/buffer/ : a GtkTextBuffer <cid:part1.04040407.06070302@zebradevelopment.com>
/text/ :        some text in UTF-8 format
/len/ :         length of text, in bytes


Plus, why are you adding a NULL terminator? And yes, it inserted four newlines. I put four to make it more obvious.

Felix Kater wrote:

Paolo Costabel:

I just tried this:

   gtk_text_buffer_insert_at_cursor(buffer, "\n\n\n\n", 4);

and works fine here (gtk 2.4.10).

What call are you using?

Hm.
a)

First I used gtk_text_buffer_insert_at_cursor(buffer, "\n\0", -1);
This didn't work (maybe the 0 termination is not right this way?)

b)

then I just tried gtk_text_buffer_insert_at_cursor(buffer, "\n", -1);
which is of course wrong for what I realize now (missing 0 termination).

c)

Why are you using 4 times "\n"? Is it creating 4 new lines or just one?


Felix






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