GtkTextView: annoying delay



Hi List,

i have a small problem with a simple program:

---
#include <gtk/gtk.h>

static void tb_insert_text (GtkTextBuffer *tb, GtkTextIter *iter, gchar *c, gint len, GtkTextView *tv)
{
   GtkTextIter s;
   GtkTextIter e;
   gtk_text_buffer_get_bounds (tb, &s, &e);
   gtk_text_buffer_apply_tag_by_name (tb, "test", &s, &e);
   gtk_widget_queue_draw (GTK_WIDGET (tv));
}

int main (int argc, char *argv[])
{
   GtkWidget *window;
   GtkWidget *tv;
   GtkTextBuffer *tb;
   gtk_init (&argc, &argv);
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);
   tb = gtk_text_buffer_new (NULL);
   tv = gtk_text_view_new_with_buffer (tb);
g_signal_connect_after (G_OBJECT (tb), "insert-text", G_CALLBACK (tb_insert_text), tv);
   gtk_text_buffer_create_tag (tb, "test", "foreground", "blue", NULL);
   gtk_container_add (GTK_CONTAINER (window), tv);
   gtk_widget_show (tv);
   gtk_widget_show (window);
   gtk_main ();
   return 0;
}
---

All the text should get tagged with the "test"-tag and turned blue after a user enters some text into the TextView.

Now, when i enter a single character at the end of the the text, the character stays black for a second until it gets blue. This is very annoying because the final program has to react very quick to new user input. Is there a way to force the Buffer/View to apply and display the tag immediately ? I already tried gtk_widget_queue_draw() as you can see, with no visible results. Also, i tried to do the hightlighting on the "changed" event, insteat of after the "insert-text" event ...

Thanks!

-Maximilian Treiber




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