diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2005-11-22 13:43:54 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2005-11-22 13:43:54 +0000 |
commit | 4ea27db1d7534c84b97f09a04d175739b27a2117 (patch) | |
tree | d08a4ca41af325b5d1dab48c7d768f2ad6ca60f8 /src/gui | |
parent | 470e8a029651f69e8d596943ed03af99a3f49f11 (diff) | |
download | weechat-4ea27db1d7534c84b97f09a04d175739b27a2117.zip |
Added new keys for switching to other windows: alt-w followed by alt-{arrow}
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-display.c | 147 | ||||
-rw-r--r-- | src/gui/curses/gui-input.c | 136 | ||||
-rw-r--r-- | src/gui/gui-action.c | 4 | ||||
-rw-r--r-- | src/gui/gui-common.c | 34 | ||||
-rw-r--r-- | src/gui/gui.h | 20 |
5 files changed, 248 insertions, 93 deletions
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c index 487b2348d..4c643240f 100644 --- a/src/gui/curses/gui-display.c +++ b/src/gui/curses/gui-display.c @@ -3087,6 +3087,153 @@ gui_window_merge_all (t_gui_window *window) } /* + * gui_window_side_by_side: return a code about position of 2 windows: + * 0 = they're not side by side + * 1 = side by side (win2 is over the win1) + * 2 = side by side (win2 on the right) + * 3 = side by side (win2 below win1) + * 4 = side by side (win2 on the left) + */ + +int +gui_window_side_by_side (t_gui_window *win1, t_gui_window *win2) +{ + /* win2 over win1 ? */ + if (win2->win_y + win2->win_height == win1->win_y) + { + if (win2->win_x >= win1->win_x + win1->win_width) + return 0; + if (win2->win_x + win2->win_width <= win1->win_x) + return 0; + return 1; + } + + /* win2 on the right ? */ + if (win2->win_x == win1->win_x + win1->win_width + 1) + { + if (win2->win_y >= win1->win_y + win1->win_height) + return 0; + if (win2->win_y + win2->win_height <= win1->win_y) + return 0; + return 2; + } + + /* win2 below win1 ? */ + if (win2->win_y == win1->win_y + win1->win_height) + { + if (win2->win_x >= win1->win_x + win1->win_width) + return 0; + if (win2->win_x + win2->win_width <= win1->win_x) + return 0; + return 3; + } + + /* win2 on the left ? */ + if (win2->win_x + win2->win_width + 1 == win1->win_x) + { + if (win2->win_y >= win1->win_y + win1->win_height) + return 0; + if (win2->win_y + win2->win_height <= win1->win_y) + return 0; + return 4; + } + + return 0; +} + +/* + * gui_window_switch_up: search and switch to a window over current window + */ + +void +gui_window_switch_up (t_gui_window *window) +{ + t_gui_window *ptr_win; + + for (ptr_win = gui_windows; ptr_win; + ptr_win = ptr_win->next_window) + { + if ((ptr_win != window) && + (gui_window_side_by_side (window, ptr_win) == 1)) + { + gui_current_window = ptr_win; + gui_switch_to_buffer (gui_current_window, gui_current_window->buffer); + gui_redraw_buffer (gui_current_window->buffer); + return; + } + } +} + +/* + * gui_window_switch_down: search and switch to a window below current window + */ + +void +gui_window_switch_down (t_gui_window *window) +{ + t_gui_window *ptr_win; + + for (ptr_win = gui_windows; ptr_win; + ptr_win = ptr_win->next_window) + { + if ((ptr_win != window) && + (gui_window_side_by_side (window, ptr_win) == 3)) + { + gui_current_window = ptr_win; + gui_switch_to_buffer (gui_current_window, gui_current_window->buffer); + gui_redraw_buffer (gui_current_window->buffer); + return; + } + } +} + +/* + * gui_window_switch_left: search and switch to a window on the left of current window + */ + +void +gui_window_switch_left (t_gui_window *window) +{ + t_gui_window *ptr_win; + + for (ptr_win = gui_windows; ptr_win; + ptr_win = ptr_win->next_window) + { + if ((ptr_win != window) && + (gui_window_side_by_side (window, ptr_win) == 4)) + { + gui_current_window = ptr_win; + gui_switch_to_buffer (gui_current_window, gui_current_window->buffer); + gui_redraw_buffer (gui_current_window->buffer); + return; + } + } +} + +/* + * gui_window_switch_right: search and switch to a window on the right of current window + */ + +void +gui_window_switch_right (t_gui_window *window) +{ + t_gui_window *ptr_win; + + for (ptr_win = gui_windows; ptr_win; + ptr_win = ptr_win->next_window) + { + if ((ptr_win != window) && + (gui_window_side_by_side (window, ptr_win) == 2)) + { + gui_current_window = ptr_win; + gui_switch_to_buffer (gui_current_window, gui_current_window->buffer); + gui_redraw_buffer (gui_current_window->buffer); + return; + } + } +} + +/* * gui_refresh_screen: called when term size is modified */ diff --git a/src/gui/curses/gui-input.c b/src/gui/curses/gui-input.c index 520179a23..4621b05e9 100644 --- a/src/gui/curses/gui-input.c +++ b/src/gui/curses/gui-input.c @@ -59,74 +59,78 @@ gui_input_default_key_bindings () char key_str[32], command[32]; /* keys binded with internal functions */ - gui_key_bind ( /* RC */ "ctrl-M", "return"); - gui_key_bind ( /* RC */ "ctrl-J", "return"); - gui_key_bind ( /* tab */ "ctrl-I", "tab"); - gui_key_bind ( /* basckp */ "ctrl-H", "backspace"); - gui_key_bind ( /* basckp */ "ctrl-?", "backspace"); - gui_key_bind ( /* del */ "meta2-3~", "delete"); - gui_key_bind ( /* ^K */ "ctrl-K", "delete_end_line"); - gui_key_bind ( /* ^U */ "ctrl-U", "delete_beginning_line"); - gui_key_bind ( /* ^W */ "ctrl-W", "delete_previous_word"); - gui_key_bind ( /* ^Y */ "ctrl-Y", "clipboard_paste"); - gui_key_bind ( /* ^T */ "ctrl-T", "transpose_chars"); - gui_key_bind ( /* home */ "meta2-1~", "home"); - gui_key_bind ( /* home */ "meta2-H", "home"); - gui_key_bind ( /* home */ "meta2-7~", "home"); - gui_key_bind ( /* ^A */ "ctrl-A", "home"); - gui_key_bind ( /* end */ "meta2-4~", "end"); - gui_key_bind ( /* end */ "meta2-F", "end"); - gui_key_bind ( /* end */ "meta2-8~", "end"); - gui_key_bind ( /* ^E */ "ctrl-E", "end"); - gui_key_bind ( /* left */ "meta2-D", "left"); - gui_key_bind ( /* right */ "meta2-C", "right"); - gui_key_bind ( /* up */ "meta2-A", "up"); - gui_key_bind ( /* ^up */ "meta-Oa", "up_global"); - gui_key_bind ( /* down */ "meta2-B", "down"); - gui_key_bind ( /* ^down */ "meta-Ob", "down_global"); - gui_key_bind ( /* pgup */ "meta2-5~", "page_up"); - gui_key_bind ( /* pgdn */ "meta2-6~", "page_down"); - gui_key_bind ( /* F10 */ "meta2-21~", "infobar_clear"); - gui_key_bind ( /* F11 */ "meta2-23~", "nick_page_up"); - gui_key_bind ( /* F12 */ "meta2-24~", "nick_page_down"); - gui_key_bind ( /* m-F11 */ "meta-meta2-1~", "nick_beginning"); - gui_key_bind ( /* m-F12 */ "meta-meta2-4~", "nick_end"); - gui_key_bind ( /* ^L */ "ctrl-L", "refresh"); - gui_key_bind ( /* m-a */ "meta-a", "jump_smart"); - gui_key_bind ( /* m-b */ "meta-b", "previous_word"); - gui_key_bind ( /* ^left */ "meta-Od", "previous_word"); - gui_key_bind ( /* m-d */ "meta-d", "delete_next_word"); - gui_key_bind ( /* m-f */ "meta-f", "next_word"); - gui_key_bind ( /* ^right */ "meta-Oc", "next_word"); - gui_key_bind ( /* m-h */ "meta-h", "hotlist_clear"); - gui_key_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc"); - gui_key_bind ( /* m-j,m-l */ "meta-jmeta-l", "jump_last_buffer"); - gui_key_bind ( /* m-j,m-s */ "meta-jmeta-s", "jump_server"); - gui_key_bind ( /* m-j,m-x */ "meta-jmeta-x", "jump_next_server"); - gui_key_bind ( /* m-k */ "meta-k", "grab_key"); - gui_key_bind ( /* m-n */ "meta-n", "scroll_next_highlight"); - gui_key_bind ( /* m-p */ "meta-p", "scroll_previous_highlight"); - gui_key_bind ( /* m-r */ "meta-r", "delete_line"); - gui_key_bind ( /* m-s */ "meta-s", "switch_server"); - gui_key_bind ( /* m-u */ "meta-u", "scroll_unread"); + gui_key_bind ( /* RC */ "ctrl-M", "return"); + gui_key_bind ( /* RC */ "ctrl-J", "return"); + gui_key_bind ( /* tab */ "ctrl-I", "tab"); + gui_key_bind ( /* basckp */ "ctrl-H", "backspace"); + gui_key_bind ( /* basckp */ "ctrl-?", "backspace"); + gui_key_bind ( /* del */ "meta2-3~", "delete"); + gui_key_bind ( /* ^K */ "ctrl-K", "delete_end_line"); + gui_key_bind ( /* ^U */ "ctrl-U", "delete_beginning_line"); + gui_key_bind ( /* ^W */ "ctrl-W", "delete_previous_word"); + gui_key_bind ( /* ^Y */ "ctrl-Y", "clipboard_paste"); + gui_key_bind ( /* ^T */ "ctrl-T", "transpose_chars"); + gui_key_bind ( /* home */ "meta2-1~", "home"); + gui_key_bind ( /* home */ "meta2-H", "home"); + gui_key_bind ( /* home */ "meta2-7~", "home"); + gui_key_bind ( /* ^A */ "ctrl-A", "home"); + gui_key_bind ( /* end */ "meta2-4~", "end"); + gui_key_bind ( /* end */ "meta2-F", "end"); + gui_key_bind ( /* end */ "meta2-8~", "end"); + gui_key_bind ( /* ^E */ "ctrl-E", "end"); + gui_key_bind ( /* left */ "meta2-D", "left"); + gui_key_bind ( /* right */ "meta2-C", "right"); + gui_key_bind ( /* up */ "meta2-A", "up"); + gui_key_bind ( /* ^up */ "meta-Oa", "up_global"); + gui_key_bind ( /* down */ "meta2-B", "down"); + gui_key_bind ( /* ^down */ "meta-Ob", "down_global"); + gui_key_bind ( /* pgup */ "meta2-5~", "page_up"); + gui_key_bind ( /* pgdn */ "meta2-6~", "page_down"); + gui_key_bind ( /* F10 */ "meta2-21~", "infobar_clear"); + gui_key_bind ( /* F11 */ "meta2-23~", "nick_page_up"); + gui_key_bind ( /* F12 */ "meta2-24~", "nick_page_down"); + gui_key_bind ( /* m-F11 */ "meta-meta2-1~", "nick_beginning"); + gui_key_bind ( /* m-F12 */ "meta-meta2-4~", "nick_end"); + gui_key_bind ( /* ^L */ "ctrl-L", "refresh"); + gui_key_bind ( /* m-a */ "meta-a", "jump_smart"); + gui_key_bind ( /* m-b */ "meta-b", "previous_word"); + gui_key_bind ( /* ^left */ "meta-Od", "previous_word"); + gui_key_bind ( /* m-d */ "meta-d", "delete_next_word"); + gui_key_bind ( /* m-f */ "meta-f", "next_word"); + gui_key_bind ( /* ^right */ "meta-Oc", "next_word"); + gui_key_bind ( /* m-h */ "meta-h", "hotlist_clear"); + gui_key_bind ( /* m-j,m-d */ "meta-jmeta-d", "jump_dcc"); + gui_key_bind ( /* m-j,m-l */ "meta-jmeta-l", "jump_last_buffer"); + gui_key_bind ( /* m-j,m-s */ "meta-jmeta-s", "jump_server"); + gui_key_bind ( /* m-j,m-x */ "meta-jmeta-x", "jump_next_server"); + gui_key_bind ( /* m-k */ "meta-k", "grab_key"); + gui_key_bind ( /* m-n */ "meta-n", "scroll_next_highlight"); + gui_key_bind ( /* m-p */ "meta-p", "scroll_previous_highlight"); + gui_key_bind ( /* m-r */ "meta-r", "delete_line"); + gui_key_bind ( /* m-s */ "meta-s", "switch_server"); + gui_key_bind ( /* m-u */ "meta-u", "scroll_unread"); /* keys binded with commands */ - gui_key_bind ( /* m-left */ "meta-meta2-D", "/buffer -1"); - gui_key_bind ( /* F5 */ "meta2-15~", "/buffer -1"); - gui_key_bind ( /* m-right */ "meta-meta2-C", "/buffer +1"); - gui_key_bind ( /* F6 */ "meta2-17~", "/buffer +1"); - gui_key_bind ( /* F7 */ "meta2-18~", "/window -1"); - gui_key_bind ( /* F8 */ "meta2-19~", "/window +1"); - gui_key_bind ( /* m-0 */ "meta-0", "/buffer 10"); - gui_key_bind ( /* m-1 */ "meta-1", "/buffer 1"); - gui_key_bind ( /* m-2 */ "meta-2", "/buffer 2"); - gui_key_bind ( /* m-3 */ "meta-3", "/buffer 3"); - gui_key_bind ( /* m-4 */ "meta-4", "/buffer 4"); - gui_key_bind ( /* m-5 */ "meta-5", "/buffer 5"); - gui_key_bind ( /* m-6 */ "meta-6", "/buffer 6"); - gui_key_bind ( /* m-7 */ "meta-7", "/buffer 7"); - gui_key_bind ( /* m-8 */ "meta-8", "/buffer 8"); - gui_key_bind ( /* m-9 */ "meta-9", "/buffer 9"); + gui_key_bind ( /* m-left */ "meta-meta2-D", "/buffer -1"); + gui_key_bind ( /* F5 */ "meta2-15~", "/buffer -1"); + gui_key_bind ( /* m-right */ "meta-meta2-C", "/buffer +1"); + gui_key_bind ( /* F6 */ "meta2-17~", "/buffer +1"); + gui_key_bind ( /* F7 */ "meta2-18~", "/window -1"); + gui_key_bind ( /* F8 */ "meta2-19~", "/window +1"); + gui_key_bind ( /* m-w,m-up */ "meta-wmeta-meta2-A", "/window up"); + gui_key_bind ( /* m-w,m-down */ "meta-wmeta-meta2-B", "/window down"); + gui_key_bind ( /* m-w,m-left */ "meta-wmeta-meta2-D", "/window left"); + gui_key_bind ( /* m-w,m-right */ "meta-wmeta-meta2-C", "/window right"); + gui_key_bind ( /* m-0 */ "meta-0", "/buffer 10"); + gui_key_bind ( /* m-1 */ "meta-1", "/buffer 1"); + gui_key_bind ( /* m-2 */ "meta-2", "/buffer 2"); + gui_key_bind ( /* m-3 */ "meta-3", "/buffer 3"); + gui_key_bind ( /* m-4 */ "meta-4", "/buffer 4"); + gui_key_bind ( /* m-5 */ "meta-5", "/buffer 5"); + gui_key_bind ( /* m-6 */ "meta-6", "/buffer 6"); + gui_key_bind ( /* m-7 */ "meta-7", "/buffer 7"); + gui_key_bind ( /* m-8 */ "meta-8", "/buffer 8"); + gui_key_bind ( /* m-9 */ "meta-9", "/buffer 9"); /* bind meta-j + {01..99} to switch to buffers # > 10 */ for (i = 1; i < 100; i++) diff --git a/src/gui/gui-action.c b/src/gui/gui-action.c index 31779b9e6..dc3bb404e 100644 --- a/src/gui/gui-action.c +++ b/src/gui/gui-action.c @@ -962,7 +962,7 @@ gui_action_jump_dcc (t_gui_window *window) else { buffer_before_dcc = window->buffer; - gui_switch_to_dcc_buffer (window); + gui_buffer_switch_dcc (window); } } @@ -974,7 +974,7 @@ void gui_action_jump_last_buffer (t_gui_window *window) { if (last_gui_buffer) - gui_switch_to_buffer_by_number (window, last_gui_buffer->number); + gui_buffer_switch_by_number (window, last_gui_buffer->number); } /* diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c index b9e4e312c..db601c635 100644 --- a/src/gui/gui-common.c +++ b/src/gui/gui-common.c @@ -555,7 +555,7 @@ gui_buffer_free (t_gui_buffer *buffer, int switch_to_another) { if ((buffer == ptr_win->buffer) && ((buffer->next_buffer) || (buffer->prev_buffer))) - gui_switch_to_previous_buffer (ptr_win); + gui_buffer_switch_previous (ptr_win); } } @@ -1299,11 +1299,11 @@ gui_window_switch_server (t_gui_window *window) } /* - * gui_switch_to_previous_buffer: switch to previous buffer + * gui_buffer_switch_previous: switch to previous buffer */ void -gui_switch_to_previous_buffer (t_gui_window *window) +gui_buffer_switch_previous (t_gui_window *window) { if (!gui_ok) return; @@ -1321,11 +1321,11 @@ gui_switch_to_previous_buffer (t_gui_window *window) } /* - * gui_switch_to_next_buffer: switch to next buffer + * gui_buffer_switch_next: switch to next buffer */ void -gui_switch_to_next_buffer (t_gui_window *window) +gui_buffer_switch_next (t_gui_window *window) { if (!gui_ok) return; @@ -1343,11 +1343,11 @@ gui_switch_to_next_buffer (t_gui_window *window) } /* - * gui_switch_to_previous_window: switch to previous window + * gui_window_switch_previous: switch to previous window */ void -gui_switch_to_previous_window (t_gui_window *window) +gui_window_switch_previous (t_gui_window *window) { if (!gui_ok) return; @@ -1362,11 +1362,11 @@ gui_switch_to_previous_window (t_gui_window *window) } /* - * gui_switch_to_next_window: switch to next window + * gui_window_switch_next: switch to next window */ void -gui_switch_to_next_window (t_gui_window *window) +gui_window_switch_next (t_gui_window *window) { if (!gui_ok) return; @@ -1381,11 +1381,11 @@ gui_switch_to_next_window (t_gui_window *window) } /* - * gui_switch_to_window_by_buffer: switch to next window displaying a buffer + * gui_window_switch_by_buffer: switch to next window displaying a buffer */ void -gui_switch_to_window_by_buffer (t_gui_window *window, int buffer_number) +gui_window_switch_by_buffer (t_gui_window *window, int buffer_number) { t_gui_window *ptr_win; @@ -1407,11 +1407,11 @@ gui_switch_to_window_by_buffer (t_gui_window *window, int buffer_number) } /* - * gui_switch_to_dcc_buffer: switch to dcc buffer (create it if it does not exist) + * gui_buffer_switch_dcc: switch to dcc buffer (create it if it does not exist) */ void -gui_switch_to_dcc_buffer (t_gui_window *window) +gui_buffer_switch_dcc (t_gui_window *window) { t_gui_buffer *ptr_buffer; @@ -1431,11 +1431,11 @@ gui_switch_to_dcc_buffer (t_gui_window *window) } /* - * gui_switch_to_buffer_by_number: switch to another buffer with number + * gui_buffer_switch_by_number: switch to another buffer with number */ t_gui_buffer * -gui_switch_to_buffer_by_number (t_gui_window *window, int number) +gui_buffer_switch_by_number (t_gui_window *window, int number) { t_gui_buffer *ptr_buffer; @@ -1463,11 +1463,11 @@ gui_switch_to_buffer_by_number (t_gui_window *window, int number) } /* - * gui_switch_to_buffer_by_number: switch to another buffer with number + * gui_buffer_move_to_number: move a buffer to another number */ void -gui_move_buffer_to_number (t_gui_window *window, int number) +gui_buffer_move_to_number (t_gui_window *window, int number) { t_gui_buffer *ptr_buffer; int i; diff --git a/src/gui/gui.h b/src/gui/gui.h index ef7ebbe63..a17fb1b83 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -418,14 +418,14 @@ extern int gui_insert_string_input (t_gui_window *, char *, int); extern void gui_merge_servers (t_gui_window *); extern void gui_split_server (t_gui_window *); extern void gui_window_switch_server (t_gui_window *); -extern void gui_switch_to_previous_buffer (t_gui_window *); -extern void gui_switch_to_next_buffer (t_gui_window *); -extern void gui_switch_to_previous_window (t_gui_window *); -extern void gui_switch_to_next_window (t_gui_window *); -extern void gui_switch_to_window_by_buffer (t_gui_window *, int); -extern void gui_switch_to_dcc_buffer (t_gui_window *); -extern t_gui_buffer *gui_switch_to_buffer_by_number (t_gui_window *, int); -extern void gui_move_buffer_to_number (t_gui_window *, int); +extern void gui_buffer_switch_previous (t_gui_window *); +extern void gui_buffer_switch_next (t_gui_window *); +extern void gui_window_switch_previous (t_gui_window *); +extern void gui_window_switch_next (t_gui_window *); +extern void gui_window_switch_by_buffer (t_gui_window *, int); +extern void gui_buffer_switch_dcc (t_gui_window *); +extern t_gui_buffer *gui_buffer_switch_by_number (t_gui_window *, int); +extern void gui_buffer_move_to_number (t_gui_window *, int); extern void gui_window_print_log (t_gui_window *); extern void gui_buffer_print_log (t_gui_buffer *); @@ -519,6 +519,10 @@ extern void gui_window_split_vertic (t_gui_window *, int); extern void gui_window_resize (t_gui_window *, int); extern int gui_window_merge (t_gui_window *); extern void gui_window_merge_all (t_gui_window *); +extern void gui_window_switch_up (t_gui_window *); +extern void gui_window_switch_down (t_gui_window *); +extern void gui_window_switch_left (t_gui_window *); +extern void gui_window_switch_right (t_gui_window *); extern void gui_refresh_screen (); extern void gui_pre_init (int *, char **[]); extern void gui_init_color_pairs (); |