mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Bind key to switch to next active window
alt-a brings one to the next window with unread messages. Regards https://github.com/profanity-im/profanity/issues/1114
This commit is contained in:
parent
d6c638c70f
commit
e8420e7235
@ -121,6 +121,7 @@ static int _inp_rl_win_19_handler(int count, int key);
|
||||
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_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);
|
||||
@ -403,6 +404,7 @@ _inp_rl_addfuncs(void)
|
||||
rl_add_funmap_entry("prof_win_20", _inp_rl_win_20_handler);
|
||||
rl_add_funmap_entry("prof_win_prev", _inp_rl_win_prev_handler);
|
||||
rl_add_funmap_entry("prof_win_next", _inp_rl_win_next_handler);
|
||||
rl_add_funmap_entry("prof_win_next_unread", _inp_rl_win_next_unread_handler);
|
||||
rl_add_funmap_entry("prof_win_pageup", _inp_rl_win_pageup_handler);
|
||||
rl_add_funmap_entry("prof_win_pagedown", _inp_rl_win_pagedown_handler);
|
||||
rl_add_funmap_entry("prof_subwin_pageup", _inp_rl_subwin_pageup_handler);
|
||||
@ -456,6 +458,8 @@ _inp_rl_startup_hook(void)
|
||||
rl_bind_keyseq("\\e[1;3C", _inp_rl_win_next_handler);
|
||||
rl_bind_keyseq("\\e\\e[C", _inp_rl_win_next_handler);
|
||||
|
||||
rl_bind_keyseq("\\ea", _inp_rl_win_next_unread_handler);
|
||||
|
||||
rl_bind_keyseq("\\e\\e[5~", _inp_rl_subwin_pageup_handler);
|
||||
rl_bind_keyseq("\\e[5;3~", _inp_rl_subwin_pageup_handler);
|
||||
rl_bind_keyseq("\\e\\eOy", _inp_rl_subwin_pageup_handler);
|
||||
@ -769,6 +773,16 @@ _inp_rl_win_next_handler(int count, int key)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_inp_rl_win_next_unread_handler(int count, int key)
|
||||
{
|
||||
ProfWin *window = wins_get_next_unread();
|
||||
if (window) {
|
||||
ui_focus_win(window);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_inp_rl_win_pageup_handler(int count, int key)
|
||||
{
|
||||
|
@ -1130,3 +1130,29 @@ wins_destroy(void)
|
||||
autocomplete_free(wins_ac);
|
||||
autocomplete_free(wins_close_ac);
|
||||
}
|
||||
|
||||
ProfWin*
|
||||
wins_get_next_unread(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) {
|
||||
if (current == GPOINTER_TO_INT(curr->data)) {
|
||||
break;
|
||||
}
|
||||
|
||||
ProfWin *window = curr->data;
|
||||
if (win_unread(window) > 0) {
|
||||
g_list_free(values);
|
||||
return window;
|
||||
}
|
||||
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
g_list_free(values);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -72,6 +72,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);
|
||||
int wins_get_num(ProfWin *window);
|
||||
int wins_get_current_num(void);
|
||||
void wins_close_current(void);
|
||||
|
Loading…
Reference in New Issue
Block a user