From 35206453667d46e4e14903c435958a94d8ad00e5 Mon Sep 17 00:00:00 2001 From: DebXWoody Date: Sat, 29 May 2021 08:05:03 +0200 Subject: Attention flag for chat windows User is able to toggle a flag for chat windows. This flag should be used to mark the window for "Attention". Use Ctrl+f to mark the window. --- src/command/cmd_ac.c | 1 + src/command/cmd_defs.c | 3 +++ src/command/cmd_funcs.c | 7 +++++++ src/command/cmd_funcs.h | 1 + src/ui/inputwin.c | 22 ++++++++++++++++++++++ src/ui/titlebar.c | 12 ++++++++++++ src/ui/win_types.h | 1 + src/ui/window.c | 2 +- 8 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index b84d4d2e..03c6e404 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -471,6 +471,7 @@ cmd_ac_init(void) wins_ac = autocomplete_new(); autocomplete_add(wins_ac, "unread"); + autocomplete_add(wins_ac, "attention"); autocomplete_add(wins_ac, "prune"); autocomplete_add(wins_ac, "swap"); diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 4ebc3432..a1b00df0 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -973,6 +973,7 @@ static struct cmd_t command_defs[] = { parse_args, 0, 3, NULL, CMD_SUBFUNCS( { "unread", cmd_wins_unread }, + { "attention", cmd_wins_attention }, { "prune", cmd_wins_prune }, { "swap", cmd_wins_swap }) CMD_MAINFUNC(cmd_wins) @@ -981,6 +982,7 @@ static struct cmd_t command_defs[] = { CMD_SYN( "/wins", "/wins unread", + "/wins attention", "/wins prune", "/wins swap ") CMD_DESC( @@ -988,6 +990,7 @@ static struct cmd_t command_defs[] = { "Passing no argument will list all currently active windows and information about their usage.") CMD_ARGS( { "unread", "List windows with unread messages." }, + { "attention", "Marked windows" }, { "prune", "Close all windows with no unread messages." }, { "swap ", "Swap windows, target may be an empty position." }) CMD_NOEXAMPLES diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index b2262c5f..0f3fb3a8 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -1298,6 +1298,13 @@ cmd_wins_unread(ProfWin* window, const char* const command, gchar** args) return TRUE; } +gboolean +cmd_wins_attention(ProfWin* window, const char* const command, gchar** args) +{ + cons_show_wins(TRUE); + return TRUE; +} + gboolean cmd_wins_prune(ProfWin* window, const char* const command, gchar** args) { diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index 0785963b..aadcb55f 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -209,6 +209,7 @@ gboolean cmd_otr_sendfile(ProfWin* window, const char* const command, gchar** ar gboolean cmd_wins(ProfWin* window, const char* const command, gchar** args); gboolean cmd_wins_unread(ProfWin* window, const char* const command, gchar** args); +gboolean cmd_wins_attention(ProfWin* window, const char* const command, gchar** args); gboolean cmd_wins_prune(ProfWin* window, const char* const command, gchar** args); gboolean cmd_wins_swap(ProfWin* window, const char* const command, gchar** args); diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 74fcfbb4..e23fad68 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -125,6 +125,8 @@ static int _inp_rl_win_20_handler(int count, int key); static int _inp_rl_win_prev_handler(int count, int key); static int _inp_rl_win_next_handler(int count, int key); static int _inp_rl_win_next_unread_handler(int count, int key); +static int _inp_rl_win_attention_handler(int count, int key); +static int _inp_rl_win_attention_next_handler(int count, int key); static int _inp_rl_win_pageup_handler(int count, int key); static int _inp_rl_win_pagedown_handler(int count, int key); static int _inp_rl_subwin_pageup_handler(int count, int key); @@ -480,6 +482,8 @@ _inp_rl_startup_hook(void) rl_bind_keyseq("\\e\\e[C", _inp_rl_win_next_handler); rl_bind_keyseq("\\ea", _inp_rl_win_next_unread_handler); + rl_bind_keyseq("\\ef", _inp_rl_win_attention_handler); + rl_bind_keyseq("\\em", _inp_rl_win_attention_next_handler); rl_bind_keyseq("\\e\\e[5~", _inp_rl_subwin_pageup_handler); rl_bind_keyseq("\\e[5;3~", _inp_rl_subwin_pageup_handler); @@ -806,6 +810,24 @@ _inp_rl_win_next_unread_handler(int count, int key) return 0; } +static int +_inp_rl_win_attention_handler(int count, int key) { + ProfWin* current = wins_get_current(); + if ( current ) { + ProfChatWin* chatwin = (ProfChatWin*)current; + chatwin->has_attention = !chatwin->has_attention; + win_redraw(current); + } + return 0; +} + +static int +_inp_rl_win_attention_next_handler(int count, int key) { + //ProfWin* current = wins_get_current(); + return 0; +} + + static int _inp_rl_win_pageup_handler(int count, int key) { diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index dee6a7e2..0b2187ce 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -487,6 +487,18 @@ _show_privacy(ProfChatWin* chatwin) return; } + if (chatwin->has_attention) { + wprintw(win, " "); + wattron(win, bracket_attrs); + wprintw(win, "["); + wattroff(win, bracket_attrs); + wattron(win, encrypted_attrs); + wprintw(win, "ATTENTION"); + wattroff(win, encrypted_attrs); + wattron(win, bracket_attrs); + wprintw(win, "]"); + wattroff(win, bracket_attrs); + } if (chatwin->pgp_send || chatwin->pgp_recv) { GString* pgpmsg = g_string_new("PGP "); diff --git a/src/ui/win_types.h b/src/ui/win_types.h index e740b543..d40a5396 100644 --- a/src/ui/win_types.h +++ b/src/ui/win_types.h @@ -176,6 +176,7 @@ typedef struct prof_chat_win_t // For LMC char* last_message; char* last_msg_id; + gboolean has_attention; } ProfChatWin; typedef struct prof_muc_win_t diff --git a/src/ui/window.c b/src/ui/window.c index b6676774..f4439c74 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -158,7 +158,7 @@ win_create_chat(const char* const barejid) new_win->outgoing_char = NULL; new_win->last_message = NULL; new_win->last_msg_id = NULL; - + new_win->has_attention = FALSE; new_win->memcheck = PROFCHATWIN_MEMCHECK; return &new_win->window; -- cgit 1.4.1-2-gfad0 From 6dd11f0fff27d9019c9e362fc2567f2a0c64690b Mon Sep 17 00:00:00 2001 From: DebXWoody Date: Sat, 29 May 2021 09:30:13 +0200 Subject: Attention flagĀ for groupchats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Attention flag for groupchat and display the windows via "/wins attention" --- src/command/cmd_funcs.c | 2 +- src/ui/console.c | 20 ++++++++++++++++++++ src/ui/inputwin.c | 12 ++++++++++-- src/ui/ui.h | 1 + src/ui/win_types.h | 1 + src/ui/window.c | 1 + src/ui/window_list.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/ui/window_list.h | 1 + 8 files changed, 80 insertions(+), 3 deletions(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 0f3fb3a8..1efc6a18 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -1301,7 +1301,7 @@ cmd_wins_unread(ProfWin* window, const char* const command, gchar** args) gboolean cmd_wins_attention(ProfWin* window, const char* const command, gchar** args) { - cons_show_wins(TRUE); + cons_show_wins_attention(); return TRUE; } diff --git a/src/ui/console.c b/src/ui/console.c index 3eff47d5..74a7740f 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -506,6 +506,26 @@ cons_show_wins(gboolean unread) cons_alert(NULL); } +void +cons_show_wins_attention() { + ProfWin* console = wins_get_console(); + cons_show(""); + GSList* window_strings = wins_create_summary_attention(); + + GSList* curr = window_strings; + while (curr) { + if (g_strstr_len(curr->data, strlen(curr->data), " unread") > 0) { + win_println(console, THEME_CMD_WINS_UNREAD, "-", "%s", curr->data); + } else { + win_println(console, THEME_DEFAULT, "-", "%s", curr->data); + } + curr = g_slist_next(curr); + } + g_slist_free_full(window_strings, free); + + cons_alert(NULL); +} + void cons_show_room_invites(GList* invites) { diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index e23fad68..8de12115 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -36,6 +36,7 @@ #define _XOPEN_SOURCE_EXTENDED #include "config.h" +#include #include #include #include @@ -814,8 +815,15 @@ static int _inp_rl_win_attention_handler(int count, int key) { ProfWin* current = wins_get_current(); if ( current ) { - ProfChatWin* chatwin = (ProfChatWin*)current; - chatwin->has_attention = !chatwin->has_attention; + if (current->type == WIN_CHAT) { + ProfChatWin* chatwin = (ProfChatWin*)current; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); + chatwin->has_attention = !chatwin->has_attention; + } else if (current->type == WIN_MUC) { + ProfMucWin* mucwin = (ProfMucWin*)current; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + mucwin->has_attention = !mucwin->has_attention; + } win_redraw(current); } return 0; diff --git a/src/ui/ui.h b/src/ui/ui.h index 391b906c..3404992d 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -256,6 +256,7 @@ void cons_show_contacts(GSList* list); void cons_show_roster(GSList* list); void cons_show_roster_group(const char* const group, GSList* list); void cons_show_wins(gboolean unread); +void cons_show_wins_attention(); char* cons_get_string(ProfConsoleWin* conswin); void cons_show_status(const char* const barejid); void cons_show_info(PContact pcontact); diff --git a/src/ui/win_types.h b/src/ui/win_types.h index d40a5396..f2237a79 100644 --- a/src/ui/win_types.h +++ b/src/ui/win_types.h @@ -197,6 +197,7 @@ typedef struct prof_muc_win_t // For LMC char* last_message; char* last_msg_id; + gboolean has_attention; } ProfMucWin; typedef struct prof_conf_win_t ProfConfWin; diff --git a/src/ui/window.c b/src/ui/window.c index f4439c74..36825eab 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -213,6 +213,7 @@ win_create_muc(const char* const roomjid) new_win->is_omemo = FALSE; new_win->last_message = NULL; new_win->last_msg_id = NULL; + new_win->has_attention = FALSE; new_win->memcheck = PROFMUCWIN_MEMCHECK; diff --git a/src/ui/window_list.c b/src/ui/window_list.c index a90c7141..2c45ea97 100644 --- a/src/ui/window_list.c +++ b/src/ui/window_list.c @@ -1102,6 +1102,51 @@ wins_create_summary(gboolean unread) return result; } +GSList* +wins_create_summary_attention() +{ + GSList* result = NULL; + + GList* keys = g_hash_table_get_keys(windows); + keys = g_list_sort(keys, _wins_cmp_num); + GList* curr = keys; + + while (curr) { + ProfWin* window = g_hash_table_lookup(windows, curr->data); + gboolean has_attention = FALSE; + if (window->type == WIN_CHAT) { + ProfChatWin* chatwin = (ProfChatWin*)window; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); + has_attention = chatwin->has_attention; + } else if (window->type == WIN_MUC) { + ProfMucWin* mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + has_attention = mucwin->has_attention; + } + if ( has_attention) { + GString* line = g_string_new(""); + + int ui_index = GPOINTER_TO_INT(curr->data); + char* winstring = win_to_string(window); + if (!winstring) { + g_string_free(line, TRUE); + continue; + } + + g_string_append_printf(line, "%d: %s", ui_index, winstring); + free(winstring); + + result = g_slist_append(result, strdup(line->str)); + g_string_free(line, TRUE); + } + curr = g_list_next(curr); + } + + g_list_free(keys); + + return result; +} + char* win_autocomplete(const char* const search_str, gboolean previous, void* context) { diff --git a/src/ui/window_list.h b/src/ui/window_list.h index e02358f9..b2c752e0 100644 --- a/src/ui/window_list.h +++ b/src/ui/window_list.h @@ -87,6 +87,7 @@ void wins_lost_connection(void); void wins_reestablished_connection(void); gboolean wins_tidy(void); GSList* wins_create_summary(gboolean unread); +GSList* wins_create_summary_attention(); void wins_destroy(void); GList* wins_get_nums(void); void wins_swap(int source_win, int target_win); -- cgit 1.4.1-2-gfad0 From 1526a00123f2a00447a2578a11a451c26025b101 Mon Sep 17 00:00:00 2001 From: DebXWoody Date: Sat, 29 May 2021 20:16:21 +0200 Subject: Attention flag - Implemented Alt+m --- src/ui/core.c | 12 ++++++++++++ src/ui/inputwin.c | 16 +++++----------- src/ui/ui.h | 3 +++ src/ui/window.c | 33 +++++++++++++++++++++++++++++++++ src/ui/window_list.c | 32 ++++++++++++++++++++++++++++++++ src/ui/window_list.h | 1 + 6 files changed, 86 insertions(+), 11 deletions(-) diff --git a/src/ui/core.c b/src/ui/core.c index 4e4e39a0..50fba846 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -996,6 +996,18 @@ ui_win_unread(int index) } } +gboolean +ui_win_has_attention(int index) +{ + ProfWin* window = wins_get_by_num(index); + if (window) { + return win_has_attention(window); + } else { + return 0; + } +} + + char* ui_ask_password(gboolean confirm) { diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 8de12115..f8b67bfe 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -36,7 +36,6 @@ #define _XOPEN_SOURCE_EXTENDED #include "config.h" -#include #include #include #include @@ -815,15 +814,7 @@ static int _inp_rl_win_attention_handler(int count, int key) { ProfWin* current = wins_get_current(); if ( current ) { - if (current->type == WIN_CHAT) { - ProfChatWin* chatwin = (ProfChatWin*)current; - assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); - chatwin->has_attention = !chatwin->has_attention; - } else if (current->type == WIN_MUC) { - ProfMucWin* mucwin = (ProfMucWin*)current; - assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); - mucwin->has_attention = !mucwin->has_attention; - } + win_toggle_attention(current); win_redraw(current); } return 0; @@ -831,7 +822,10 @@ _inp_rl_win_attention_handler(int count, int key) { static int _inp_rl_win_attention_next_handler(int count, int key) { - //ProfWin* current = wins_get_current(); + ProfWin* window = wins_get_next_attention(); + if (window) { + ui_focus_win(window); + } return 0; } diff --git a/src/ui/ui.h b/src/ui/ui.h index 3404992d..f9ef5cff 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -75,6 +75,9 @@ int ui_close_all_wins(void); int ui_close_read_wins(void); void ui_close_win(int index); int ui_win_unread(int index); +gboolean ui_win_has_attention(int index); +gboolean win_has_attention(ProfWin* window); +gboolean win_toggle_attention(ProfWin* window); char* ui_ask_password(gboolean confirm); char* ui_get_line(void); char* ui_ask_pgp_passphrase(const char* hint, int prev_fail); diff --git a/src/ui/window.c b/src/ui/window.c index 36825eab..4fb7d5f7 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1842,6 +1842,39 @@ win_unread(ProfWin* window) } } +gboolean +win_has_attention(ProfWin* window) +{ + if (window->type == WIN_CHAT) { + ProfChatWin* chatwin = (ProfChatWin*)window; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); + return chatwin->has_attention; + } else if (window->type == WIN_MUC) { + ProfMucWin* mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + return mucwin->has_attention; + } + return FALSE; +} + +gboolean +win_toggle_attention(ProfWin* window) +{ + if (window->type == WIN_CHAT) { + ProfChatWin* chatwin = (ProfChatWin*)window; + assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); + chatwin->has_attention = !chatwin->has_attention; + return chatwin->has_attention; + } else if (window->type == WIN_MUC) { + ProfMucWin* mucwin = (ProfMucWin*)window; + assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); + mucwin->has_attention = !mucwin->has_attention; + return mucwin->has_attention; + } + return FALSE; +} + + void win_sub_print(WINDOW* win, char* msg, gboolean newline, gboolean wrap, int indent) { diff --git a/src/ui/window_list.c b/src/ui/window_list.c index 2c45ea97..3a46f59e 100644 --- a/src/ui/window_list.c +++ b/src/ui/window_list.c @@ -1205,6 +1205,38 @@ wins_get_next_unread(void) return NULL; } +ProfWin* +wins_get_next_attention(void) +{ + // get and sort win nums + GList* values = g_hash_table_get_values(windows); + values = g_list_sort(values, _wins_cmp_num); + GList* curr = values; + + while (curr) { + // copy from wins_get_next_unread - what is it? + if (current == GPOINTER_TO_INT(curr->data)) { + curr = g_list_next(curr); + continue; + } + + ProfWin* window_current = wins_get_by_num( current); + ProfWin* window = curr->data; + if( window_current == window ) { + curr = g_list_next(curr); + continue; + } + if (win_has_attention(window)) { + g_list_free(values); + return window; + } + curr = g_list_next(curr); + } + + g_list_free(values); + return NULL; +} + void wins_add_urls_ac(const ProfWin* const win, const ProfMessage* const message) { diff --git a/src/ui/window_list.h b/src/ui/window_list.h index b2c752e0..06ae6d7e 100644 --- a/src/ui/window_list.h +++ b/src/ui/window_list.h @@ -74,6 +74,7 @@ ProfWin* wins_get_by_string(const char* str); ProfWin* wins_get_next(void); ProfWin* wins_get_previous(void); ProfWin* wins_get_next_unread(void); +ProfWin* wins_get_next_attention(void); int wins_get_num(ProfWin* window); int wins_get_current_num(void); void wins_close_by_num(int i); -- cgit 1.4.1-2-gfad0 From b0a89db1d64893c2c5f5261c4b790165b16a442f Mon Sep 17 00:00:00 2001 From: DebXWoody Date: Sat, 29 May 2021 20:44:17 +0200 Subject: Attention flag message ( enabled, disabled) When the user enables or disabled the attention flag, a message will be displayed in the chat window. --- src/ui/inputwin.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index f8b67bfe..b2b2ea33 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -814,7 +814,12 @@ static int _inp_rl_win_attention_handler(int count, int key) { ProfWin* current = wins_get_current(); if ( current ) { - win_toggle_attention(current); + gboolean attention = win_toggle_attention(current); + if (attention) { + win_println(current, THEME_DEFAULT, "!", "Attention flag has been activated"); + } else { + win_println(current, THEME_DEFAULT, "!", "Attention flag has been deactivated"); + } win_redraw(current); } return 0; -- cgit 1.4.1-2-gfad0 From b9af7152f91fce53ef16a228e860cad5f4db1b4c Mon Sep 17 00:00:00 2001 From: DebXWoody Date: Sat, 29 May 2021 21:17:12 +0200 Subject: attention-flag - unittest - stub_ui --- tests/unittests/ui/stub_ui.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index dc36678b..578ebcda 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -210,6 +210,20 @@ ui_win_unread(int index) return 0; } +gboolean +ui_win_has_attention(int index) { + return FALSE; +} + +gboolean +win_has_attention(ProfWin* window){ + return FALSE; +} + +gboolean +win_toggle_attention(ProfWin* window){ + return FALSE; +} char* ui_ask_password(gboolean confirm) { @@ -828,6 +842,12 @@ void cons_show_wins(gboolean unread) { } + +void +cons_show_wins_attention() +{ +} + void cons_show_status(const char* const barejid) { -- cgit 1.4.1-2-gfad0 From 47e39a79759eddbacf8c738f8415e3e96381116e Mon Sep 17 00:00:00 2001 From: DebXWoody Date: Sat, 29 May 2021 22:01:44 +0200 Subject: Attention-flag: Fix next window --- src/ui/window_list.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/ui/window_list.c b/src/ui/window_list.c index 3a46f59e..c17ced50 100644 --- a/src/ui/window_list.c +++ b/src/ui/window_list.c @@ -1213,18 +1213,35 @@ wins_get_next_attention(void) values = g_list_sort(values, _wins_cmp_num); GList* curr = values; - while (curr) { - // copy from wins_get_next_unread - what is it? - if (current == GPOINTER_TO_INT(curr->data)) { + ProfWin* current_window = wins_get_by_num( current); + + // search the current window + while(curr) { + ProfWin* window = curr->data; + if( current_window == window ) { + current_window = window; curr = g_list_next(curr); - continue; + break; } + curr = g_list_next(curr); + } - ProfWin* window_current = wins_get_by_num( current); + // Start from current window + while ( current_window && curr) { ProfWin* window = curr->data; - if( window_current == window ) { - curr = g_list_next(curr); - continue; + if (win_has_attention(window)) { + g_list_free(values); + return window; + } + curr = g_list_next(curr); + } + // Start from begin + curr = values; + while ( current_window && curr) { + ProfWin* window = curr->data; + if( current_window == window) { + // we are at current again + break; } if (win_has_attention(window)) { g_list_free(values); -- cgit 1.4.1-2-gfad0 From 2bfe11ed828805e1a810cf3a22036710739743d7 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Mon, 31 May 2021 09:41:18 +0200 Subject: Display attention hint in titlebar for mucs too * Display the `[ATTENTION]` hint in the titlebar for both chatwins and mucwins. * Use THEME_TITLE_TEXT instead of THEME_TITLE_ENCRYPT * Have separate function `_show_attention` and don't do it in unrelated `_show_privacy`. --- src/ui/titlebar.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/ui/titlebar.c b/src/ui/titlebar.c index 0b2187ce..98af2b24 100644 --- a/src/ui/titlebar.c +++ b/src/ui/titlebar.c @@ -67,6 +67,7 @@ static void _show_contact_presence(ProfChatWin* chatwin, int pos, int maxpos); static void _show_privacy(ProfChatWin* chatwin); static void _show_muc_privacy(ProfMucWin* mucwin); static void _show_scrolled(ProfWin* current); +static void _show_attention(ProfWin* current, gboolean attention); void create_title_bar(void) @@ -210,6 +211,7 @@ _title_bar_draw(void) assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); _show_contact_presence(chatwin, pos, maxrightpos); _show_privacy(chatwin); + _show_attention(current, chatwin->has_attention); _show_scrolled(current); if (typing) { @@ -219,6 +221,7 @@ _title_bar_draw(void) ProfMucWin* mucwin = (ProfMucWin*)current; assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK); _show_muc_privacy(mucwin); + _show_attention(current, mucwin->has_attention); _show_scrolled(current); } @@ -228,6 +231,26 @@ _title_bar_draw(void) inp_put_back(); } +static void +_show_attention(ProfWin* current, gboolean attention) +{ + int bracket_attrs = theme_attrs(THEME_TITLE_BRACKET); + int text_attrs = theme_attrs(THEME_TITLE_TEXT); + + if (attention) { + wprintw(win, " "); + wattron(win, bracket_attrs); + wprintw(win, "["); + wattroff(win, bracket_attrs); + wattron(win, text_attrs); + wprintw(win, "ATTENTION"); + wattroff(win, text_attrs); + wattron(win, bracket_attrs); + wprintw(win, "]"); + wattroff(win, bracket_attrs); + } +} + static void _show_scrolled(ProfWin* current) { @@ -487,18 +510,6 @@ _show_privacy(ProfChatWin* chatwin) return; } - if (chatwin->has_attention) { - wprintw(win, " "); - wattron(win, bracket_attrs); - wprintw(win, "["); - wattroff(win, bracket_attrs); - wattron(win, encrypted_attrs); - wprintw(win, "ATTENTION"); - wattroff(win, encrypted_attrs); - wattron(win, bracket_attrs); - wprintw(win, "]"); - wattroff(win, bracket_attrs); - } if (chatwin->pgp_send || chatwin->pgp_recv) { GString* pgpmsg = g_string_new("PGP "); -- cgit 1.4.1-2-gfad0 From 2dcbaf98c0e892996eac5bc6ff0bc80727617029 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Mon, 31 May 2021 09:46:12 +0200 Subject: Change attention description --- src/command/cmd_defs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index a1b00df0..0ebcf04f 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -990,7 +990,7 @@ static struct cmd_t command_defs[] = { "Passing no argument will list all currently active windows and information about their usage.") CMD_ARGS( { "unread", "List windows with unread messages." }, - { "attention", "Marked windows" }, + { "attention", "List windows that have been marked with the attention flag (alt+f). You can toggle between marked windows with alt+m." }, { "prune", "Close all windows with no unread messages." }, { "swap ", "Swap windows, target may be an empty position." }) CMD_NOEXAMPLES -- cgit 1.4.1-2-gfad0 From 6df062b542d2376d464b2a9d8d6577fdf906cab4 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Mon, 31 May 2021 09:51:12 +0200 Subject: Change ui_win_has_attention() logic --- src/ui/core.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ui/core.c b/src/ui/core.c index 50fba846..f4ee4a86 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -999,12 +999,14 @@ ui_win_unread(int index) gboolean ui_win_has_attention(int index) { + gboolean ret = FALSE; + ProfWin* window = wins_get_by_num(index); if (window) { - return win_has_attention(window); - } else { - return 0; + ret = win_has_attention(window); } + + return ret; } -- cgit 1.4.1-2-gfad0