diff --git a/src/curses/ui_call_flow.c b/src/curses/ui_call_flow.c index 42ed6f8..d3e81f3 100644 --- a/src/curses/ui_call_flow.c +++ b/src/curses/ui_call_flow.c @@ -1282,7 +1282,7 @@ call_flow_handle_key(PANEL *panel, int key) break; case ACTION_CLEAR_CALLS: // Propagate the key to the previous panel - return -2; + return -1; default: // Parse next action @@ -1338,20 +1338,21 @@ call_flow_help(PANEL *panel) // A list of available keys in this window mvwprintw(help_win, 8, 2, "Available keys:"); mvwprintw(help_win, 9, 2, "Esc/Q Go back to Call list window"); - mvwprintw(help_win, 10, 2, "Enter Show current message Raw"); - mvwprintw(help_win, 11, 2, "F1/h Show this screen"); - mvwprintw(help_win, 12, 2, "F2/d Toggle SDP Address:Port info"); - mvwprintw(help_win, 13, 2, "F3/m Toggle RTP arrows display"); - mvwprintw(help_win, 14, 2, "F4/X Show call-flow with X-CID/X-Call-ID dialog"); - mvwprintw(help_win, 15, 2, "F5/s Toggle compressed view (One address <=> one column"); - mvwprintw(help_win, 16, 2, "F6/R Show original call messages in raw mode"); - mvwprintw(help_win, 17, 2, "F7/c Cycle between available color modes"); - mvwprintw(help_win, 18, 2, "F8/C Turn on/off message syntax highlighting"); - mvwprintw(help_win, 19, 2, "F9/l Turn on/off resolved addresses"); - mvwprintw(help_win, 20, 2, "9/0 Increase/Decrease raw preview size"); - mvwprintw(help_win, 21, 2, "t Toggle raw preview display"); - mvwprintw(help_win, 22, 2, "T Restore raw preview size"); - mvwprintw(help_win, 23, 2, "D Only show SDP messages"); + mvwprintw(help_win, 10, 2, "F5/Ctrl-L Leave screen and clear call list"); + mvwprintw(help_win, 11, 2, "Enter Show current message Raw"); + mvwprintw(help_win, 12, 2, "F1/h Show this screen"); + mvwprintw(help_win, 13, 2, "F2/d Toggle SDP Address:Port info"); + mvwprintw(help_win, 14, 2, "F3/m Toggle RTP arrows display"); + mvwprintw(help_win, 15, 2, "F4/X Show call-flow with X-CID/X-Call-ID dialog"); + mvwprintw(help_win, 16, 2, "F5/s Toggle compressed view (One address <=> one column"); + mvwprintw(help_win, 17, 2, "F6/R Show original call messages in raw mode"); + mvwprintw(help_win, 18, 2, "F7/c Cycle between available color modes"); + mvwprintw(help_win, 19, 2, "F8/C Turn on/off message syntax highlighting"); + mvwprintw(help_win, 20, 2, "F9/l Turn on/off resolved addresses"); + mvwprintw(help_win, 21, 2, "9/0 Increase/Decrease raw preview size"); + mvwprintw(help_win, 22, 2, "t Toggle raw preview display"); + mvwprintw(help_win, 23, 2, "T Restore raw preview size"); + mvwprintw(help_win, 24, 2, "D Only show SDP messages"); // Press any key to close diff --git a/src/curses/ui_call_flow.h b/src/curses/ui_call_flow.h index e412701..4586c5f 100644 --- a/src/curses/ui_call_flow.h +++ b/src/curses/ui_call_flow.h @@ -335,10 +335,8 @@ call_flow_draw_raw_rtcp(PANEL *panel, rtp_stream_t *rtcp); * @brief Handle Call flow extended key strokes * * This function will manage the custom keybindings of the panel. If this - * function returns -1, the ui manager will check if the pressed key - * is one of the common ones (like toggle colors and so). If this function - * returns -2, the ui manager will destroy the current panel and pass the key - * to the previous panel. + * function returns -1, the ui manager will destroy the current panel and + * pass the key to the previous panel. * * @param panel Ncurses panel pointer * @param key Pressed keycode diff --git a/src/curses/ui_call_raw.c b/src/curses/ui_call_raw.c index 3c28dec..f6b360f 100644 --- a/src/curses/ui_call_raw.c +++ b/src/curses/ui_call_raw.c @@ -269,7 +269,7 @@ call_raw_handle_key(PANEL *panel, int key) break; case ACTION_CLEAR_CALLS: // Propagate the key to the previous panel - return -2; + return -1; default: // Parse next action continue; diff --git a/src/curses/ui_call_raw.h b/src/curses/ui_call_raw.h index af5adfb..d6554e7 100644 --- a/src/curses/ui_call_raw.h +++ b/src/curses/ui_call_raw.h @@ -116,10 +116,8 @@ call_raw_print_msg(PANEL *panel, sip_msg_t *msg); * @brief Handle Call Raw key strokes * * This function will manage the custom keybindings of the panel. If this - * function returns -1, the ui manager will check if the pressed key - * is one of the common ones (like toggle colors and so). If this function - * returns -2, the ui manager will destroy the current panel and pass the key - * to the previous panel. + * function returns -1, the ui manager will destroy the current panel and + * pass the key to the previous panel. * * @param panel Ncurses panel pointer diff --git a/src/curses/ui_manager.c b/src/curses/ui_manager.c index e29264b..473dbf6 100644 --- a/src/curses/ui_manager.c +++ b/src/curses/ui_manager.c @@ -302,9 +302,6 @@ wait_for_input() WINDOW *win; PANEL *panel; - int c = ERR; - int rekey = 0; - // While there are still panels while ((panel = panel_below(NULL))) { @@ -325,31 +322,33 @@ wait_for_input() win = panel_window(panel); keypad(win, TRUE); - if (rekey == 0) { - // Get pressed key - c = wgetch(win); + // Get pressed key + int c = wgetch(win); - // Timeout, no key pressed - if (c == ERR) - continue; - } else { - rekey = 0; - } - - // Check if current panel has custom bindings for that key - int ret = ui_handle_key(ui, c); - if (ret == 0) { - // Key has been handled by panel + // Timeout, no key pressed + if (c == ERR) continue; - } else if (ret == -2) { - // Propagate the key to the previous panel - ui_destroy(ui); - rekey = 1; - continue; - } - // Key not handled by UI, try default handler - default_handle_key(ui, c); + // Handle received key + int hdl = -1; + while (hdl != KEY_HANDLED) { + // Check if current panel has custom bindings for that key + hdl = ui_handle_key(ui, c); + + if (hdl == KEY_HANDLED) { + // Panel handled this key + continue; + } else if (hdl == KEY_PROPAGATED) { + // Destroy current panel + ui_destroy(ui); + // Try to handle this key with the previus panel + ui = ui_find_by_panel(panel_below(NULL)); + } else { + // Key not handled by UI nor propagated. Use default handler + default_handle_key(ui, c); + break; + } + } } return -1; diff --git a/src/curses/ui_manager.h b/src/curses/ui_manager.h index a896546..ebc82d5 100644 --- a/src/curses/ui_manager.h +++ b/src/curses/ui_manager.h @@ -55,6 +55,10 @@ #define DIALOG_MAX_WIDTH 100 #define DIALOG_MIN_WIDTH 40 +//! Possible key handler results +#define KEY_HANDLED 0 +#define KEY_PROPAGATED -1 + //! Shorter declaration of ui structure typedef struct ui ui_t;