2 * Copyright (C) 2008 - 2016 The Geeqie Team
4 * Authors: Vladimir Nadvornik, Laurent Monin
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "logwindow.h"
36 GtkWidget *scrolledwin;
38 GtkTextTag *color_tags[LOG_COUNT];
40 GtkWidget *regexp_box;
44 GtkWidget *timer_data;
45 GtkWidget *debug_level;
46 gint debug_value; /**< Not used */
47 GtkWidget *search_entry_box;
48 gboolean highlight_all;
51 enum LogWindowSearchDirection {
52 LOGWINDOW_SEARCH_BACKWARDS,
53 LOGWINDOW_SEARCH_FORWARDS
56 static LogWindow *logwindow = nullptr;
58 static void hide_cb(GtkWidget *, LogWindow *)
62 static gboolean iter_char_search_cb(gunichar ch, gpointer data)
66 if (ch == GPOINTER_TO_UINT(data))
79 * @brief Handle escape and F1 keys
85 * If escape key pressed, hide log window. \n
86 * If no text selected, form a selection bounded by space characters or
87 * start and end of line. \n
88 * If F1 pressed, execute command line program: \n
89 * <options->log_window.action> <selected text>
92 static gboolean key_pressed(GtkWidget *, GdkEventKey *event, LogWindow *logwin)
94 GtkTextBuffer *buffer;
96 GtkTextIter chr_start;
97 GtkTextIter cursor_iter;
99 GtkTextIter line_start;
100 GtkTextMark *cursor_mark;
104 if (event && event->keyval == GDK_KEY_Escape)
105 gtk_widget_hide(logwin->window);
107 if (event && event->keyval == GDK_KEY_F1)
109 if (strlen(options->log_window.action) > 0)
111 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text));
113 if (!gtk_text_buffer_get_has_selection(buffer))
115 cursor_mark = gtk_text_buffer_get_insert(buffer);
116 gtk_text_buffer_get_iter_at_mark(buffer, &cursor_iter, cursor_mark);
118 line_start = cursor_iter;
119 gtk_text_iter_set_line_offset(&line_start, 0);
120 line_end = cursor_iter;
121 gtk_text_iter_forward_to_line_end(&line_end);
123 chr_start = cursor_iter;
124 gtk_text_iter_backward_find_char(&chr_start, static_cast<GtkTextCharPredicate>(iter_char_search_cb), GUINT_TO_POINTER(' '), &line_start);
126 chr_end = cursor_iter;
127 gtk_text_iter_forward_find_char(&chr_end, static_cast<GtkTextCharPredicate>(iter_char_search_cb), GUINT_TO_POINTER(' '), &line_end);
129 gtk_text_buffer_select_range(buffer, &chr_start, &chr_end);
132 if (gtk_text_buffer_get_selection_bounds(gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text)), &chr_start, &chr_end))
134 sel_text = gtk_text_buffer_get_text( gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text)), &chr_start, &chr_end, FALSE);
136 cmd_line = g_strconcat(options->log_window.action, " ", sel_text, NULL);
150 static void log_window_pause_cb(GtkWidget *, gpointer)
152 options->log_window.paused = !options->log_window.paused;
155 static void log_window_line_wrap_cb(GtkWidget *, gpointer data)
157 auto logwin = static_cast<LogWindow *>(data);
159 options->log_window.line_wrap = !options->log_window.line_wrap;
161 if (options->log_window.line_wrap)
163 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(logwin->text), GTK_WRAP_WORD);
167 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(logwin->text), GTK_WRAP_NONE);
171 static void log_window_timer_data_cb(GtkWidget *, gpointer)
173 options->log_window.timer_data = !options->log_window.timer_data;
176 static void log_window_regexp_cb(GtkWidget *text_entry, gpointer)
180 new_regexp = g_strdup(gq_gtk_entry_get_text(GTK_ENTRY(text_entry)));
181 set_regexp(new_regexp);
185 static void remove_green_bg(LogWindow *logwin)
187 GtkTextIter start_find;
188 GtkTextIter start_match;
189 GtkTextIter end_match;
190 GtkTextBuffer *buffer;
196 text = gq_gtk_entry_get_text(GTK_ENTRY(logwin->search_entry_box));
197 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text));
198 gtk_text_buffer_get_start_iter(buffer, &start_find);
200 while (gtk_text_iter_forward_search(&start_find, text, GTK_TEXT_SEARCH_VISIBLE_ONLY, &start_match, &end_match, nullptr))
202 list = gtk_text_iter_get_tags(&start_match);
205 g_object_get(list->data, "name", &tag_name, NULL);
206 if (g_strcmp0(tag_name, "green_bg") == 0)
208 gtk_text_buffer_remove_tag_by_name(buffer, "green_bg", &start_match, &end_match);
214 offset = gtk_text_iter_get_offset(&end_match);
215 gtk_text_buffer_get_iter_at_offset(buffer, &start_find, offset);
219 static void search_activate_event(GtkEntry *, LogWindow *logwin)
221 GtkTextIter start_find;
222 GtkTextIter start_match;
223 GtkTextIter end_match;
224 GtkTextBuffer *buffer;
225 GtkTextMark *cursor_mark;
226 GtkTextIter cursor_iter;
230 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text));
231 text = gq_gtk_entry_get_text(GTK_ENTRY(logwin->search_entry_box));
233 if (logwin->highlight_all)
235 gtk_text_buffer_get_start_iter(buffer, &start_find);
237 while (gtk_text_iter_forward_search(&start_find, text, GTK_TEXT_SEARCH_VISIBLE_ONLY, &start_match, &end_match, nullptr))
239 gtk_text_buffer_apply_tag_by_name(buffer, "gray_bg", &start_match, &end_match);
240 offset = gtk_text_iter_get_offset(&end_match);
241 gtk_text_buffer_get_iter_at_offset(buffer, &start_find, offset);
246 cursor_mark = gtk_text_buffer_get_insert(buffer);
247 gtk_text_buffer_get_iter_at_mark(buffer, &cursor_iter, cursor_mark);
249 if (gtk_text_iter_forward_search(&cursor_iter, text, GTK_TEXT_SEARCH_VISIBLE_ONLY, &start_match, &end_match, nullptr))
251 gtk_text_buffer_apply_tag_by_name(buffer, "gray_bg", &start_match, &end_match);
256 static gboolean search_keypress_event(GtkWidget *, GdkEventKey *, LogWindow *logwin, LogWindowSearchDirection direction)
258 GtkTextIter start_find;
259 GtkTextIter start_match;
260 GtkTextIter end_match;
261 GtkTextIter start_sel;
264 GtkTextBuffer *buffer;
265 GtkTextMark *cursor_mark;
266 GtkTextIter cursor_iter;
268 gboolean match_found = FALSE;
271 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text));
272 gtk_text_buffer_get_start_iter(buffer, &start_find);
274 text = gq_gtk_entry_get_text(GTK_ENTRY(logwin->search_entry_box));
275 if (strlen(text) == 0)
277 selected = gtk_text_buffer_get_selection_bounds(buffer, &start_sel, &end_sel);
280 text = gtk_text_buffer_get_text(buffer, &start_sel, &end_sel, FALSE);
281 gq_gtk_entry_set_text(GTK_ENTRY(logwin->search_entry_box), text);
285 if (logwin->highlight_all)
287 while (gtk_text_iter_forward_search(&start_find, text, GTK_TEXT_SEARCH_VISIBLE_ONLY, &start_match, &end_match, nullptr))
289 gtk_text_buffer_apply_tag_by_name(buffer, "gray_bg", &start_match, &end_match);
290 offset = gtk_text_iter_get_offset(&end_match);
291 gtk_text_buffer_get_iter_at_offset(buffer, &start_find, offset);
295 cursor_mark = gtk_text_buffer_get_insert(buffer);
296 gtk_text_buffer_get_iter_at_mark(buffer, &cursor_iter, cursor_mark);
298 if (direction == LOGWINDOW_SEARCH_BACKWARDS)
300 match_found = gtk_text_iter_backward_search( &cursor_iter, text, GTK_TEXT_SEARCH_VISIBLE_ONLY, &start_match, &end_match, nullptr);
304 match_found = gtk_text_iter_forward_search( &cursor_iter, text, GTK_TEXT_SEARCH_VISIBLE_ONLY, &start_match, &end_match, nullptr);
309 remove_green_bg(logwin);
311 gtk_text_buffer_apply_tag_by_name(buffer, "green_bg", &start_match, &end_match);
313 if (direction == LOGWINDOW_SEARCH_BACKWARDS)
315 gtk_text_buffer_place_cursor(buffer, &start_match);
319 gtk_text_buffer_place_cursor(buffer, &end_match);
322 cursor_mark = gtk_text_buffer_get_insert(buffer);
323 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(logwin->text), cursor_mark, 0.2, FALSE, 0.0, 0.0);
329 static gboolean backwards_keypress_event_cb(GtkWidget *widget, GdkEventKey *event, LogWindow *logwin)
331 search_keypress_event(widget, event, logwin, LOGWINDOW_SEARCH_BACKWARDS);
336 static gboolean forwards_keypress_event_cb(GtkWidget *widget, GdkEventKey *event, LogWindow *logwin)
338 search_keypress_event(widget, event, logwin, LOGWINDOW_SEARCH_FORWARDS);
343 static gboolean all_keypress_event_cb(GtkToggleButton *widget, LogWindow *logwin)
345 logwin->highlight_all = gtk_toggle_button_get_active(widget);
350 static gboolean debug_changed_cb(GtkSpinButton *widget, LogWindow *)
352 set_debug_level((gtk_spin_button_get_value(widget)));
357 static void search_entry_icon_cb(GtkEntry *, GtkEntryIconPosition pos, GdkEvent *, gpointer userdata)
359 auto logwin = static_cast<LogWindow *>(userdata);
360 GtkTextIter start_find;
361 GtkTextIter end_find;
362 GtkTextBuffer *buffer;
364 if (pos == GTK_ENTRY_ICON_SECONDARY)
366 gq_gtk_entry_set_text(GTK_ENTRY(logwin->search_entry_box), "");
368 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text));
369 gtk_text_buffer_get_start_iter(buffer, &start_find);
370 gtk_text_buffer_get_end_iter(buffer, &end_find);
371 gtk_text_buffer_remove_tag_by_name(buffer, "gray_bg", &start_find, &end_find);
372 gtk_text_buffer_remove_tag_by_name(buffer, "green_bg", &start_find, &end_find);
376 static void filter_entry_icon_cb(GtkEntry *entry, GtkEntryIconPosition, GdkEvent *, gpointer)
378 const gchar *blank = "";
379 gq_gtk_entry_set_text(entry, blank);
383 static LogWindow *log_window_create(LayoutWindow *lw)
387 GtkWidget *scrolledwin;
389 GtkTextBuffer *buffer;
394 GtkWidget *label = nullptr;
395 GtkWidget *search_box;
396 GtkWidget *backwards_button;
397 GtkWidget *forwards_button;
398 GtkWidget *all_button;
401 GtkWidget *image = nullptr;
403 logwin = g_new0(LogWindow, 1);
405 window = window_new("log", nullptr, nullptr, _("Log"));
407 win_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, PREF_PAD_SPACE);
408 gq_gtk_container_add(GTK_WIDGET(window), win_vbox);
409 gtk_widget_show(win_vbox);
411 gtk_window_resize(GTK_WINDOW(window), lw->options.log_window.w,
412 lw->options.log_window.h);
413 gq_gtk_window_move(GTK_WINDOW(window), lw->options.log_window.x, lw->options.log_window.y);
415 g_signal_connect(G_OBJECT(window), "delete_event",
416 G_CALLBACK(gtk_widget_hide_on_delete), NULL);
417 g_signal_connect(G_OBJECT(window), "key_press_event",
418 G_CALLBACK(key_pressed), logwin);
419 g_signal_connect(G_OBJECT(window), "hide",
420 G_CALLBACK(hide_cb), logwin);
421 gtk_widget_realize(window);
423 scrolledwin = gq_gtk_scrolled_window_new(nullptr, nullptr);
424 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
425 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
426 gq_gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
429 gq_gtk_box_pack_start(GTK_BOX(win_vbox), scrolledwin, TRUE, TRUE, 0);
430 gtk_widget_show(scrolledwin);
432 text = gtk_text_view_new();
433 gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
434 if (options->log_window.line_wrap)
436 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
440 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_NONE);
442 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
443 gtk_text_buffer_get_start_iter(buffer, &iter);
444 gtk_text_buffer_create_mark(buffer, "end", &iter, FALSE);
445 gq_gtk_container_add(GTK_WIDGET(scrolledwin), text);
446 gtk_widget_show(text);
449 gtk_text_buffer_create_tag(buffer, "gray_bg", "background", "gray", NULL);
450 gtk_text_buffer_create_tag(buffer, "green_bg", "background", "#00FF00", NULL);
452 hbox = pref_box_new(win_vbox, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
454 gtk_widget_show(hbox);
455 logwin->debug_level = pref_spin_new_int(hbox, _("Debug level:"), nullptr, 0, 4, 1, get_debug_level(), &logwin->debug_value);
456 g_signal_connect(logwin->debug_level, "value-changed", G_CALLBACK(debug_changed_cb), logwin);
458 logwin->pause = gtk_toggle_button_new();
459 label = gtk_label_new("Pause");
460 gtk_widget_set_tooltip_text(GTK_WIDGET(logwin->pause), _("Pause scrolling"));
461 gq_gtk_container_add(GTK_WIDGET(logwin->pause), label) ;
462 gq_gtk_box_pack_start(GTK_BOX(hbox),logwin->pause, FALSE, FALSE, 0) ;
463 g_signal_connect(logwin->pause, "toggled", G_CALLBACK(log_window_pause_cb), logwin);
464 gtk_widget_show_all(logwin->pause);
466 logwin->wrap = gtk_toggle_button_new();
467 label = gtk_label_new("Wrap");
468 gtk_widget_set_tooltip_text(GTK_WIDGET(logwin->wrap), _("Enable line wrap"));
469 gq_gtk_container_add(GTK_WIDGET(logwin->wrap), label) ;
470 gq_gtk_box_pack_start(GTK_BOX(hbox),logwin->wrap, FALSE, FALSE, 0) ;
471 g_signal_connect(logwin->wrap, "toggled", G_CALLBACK(log_window_line_wrap_cb), logwin);
472 gtk_widget_show_all(logwin->wrap);
474 logwin->timer_data = gtk_toggle_button_new();
475 label = gtk_label_new("Timer");
476 gtk_widget_set_tooltip_text(GTK_WIDGET(logwin->timer_data), _("Enable timer data"));
477 gq_gtk_container_add(GTK_WIDGET(logwin->timer_data), label) ;
478 gq_gtk_box_pack_start(GTK_BOX(hbox),logwin->timer_data, FALSE, FALSE, 0) ;
479 if (options->log_window.timer_data)
481 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(logwin->timer_data), TRUE);
483 g_signal_connect(logwin->timer_data, "toggled", G_CALLBACK(log_window_timer_data_cb), logwin);
484 gtk_widget_show_all(logwin->timer_data);
486 search_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
487 gq_gtk_container_add(GTK_WIDGET(hbox), search_box);
488 gtk_widget_show(search_box);
490 logwin->search_entry_box = gtk_entry_new();
491 gq_gtk_box_pack_start(GTK_BOX(search_box), logwin->search_entry_box, FALSE, FALSE, 0);
492 gtk_widget_show(logwin->search_entry_box);
493 gtk_entry_set_icon_from_icon_name(GTK_ENTRY(logwin->search_entry_box), GTK_ENTRY_ICON_PRIMARY, GQ_ICON_FIND);
494 gtk_entry_set_icon_from_icon_name(GTK_ENTRY(logwin->search_entry_box), GTK_ENTRY_ICON_SECONDARY, GQ_ICON_CLEAR);
495 gtk_widget_show(search_box);
496 gtk_widget_set_tooltip_text(logwin->search_entry_box, _("Search for text in log window"));
497 g_signal_connect(logwin->search_entry_box, "icon-press", G_CALLBACK(search_entry_icon_cb), logwin);
498 g_signal_connect(logwin->search_entry_box, "activate", G_CALLBACK(search_activate_event), logwin);
500 theme = gtk_icon_theme_get_default();
501 pixbuf = gtk_icon_theme_load_icon(theme, GQ_ICON_PAN_UP, 20, GTK_ICON_LOOKUP_GENERIC_FALLBACK, nullptr);
502 image = gtk_image_new_from_pixbuf(pixbuf);
503 backwards_button = gtk_button_new();
504 gtk_button_set_image(GTK_BUTTON(backwards_button), GTK_WIDGET(image));
505 gtk_widget_set_tooltip_text(backwards_button, _("Search backwards"));
506 gq_gtk_box_pack_start(GTK_BOX(search_box), backwards_button, FALSE, FALSE, 0);
507 gtk_widget_show(backwards_button);
508 g_signal_connect(backwards_button, "button_release_event", G_CALLBACK(backwards_keypress_event_cb), logwin);
509 g_object_unref(pixbuf);
511 pixbuf = gtk_icon_theme_load_icon(theme, GQ_ICON_PAN_DOWN, 20, GTK_ICON_LOOKUP_GENERIC_FALLBACK, nullptr);
512 image = gtk_image_new_from_pixbuf(pixbuf);
513 forwards_button = gtk_button_new();
514 gtk_button_set_image(GTK_BUTTON(forwards_button), GTK_WIDGET(image));
515 gtk_widget_set_tooltip_text(forwards_button, _("Search forwards"));
516 gq_gtk_box_pack_start(GTK_BOX(search_box), forwards_button, FALSE, FALSE, 0);
517 gtk_widget_show(forwards_button);
518 g_signal_connect(forwards_button, "button_release_event", G_CALLBACK(forwards_keypress_event_cb), logwin);
519 g_object_unref(pixbuf);
521 pixbuf = gtk_icon_theme_load_icon(theme, "edit-select-all-symbolic", 20, GTK_ICON_LOOKUP_GENERIC_FALLBACK, nullptr);
522 image = gtk_image_new_from_pixbuf(pixbuf);
523 all_button = gtk_toggle_button_new();
524 gtk_button_set_image(GTK_BUTTON(all_button), GTK_WIDGET(image));
525 gtk_widget_set_tooltip_text(GTK_WIDGET(all_button), _("Highlight all"));
526 gq_gtk_box_pack_start(GTK_BOX(search_box), all_button, FALSE, FALSE, 0) ;
527 g_signal_connect(all_button, "toggled", G_CALLBACK(all_keypress_event_cb), logwin);
528 gtk_widget_show_all(all_button);
529 g_object_unref(pixbuf);
531 pref_label_new(hbox, _("Filter regexp"));
533 textbox = gtk_entry_new();
534 gq_gtk_box_pack_start(GTK_BOX(hbox), textbox, FALSE, FALSE, 0);
535 gtk_entry_set_icon_from_icon_name(GTK_ENTRY(textbox), GTK_ENTRY_ICON_SECONDARY, GQ_ICON_CLEAR);
536 gtk_widget_show(textbox);
537 g_signal_connect(G_OBJECT(textbox), "activate",
538 G_CALLBACK(log_window_regexp_cb), logwin);
539 g_signal_connect(textbox, "icon-press", G_CALLBACK(filter_entry_icon_cb), logwin);
542 logwin->window = window;
543 logwin->scrolledwin = scrolledwin;
546 logwin->regexp_box = textbox;
547 lw->log_window = logwin->window;
551 static void log_window_init(LogWindow *logwin)
553 GtkTextBuffer *buffer;
555 g_assert(logwin != nullptr);
557 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(logwin->text));
559 logwin->color_tags[LOG_NORMAL] = gtk_text_buffer_create_tag (buffer,
560 "black_foreground", "foreground", "black",
561 "family", "MonoSpace", NULL);
562 logwin->color_tags[LOG_MSG] = gtk_text_buffer_create_tag (buffer,
563 "blue_foreground", "foreground", "blue",
564 "family", "MonoSpace", NULL);
565 logwin->color_tags[LOG_WARN] = gtk_text_buffer_create_tag (buffer,
566 "orange_foreground", "foreground", "orange",
567 "family", "MonoSpace", NULL);
568 logwin->color_tags[LOG_ERROR] = gtk_text_buffer_create_tag (buffer,
569 "red_foreground", "foreground", "red",
570 "family", "MonoSpace", NULL);
573 static void log_window_show(LogWindow *logwin)
575 GtkTextView *text = GTK_TEXT_VIEW(logwin->text);
576 GtkTextBuffer *buffer;
580 buffer = gtk_text_view_get_buffer(text);
581 mark = gtk_text_buffer_get_mark(buffer, "end");
582 gtk_text_view_scroll_mark_onscreen(text, mark);
584 gtk_window_present(GTK_WINDOW(logwin->window));
586 log_window_append("", LOG_NORMAL); // to flush memorized lines
588 regexp = g_strdup(get_regexp());
589 if (regexp != nullptr)
591 gq_gtk_entry_set_text(GTK_ENTRY(logwin->regexp_box), regexp);
596 void log_window_new(LayoutWindow *lw)
598 if (logwindow == nullptr)
602 logwin = log_window_create(lw);
603 log_window_init(logwin);
607 log_window_show(logwindow);
612 LogMsg(const gchar *text, LogType type)
620 static void log_window_insert_text(GtkTextBuffer *buffer, GtkTextIter *iter,
621 const gchar *text, GtkTextTag *tag)
625 if (!text || !*text) return;
627 str_utf8 = utf8_validate_or_convert(text);
628 gtk_text_buffer_insert_with_tags(buffer, iter, str_utf8, -1, tag, NULL);
632 void log_window_append(const gchar *str, LogType type)
635 GtkTextBuffer *buffer;
637 static std::deque<LogMsg> memory;
639 if (logwindow == nullptr)
643 memory.emplace_front(str, type);
645 if (memory.size() >= static_cast<guint>(options->log_window_lines))
647 const auto count = std::max(options->log_window_lines - 1, 0);
649 memory.resize(count);
655 text = GTK_TEXT_VIEW(logwindow->text);
656 buffer = gtk_text_view_get_buffer(text);
658 if (options->log_window_lines > 0 && logwindow->lines >= options->log_window_lines)
660 GtkTextIter start, end;
662 gtk_text_buffer_get_start_iter(buffer, &start);
664 gtk_text_iter_forward_lines(&end, logwindow->lines - options->log_window_lines);
665 gtk_text_buffer_delete(buffer, &start, &end);
668 gtk_text_buffer_get_end_iter(buffer, &iter);
670 std::for_each(memory.crbegin(), memory.crend(), [buffer, &iter](const LogMsg &oldest_msg)
672 log_window_insert_text(buffer, &iter, oldest_msg.text.c_str(), logwindow->color_tags[oldest_msg.type]);
676 log_window_insert_text(buffer, &iter, str, logwindow->color_tags[type]);
678 if (!options->log_window.paused)
680 if (gtk_widget_get_visible(GTK_WIDGET(text)))
684 mark = gtk_text_buffer_get_mark(buffer, "end");
685 gtk_text_view_scroll_mark_onscreen(text, mark);
689 logwindow->lines = gtk_text_buffer_get_line_count(buffer);
691 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */