diff options
author | Michael Vetter <jubalh@iodoru.org> | 2020-05-27 08:59:00 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2020-05-27 08:59:00 +0200 |
commit | d251b56166d95ebd8a2714c923c97295179700eb (patch) | |
tree | dd0b2cdffe63394a62539ba605261a4f765b1329 | |
parent | 438552c14cd5fc32adcc39f5a88fd2c0a17242b2 (diff) | |
download | profani-tty-d251b56166d95ebd8a2714c923c97295179700eb.tar.gz |
Fix titlebar write position
Mistake introduced in 86f0e0ea7033a27a83a5c24091ae1fd5b579296d The functions later on dont set an explitic position when writing their strings. Fix https://github.com/profanity-im/profanity/issues/1346
-rw-r--r-- | src/ui/titlebar.c | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index 915faa6a..b557b59a 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -61,7 +61,8 @@ static gboolean typing; static GTimer *typing_elapsed; static void _title_bar_draw(void); -static int _show_self_presence(void); +static void _show_self_presence(void); +static int _calc_self_presence(void); static void _show_contact_presence(ProfChatWin *chatwin, int pos, int maxpos); static void _show_privacy(ProfChatWin *chatwin); static void _show_muc_privacy(ProfMucWin *mucwin); @@ -203,7 +204,7 @@ _title_bar_draw(void) // presence is written from the right side // calculate it first so we have a maxposition - maxrightpos = _show_self_presence(); + maxrightpos = _calc_self_presence(); if (current && current->type == WIN_CHAT) { ProfChatWin *chatwin = (ProfChatWin*) current; @@ -222,6 +223,8 @@ _title_bar_draw(void) _show_scrolled(current); } + _show_self_presence(); + wnoutrefresh(win); inp_put_back(); } @@ -248,6 +251,36 @@ _show_scrolled(ProfWin *current) } static int +_calc_self_presence(void) +{ + int tls_start = 0; + + switch (current_presence) + { + case CONTACT_ONLINE: + tls_start = 15; + break; + case CONTACT_AWAY: + tls_start = 13; + break; + case CONTACT_DND: + tls_start = 12; + break; + case CONTACT_CHAT: + tls_start = 13; + break; + case CONTACT_XA: + tls_start = 11; + break; + case CONTACT_OFFLINE: + tls_start = 16; + break; + } + + return tls_start - 1; +} + +static void _show_self_presence(void) { int presence_attrs = 0; @@ -345,8 +378,6 @@ _show_self_presence(void) mvwaddch(win, 0, cols - (tls_start - 4), ']'); wattroff(win, bracket_attrs); } - - return tls_start - 1; } static void |