Hi, I am trying GTK3 TextView, in C. I know how to apply tags, such as italics, bold, etc., to a region of text.
But how do I "turn on" a style (italics, bold, etc) while typing in the buffer? For example, suppose I am typing text and there are no styles set. Then I want to type in italics. I want to apply the italic tag to the insert point, after which whatever I typed would be in italics. I notice that when you place the insert cursor to the right of any existing styled text, the tags of the previous character are inherited, but only if the style is in effect before and after the insert point. Interestingly, the trailing newline can be stylized (invisibly), so when the insert point is at the end of a line and the last visible character has a style, then that style is inherited. I've looked at some methods that use a key-press signal and then apply a text tag to the region of the untagged character just typed, but that is slow and looks odd on screen -- the plain char is displayed and then replaced by the tagged char. I've also tried: gtk_text_buffer_insert_markup(buf, &iter, "<i>", -1); but that gets a Warning: Invalid markup string: ... Element 'markup' was closed, but the currently open element is 'i' and has no effect on the displayed text. Using <i></i> gets no warning but also has no effect. I finally resorted to: gtk_text_buffer_insert_markup(buf, &iter, "<i> </i>", -1); // 2 spaces gtk_text_iter_backward_char (&iter); gtk_text_buffer_place_cursor(buf, &iter); which lets me start typing in italics between 2 new (tagged) spaces -- that's not so bad. But clicking an "I" button to start typing in italics -- that is a basic editing function that has been around for decades. It must be possible in GTK somehow? thanks _______________________________________________ gtk-app-devel-list mailing list email@example.com https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list