about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-05-20 15:59:57 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-05-21 09:14:45 +0200
commit469fa8f863e7fc0c2db7bc9c576071d5d5529ae7 (patch)
tree01dfbaebb9f90329935099c7b01fcd6fd5a01e9f
parentd9edfa2da9dfa0df35719fd70176daa847033a84 (diff)
downloadprofani-tty-469fa8f863e7fc0c2db7bc9c576071d5d5529ae7.tar.gz
Display when scrolled up
Display [SCROLLED] in titlebar if a chat/muc/private win is scrolled up.

Implement https://github.com/profanity-im/profanity/issues/1289
-rw-r--r--src/ui/titlebar.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c
index fd73012b..fabcd410 100644
--- a/src/ui/titlebar.c
+++ b/src/ui/titlebar.c
@@ -65,6 +65,7 @@ static void _show_self_presence(void);
 static void _show_contact_presence(ProfChatWin *chatwin);
 static void _show_privacy(ProfChatWin *chatwin);
 static void _show_muc_privacy(ProfMucWin *mucwin);
+static void _show_scrolled(ProfWin *current);
 
 void
 create_title_bar(void)
@@ -201,6 +202,7 @@ _title_bar_draw(void)
         assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
         _show_contact_presence(chatwin);
         _show_privacy(chatwin);
+        _show_scrolled(current);
 
         if (typing) {
             wprintw(win, " (typing...)");
@@ -209,6 +211,7 @@ _title_bar_draw(void)
         ProfMucWin *mucwin = (ProfMucWin*) current;
         assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
         _show_muc_privacy(mucwin);
+        _show_scrolled(current);
     }
 
     _show_self_presence();
@@ -218,6 +221,24 @@ _title_bar_draw(void)
 }
 
 static void
+_show_scrolled(ProfWin *current)
+{
+    if (current && current->layout->paged == 1) {
+        int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET);
+
+        wattron(win, bracket_attrs);
+        wprintw(win, "[");
+        wattroff(win, bracket_attrs);
+
+        wprintw(win, "SCROLLED");
+
+        wattron(win, bracket_attrs);
+        wprintw(win, "]");
+        wattroff(win, bracket_attrs);
+    }
+}
+
+static void
 _show_self_presence(void)
 {
     int presence_attrs = 0;