Its been almost a month since a last posting. How time flies. Most of my
time has been taken up between making some final adjustments to my Ph.D
thesis prior to submission and chasing up a whole pile of work related
matters. But now, for a while at least, I can give some more attention
to Gnocl. The last issue that I was working was inserting/retrieving
Pango markup strings with a GtkTextBuffer. After solving something of a
glitch in adding tags to single characters (I'd completely forgotten
that iters are invalid after changes to the content of text buffer.
Resolved the problem through the use of markers as in function that I've
just added to the code:
GtkTextMark *tagStart, *tagEnd;
GtkTextIter start, end;
tagStart = gtk_text_buffer_create_mark (buffer,"tagStart", iter, 1);
gtk_text_buffer_insert (buffer, iter, txt, -1);
tagEnd = gtk_text_buffer_get_insert(buffer);
applyTags (buffer, tag, tagStart, tagEnd);
Where:
void applyTags (GtkTextBuffer *buffer, gchar *tag, GtkTextMark *tagStart, GtkTextMark *tagEnd) {
GtkTextIter start, end;
gtk_text_buffer_get_iter_at_mark(buffer,&start,tagStart);
gtk_text_buffer_get_iter_at_mark(buffer,&end,tagEnd);
gtk_text_buffer_apply_tag_by_name (buffer,tag, &start,&end);
}
At the moment single tags are fine, ie bold but it might be necessary to nest tags, ie bold-underline. The next question is, should I pass a string of tag names, or a linked-list? I'll think about this one tomorrow!
GtkTextMark *tagStart, *tagEnd;
GtkTextIter start, end;
tagStart = gtk_text_buffer_create_mark (buffer,"tagStart", iter, 1);
gtk_text_buffer_insert (buffer, iter, txt, -1);
tagEnd = gtk_text_buffer_get_insert(buffer);
applyTags (buffer, tag, tagStart, tagEnd);
Where:
void applyTags (GtkTextBuffer *buffer, gchar *tag, GtkTextMark *tagStart, GtkTextMark *tagEnd) {
GtkTextIter start, end;
gtk_text_buffer_get_iter_at_mark(buffer,&start,tagStart);
gtk_text_buffer_get_iter_at_mark(buffer,&end,tagEnd);
gtk_text_buffer_apply_tag_by_name (buffer,tag, &start,&end);
}
At the moment single tags are fine, ie bold but it might be necessary to nest tags, ie bold-underline. The next question is, should I pass a string of tag names, or a linked-list? I'll think about this one tomorrow!
Comments