| 507 */ |
507 */ |
| 508 int gnt_text_view_tag_change(GntTextView *view, const char *name, const char *text, gboolean all) |
508 int gnt_text_view_tag_change(GntTextView *view, const char *name, const char *text, gboolean all) |
| 509 { |
509 { |
| 510 GList *alllines = g_list_first(view->list); |
510 GList *alllines = g_list_first(view->list); |
| 511 GList *list, *next, *iter, *inext; |
511 GList *list, *next, *iter, *inext; |
| |
512 const int text_length = text ? g_utf8_strlen(text, -1) : 0; |
| 512 int count = 0; |
513 int count = 0; |
| 513 for (list = view->tags; list; list = next) { |
514 for (list = view->tags; list; list = next) { |
| 514 GntTextTag *tag = list->data; |
515 GntTextTag *tag = list->data; |
| 515 next = list->next; |
516 next = list->next; |
| 516 if (strcmp(tag->name, name) == 0) { |
517 if (strcmp(tag->name, name) == 0) { |
| 519 |
520 |
| 520 count++; |
521 count++; |
| 521 |
522 |
| 522 before = g_strndup(view->string->str, tag->start); |
523 before = g_strndup(view->string->str, tag->start); |
| 523 after = g_strdup(view->string->str + tag->end); |
524 after = g_strdup(view->string->str + tag->end); |
| 524 change = (tag->end - tag->start) - (text ? strlen(text) : 0); |
525 change = (tag->end - tag->start) - text_length; |
| 525 |
526 |
| 526 g_string_printf(view->string, "%s%s%s", before, text ? text : "", after); |
527 g_string_printf(view->string, "%s%s%s", before, text ? text : "", after); |
| 527 g_free(before); |
528 g_free(before); |
| 528 g_free(after); |
529 g_free(after); |
| 529 |
530 |