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
?
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
?
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.