diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2005-11-20 18:13:24 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2005-11-20 18:13:24 +0000 |
commit | 9f0aedd3194f5f8f520837f4055125067dafc42d (patch) | |
tree | eb14538ed4f9c072d26574771d0434316dcdccc6 /src | |
parent | c71f869106473407e5effdb42fb7ce9b1e8268f1 (diff) | |
download | weechat-9f0aedd3194f5f8f520837f4055125067dafc42d.zip |
Added new keys: alt-U (scroll to read marker), alt-P / alt-N (scroll to
previous/next highlight)
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/curses/gui-display.c | 19 | ||||
-rw-r--r-- | src/gui/curses/gui-input.c | 3 | ||||
-rw-r--r-- | src/gui/gui-action.c | 86 | ||||
-rw-r--r-- | src/gui/gui-common.c | 1 | ||||
-rw-r--r-- | src/gui/gui-keyboard.c | 80 | ||||
-rw-r--r-- | src/gui/gui.h | 5 |
6 files changed, 149 insertions, 45 deletions
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c index b5514afdd..487b2348d 100644 --- a/src/gui/curses/gui-display.c +++ b/src/gui/curses/gui-display.c @@ -1666,15 +1666,20 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase) ptr_line = ptr_line->next_line; } + ptr_win->scroll = (ptr_win->win_chat_cursor_y > ptr_win->win_chat_height - 1); + /* check if last line of buffer is entirely displayed and scrolling */ - /* if so, disable scroll (to remove status bar indicator) */ - if (!ptr_line && ptr_win->start_line) + /* if so, disable scroll indicator */ + if (!ptr_line && ptr_win->scroll) { if (count == gui_display_line (ptr_win, ptr_win->buffer->last_line, 0, 1)) - { - ptr_win->start_line = NULL; - ptr_win->start_line_pos = 0; - } + ptr_win->scroll = 0; + } + + if (!ptr_win->scroll && (ptr_win->start_line == ptr_win->buffer->lines)) + { + ptr_win->start_line = NULL; + ptr_win->start_line_pos = 0; } /* cursor is below end line of chat window? */ @@ -2200,7 +2205,7 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) if (x < 0) x = 0; gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS_MORE); - if (ptr_win->start_line) + if (ptr_win->scroll) mvwprintw (ptr_win->win_status, 0, x, "%s", more); else { diff --git a/src/gui/curses/gui-input.c b/src/gui/curses/gui-input.c index 66c675d61..520179a23 100644 --- a/src/gui/curses/gui-input.c +++ b/src/gui/curses/gui-input.c @@ -104,8 +104,11 @@ gui_input_default_key_bindings () 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"); diff --git a/src/gui/gui-action.c b/src/gui/gui-action.c index 14ec2b90c..772a2f359 100644 --- a/src/gui/gui-action.c +++ b/src/gui/gui-action.c @@ -1050,6 +1050,92 @@ gui_action_switch_server (t_gui_window *window) } /* + * gui_action_scroll_previous_highlight: scroll to previous highlight + */ + +void +gui_action_scroll_previous_highlight (t_gui_window *window) +{ + t_gui_line *ptr_line; + + if (!window->buffer->dcc) + { + if (window->buffer->lines) + { + ptr_line = (window->start_line) ? + window->start_line->prev_line : window->buffer->last_line->prev_line; + while (ptr_line) + { + if (ptr_line->line_with_highlight) + { + window->start_line = ptr_line; + window->start_line_pos = 0; + window->first_line_displayed = + (window->start_line == window->buffer->lines); + gui_draw_buffer_chat (window->buffer, 1); + gui_draw_buffer_status (window->buffer, 0); + return; + } + ptr_line = ptr_line->prev_line; + } + } + } +} + +/* + * gui_action_scroll_next_highlight: scroll to next highlight + */ + +void +gui_action_scroll_next_highlight (t_gui_window *window) +{ + t_gui_line *ptr_line; + + if (!window->buffer->dcc) + { + if (window->buffer->lines) + { + ptr_line = (window->start_line) ? + window->start_line->next_line : window->buffer->lines->next_line; + while (ptr_line) + { + if (ptr_line->line_with_highlight) + { + window->start_line = ptr_line; + window->start_line_pos = 0; + window->first_line_displayed = + (window->start_line == window->buffer->lines); + gui_draw_buffer_chat (window->buffer, 1); + gui_draw_buffer_status (window->buffer, 0); + return; + } + ptr_line = ptr_line->next_line; + } + } + } +} + +/* + * gui_action_scroll_unread: scroll to first unread line of buffer + */ + +void +gui_action_scroll_unread (t_gui_window *window) +{ + if (!window->buffer->dcc && + window->buffer->last_read_line && + window->buffer->last_read_line != window->buffer->last_line) + { + window->start_line = window->buffer->last_read_line->next_line; + window->start_line_pos = 0; + window->first_line_displayed = + (window->start_line == window->buffer->lines); + gui_draw_buffer_chat (window->buffer, 1); + gui_draw_buffer_status (window->buffer, 0); + } +} + +/* * gui_action_hotlist_clear: clear hotlist */ diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c index 6932173c2..b9e4e312c 100644 --- a/src/gui/gui-common.c +++ b/src/gui/gui-common.c @@ -244,6 +244,7 @@ gui_window_new (t_gui_window *parent, int x, int y, int width, int height, new_window->first_line_displayed = 0; new_window->start_line = NULL; new_window->start_line_pos = 0; + new_window->scroll = 0; new_window->ptr_tree = ptr_leaf; ptr_leaf->window = new_window; diff --git a/src/gui/gui-keyboard.c b/src/gui/gui-keyboard.c index 2d3431899..a3c5c3329 100644 --- a/src/gui/gui-keyboard.c +++ b/src/gui/gui-keyboard.c @@ -41,79 +41,85 @@ int gui_key_grab = 0; int gui_key_grab_count = 0; t_gui_key_function gui_key_functions[] = -{ { "return", gui_action_return, +{ { "return", gui_action_return, N_("terminate line") }, - { "tab", gui_action_tab, + { "tab", gui_action_tab, N_("complete word") }, - { "backspace", gui_action_backspace, + { "backspace", gui_action_backspace, N_("delete previous char") }, - { "delete", gui_action_delete, + { "delete", gui_action_delete, N_("delete next char") }, - { "delete_end_line", gui_action_delete_end_of_line, + { "delete_end_line", gui_action_delete_end_of_line, N_("delete until end of line") }, - { "delete_beginning_line", gui_action_delete_begin_of_line, + { "delete_beginning_line", gui_action_delete_begin_of_line, N_("delete until beginning of line") }, - { "delete_line", gui_action_delete_line, + { "delete_line", gui_action_delete_line, N_("delete entire line") }, - { "delete_previous_word", gui_action_delete_previous_word, + { "delete_previous_word", gui_action_delete_previous_word, N_("delete previous word") }, - { "delete_next_word", gui_action_delete_next_word, + { "delete_next_word", gui_action_delete_next_word, N_("delete next word") }, - { "clipboard_paste", gui_action_clipboard_paste, + { "clipboard_paste", gui_action_clipboard_paste, N_("paste current clipboard content") }, - { "transpose_chars", gui_action_transpose_chars, + { "transpose_chars", gui_action_transpose_chars, N_("transpose chars") }, - { "home", gui_action_home, + { "home", gui_action_home, N_("go to beginning of line") }, - { "end", gui_action_end, + { "end", gui_action_end, N_("go to end of line") }, - { "left", gui_action_left, + { "left", gui_action_left, N_("move one char left") }, - { "previous_word", gui_action_previous_word, + { "previous_word", gui_action_previous_word, N_("move to previous word") }, - { "right", gui_action_right, + { "right", gui_action_right, N_("move one char right") }, - { "next_word", gui_action_next_word, + { "next_word", gui_action_next_word, N_("move to next word") }, - { "up", gui_action_up, + { "up", gui_action_up, N_("call previous command in history") }, - { "up_global", gui_action_up_global, + { "up_global", gui_action_up_global, N_("call previous command in global history") }, - { "down", gui_action_down, + { "down", gui_action_down, N_("call next command in history") }, - { "down_global", gui_action_down_global, + { "down_global", gui_action_down_global, N_("call next command in global history") }, - { "page_up", gui_action_page_up, + { "page_up", gui_action_page_up, N_("scroll one page up") }, - { "page_down", gui_action_page_down, + { "page_down", gui_action_page_down, N_("scroll one page down") }, - { "nick_beginning", gui_action_nick_beginning, + { "nick_beginning", gui_action_nick_beginning, N_("display beginning of nicklist") }, - { "nick_end", gui_action_nick_end, + { "nick_end", gui_action_nick_end, N_("display end of nicklist") }, - { "nick_page_up", gui_action_nick_page_up, + { "nick_page_up", gui_action_nick_page_up, N_("scroll nicklist one page up") }, - { "nick_page_down", gui_action_nick_page_down, + { "nick_page_down", gui_action_nick_page_down, N_("scroll nicklist one page down") }, - { "jump_smart", gui_action_jump_smart, + { "jump_smart", gui_action_jump_smart, N_("jump to buffer with activity") }, - { "jump_dcc", gui_action_jump_dcc, + { "jump_dcc", gui_action_jump_dcc, N_("jump to DCC buffer") }, - { "jump_last_buffer", gui_action_jump_last_buffer, + { "jump_last_buffer", gui_action_jump_last_buffer, N_("jump to last buffer") }, - { "jump_server", gui_action_jump_server, + { "jump_server", gui_action_jump_server, N_("jump to server buffer") }, - { "jump_next_server", gui_action_jump_next_server, + { "jump_next_server", gui_action_jump_next_server, N_("jump to next server") }, - { "switch_server", gui_action_switch_server, + { "switch_server", gui_action_switch_server, N_("switch active server on servers buffer") }, - { "hotlist_clear", gui_action_hotlist_clear, + { "scroll_previous_highlight", gui_action_scroll_previous_highlight, + N_("scroll to previous highlight in buffer") }, + { "scroll_next_highlight", gui_action_scroll_next_highlight, + N_("scroll to next highlight in buffer") }, + { "scroll_unread", gui_action_scroll_unread, + N_("scroll to first unread line in buffer") }, + { "hotlist_clear", gui_action_hotlist_clear, N_("clear hotlist") }, - { "infobar_clear", gui_action_infobar_clear, + { "infobar_clear", gui_action_infobar_clear, N_("clear infobar") }, - { "refresh", gui_action_refresh_screen, + { "refresh", gui_action_refresh_screen, N_("refresh screen") }, - { "grab_key", gui_action_grab_key, + { "grab_key", gui_action_grab_key, N_("grab a key") }, { NULL, NULL, NULL } }; diff --git a/src/gui/gui.h b/src/gui/gui.h index 4ffb20c80..ef7ebbe63 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -330,7 +330,7 @@ struct t_gui_window int first_line_displayed; /* = 1 if first line is displayed */ t_gui_line *start_line; /* pointer to line if scrolling */ int start_line_pos; /* position in first line displayed */ - + int scroll; /* = 1 if "MORE" should be displayed */ t_gui_window_tree *ptr_tree; /* pointer to leaf in windows tree */ t_gui_window *prev_window; /* link to previous window */ @@ -465,6 +465,9 @@ extern void gui_action_jump_last_buffer (t_gui_window *); extern void gui_action_jump_server (t_gui_window *); extern void gui_action_jump_next_server (t_gui_window *); extern void gui_action_switch_server (t_gui_window *); +extern void gui_action_scroll_previous_highlight (t_gui_window *); +extern void gui_action_scroll_next_highlight (t_gui_window *); +extern void gui_action_scroll_unread (t_gui_window *); extern void gui_action_hotlist_clear (t_gui_window *); extern void gui_action_infobar_clear (t_gui_window *); extern void gui_action_refresh_screen (); |