about summary refs log tree commit diff stats
path: root/src/ui/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/window.c')
-rw-r--r--src/ui/window.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index 2a76496c..c062e694 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -1355,6 +1355,13 @@ win_update_entry_message(ProfWin *window, const char *const id, const char *cons
 }
 
 void
+win_remove_entry_message(ProfWin *window, const char *const id)
+{
+    buffer_remove_entry_by_id(window->layout->buffer, id);
+    win_redraw(window);
+}
+
+void
 win_newline(ProfWin *window)
 {
     win_appendln(window, THEME_DEFAULT, "");
@@ -1644,6 +1651,18 @@ _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pa
 }
 
 void
+win_print_separator(ProfWin *window)
+{
+    int cols = getmaxx(window->layout->win);
+
+    int i;
+    for (i=1; i<cols; i++) {
+        wprintw(window->layout->win, "-");
+    }
+    wprintw(window->layout->win, "\n");
+}
+
+void
 win_redraw(ProfWin *window)
 {
     int i, size;
@@ -1652,7 +1671,14 @@ win_redraw(ProfWin *window)
 
     for (i = 0; i < size; i++) {
         ProfBuffEntry *e = buffer_get_entry(window->layout->buffer, i);
-        _win_print(window, e->show_char, e->pad_indent, e->time, e->flags, e->theme_item, e->from, e->message, e->receipt);
+
+        if (e->from == NULL && e->message && e->message[0] == '-') {
+            // just an indicator to print the separator not the actual message
+            win_print_separator(window);
+        } else {
+            // regular thing to print
+            _win_print(window, e->show_char, e->pad_indent, e->time, e->flags, e->theme_item, e->from, e->message, e->receipt);
+        }
     }
 }
 
@@ -1809,3 +1835,32 @@ win_handle_command_exec_result_note(ProfWin *window, const char *const type, con
     assert(window != NULL);
     win_println(window, THEME_DEFAULT, '!', value);
 }
+
+void
+win_insert_last_read_position_marker(ProfWin *window, char* id)
+{
+    int i, size;
+    size = buffer_size(window->layout->buffer);
+
+    // TODO: this is somewhat costly. We should improve this later.
+    // check if we already have a separator present
+    for (i = 0; i < size; i++) {
+        ProfBuffEntry *e = buffer_get_entry(window->layout->buffer, i);
+
+        // if yes, don't print a new one
+        if (e->id && (g_strcmp0(e->id, id) == 0)) {
+            return;
+        }
+    }
+
+    GDateTime *time = g_date_time_new_now_local();
+
+    // the separator will actually be print in win_redraw().
+    // this only puts it in the buffer and win_redraw() will interpret it.
+    // so that we have the correct length even when resizing.
+    buffer_append(window->layout->buffer, ' ', 0, time, 0, THEME_TEXT, NULL, "-", NULL, id);
+    win_redraw(window);
+
+    g_date_time_unref(time);
+}
+