Eric, thanks again. I ended up using g_signal_connect() on "key-press-event" (instead of "insert-text"). This makes it easier IMO to handle specific cases, since the callback fn can return TRUE if it did anything or FALSE to get GTK default behavior, unlike void insert-text fn. Plus if you paste 20000 chars, the insert-text callback will process every one of them, whereas key-press-event will get none of them.
I think I tried to do my own version of the move-cursor and change italic/bold state buttons, but abandoned it, don't remember why. But I took the advice to "store" the italic/bold states in the toolbar button states. It's a little quirky since the text cursor can move away from an italic/bold region and still the i/b tutton, if already pressed, stays that way and so typing at the new cursor location is i/b. Anyway, with Italic button pressed, for example, I get the char via key-press-event. (If style tool button not pressed, then return FALSE). The characters are just keycodes at this point, so need to kick back most of them to default: switch (event->keyval) { case GDK_KEY_Return: case GDK_KEY_Delete: case GDK_KEY_Shift_L: case GDK_KEY_Shift_R: case GDK_KEY_Alt_L: case GDK_KEY_Alt_R: case GDK_KEY_Control_L: case GDK_KEY_Up: case GDK_KEY_Down: case GDK_KEY_Left: case GDK_KEY_Right: case GDK_KEY_End: case GDK_KEY_Home: // case GDK_KEY_BackSpace: return FALSE; } or you get the first letter after "GDK_KEY_". Still haven't fixed up the backspace case. Then call text = gdk_keyval_name(event->keyval); If strlen(text) > 1, then go through this exercise: switch (event->keyval) { case GDK_KEY_exclam: text = "!"; break; case GDK_KEY_quotedbl: text = "\""; break; case GDK_KEY_numbersign: text = "#"; break; case GDK_KEY_dollar: text = "$"; break; case GDK_KEY_percent: text = "%"; break; case GDK_KEY_ampersand: text = "&"; break; case GDK_KEY_apostrophe: text = "'"; break; case GDK_KEY_parenleft: text = "("; break; case GDK_KEY_parenright: text = ")"; break; case GDK_KEY_asterisk: text = "*"; break; case GDK_KEY_plus: text = "+"; break; case GDK_KEY_colon: text = ":"; break; case GDK_KEY_less: text = "<"; break; case GDK_KEY_greater: text = ">"; break; case GDK_KEY_question: text = "?"; break; case GDK_KEY_at: text = "@"; break; case GDK_KEY_underscore: text = "_"; break; case GDK_KEY_braceleft: text = "{"; break; case GDK_KEY_bar: text = "|"; break; case GDK_KEY_braceright: text = "}"; break; case GDK_KEY_asciitilde: text = "~"; break; } Then after all that malarkey, simply insert the char, get the iters around it, and apply the style to it. Then return TRUE. So this works pretty good (good enough :-) ). Even though I didn't use your suggested code GSList *tlist=NULL; GSList *next=NULL; tlist=gtk_text_iter_get_tags(&start); if(tlist!=NULL) { do { next=tlist->next; gchar *string=NULL; g_object_get(G_OBJECT(tlist->data), "name", &string, NULL); g_print("%s\n", string); g_free(string); tlist=g_slist_next(tlist); }while(next!=NULL); } else g_print("No Tags\n"); if(tlist!=NULL) g_slist_free(tlist); after cursor motion, I did deploy that elsewhere to find format tags (for example in exporting to HTML, for which I have a crude version). Once again thanks for that do-while tlist loop -- I *never* would've figured out how to write that! --Doug On Tue, Jun 20, 2017 at 10:47 PM, <cecas...@aol.com> wrote: > > On that last post, I think that I have some bad pointer arithmetic. Moving > a pointer past the end and freeing a moved pointer. Not so good. > > Eric > > ... > GSList *tlist=NULL; > GSList *p=NULL; > GSList *next=NULL; > tlist=gtk_text_iter_get_tags(&start); > p=tlist; > if(tlist!=NULL) > { > do > { > next=p->next; > gchar *string=NULL; > g_object_get(G_OBJECT(p->data), "name", &string, NULL); > g_print("%s\n", string); > g_free(string); > if(next!=NULL)p=g_slist_next(p); > }while(next!=NULL); > } > else g_print("No Tag\n"); > > if(tlist!=NULL) g_slist_free(tlist); > ... > > > -----Original Message----- > From: Eric Cashon via gtk-app-devel-list <gtk-app-devel-list@gnome.org> > To: dougm <do...@bravoecho.net> > Cc: gtk-app-devel-list <gtk-app-devel-list@gnome.org> > Sent: Tue, Jun 20, 2017 4:48 pm > Subject: Re: turn on italics in TextView > > > > Another option is to look at the properties of the tags to get the > information that you need. This might work better than saving globals and > matching pointers. > > Eric > > ... > GSList *tlist=NULL; > GSList *next=NULL; > tlist=gtk_text_iter_get_tags(&start); > if(tlist!=NULL) > { > do > { > next=tlist->next; > gchar *string=NULL; > g_object_get(G_OBJECT(tlist->data), "name", &string, NULL); > g_print("%s\n", string); > g_free(string); > tlist=g_slist_next(tlist); > }while(next!=NULL); > } > else g_print("No Tags\n"); > > if(tlist!=NULL) g_slist_free(tlist); > ... > > > > > > _______________________________________________ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list