tags:

views:

59

answers:

1

How to make it behave like a prompt,

say,if too much text overflows the buffer limit,the previous should be overwritten.

Is it possible for gtk_text_view?

A: 

Connect to the insert-text signal of GtkTextBuffer. In your callback, get the length of the text. If it's longer than the limit, get two start iters, and move one of them forward by the amount of characters you want to delete:

GtkTextIter range_start, range_end;
gtk_text_buffer_get_start_iter(buffer, &range_start);
range_end = range_start;
gtk_text_iter_forward_chars(&range_end, num_chars);
gtk_text_buffer_delete(buffer, &range_start, &range_end);

That said, you'd have to put a LOT of text in a GtkTextBuffer to crash the application.

ptomato
LOT=several gigabyte?
httpinterpret
If you're dealing with several gigabytes, why are you even using a text view? No user is ever going to scroll through gigabytes of text. No user will even live long enough to do that! Maybe you need to filter the data or write it directly to a disk file.
ptomato