diff options
author | Timo Sirainen <cras@irssi.org> | 2000-06-30 19:45:28 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-06-30 19:45:28 +0000 |
commit | 4faf4d130322aab96c97c24480f9456ade645f78 (patch) | |
tree | cf98045fbbb918f1a47faf16c5c2e353dc3092e4 /src/fe-text | |
parent | d0dcffab7b7241e31c856ba10549cd1bd008cb10 (diff) | |
download | irssi-4faf4d130322aab96c97c24480f9456ade645f78.zip |
/SCROLLBACK HOME/END/GOTO commands weren't working right.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@396 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-text')
-rw-r--r-- | src/fe-text/gui-textwidget.c | 93 | ||||
-rw-r--r-- | src/fe-text/gui-windows.c | 14 | ||||
-rw-r--r-- | src/fe-text/gui-windows.h | 4 |
3 files changed, 61 insertions, 50 deletions
diff --git a/src/fe-text/gui-textwidget.c b/src/fe-text/gui-textwidget.c index 7c7657f5..288e9851 100644 --- a/src/fe-text/gui-textwidget.c +++ b/src/fe-text/gui-textwidget.c @@ -245,33 +245,31 @@ static void cmd_scrollback_clear(gchar *data) static void scrollback_goto_pos(WINDOW_REC *window, GList *pos) { - GUI_WINDOW_REC *gui; - - g_return_if_fail(window != NULL); - g_return_if_fail(pos != NULL); - - gui = WINDOW_GUI(window); - - if (g_list_find(gui->bottom_startline, pos->data) == NULL) - { - gui->startline = pos; - gui->subline = 0; - gui->bottom = FALSE; - } - else - { - /* reached the last line */ - if (gui->bottom) return; - - gui->bottom = TRUE; - gui->startline = gui->bottom_startline; - gui->subline = gui->bottom_subline; - gui->ypos = gui->parent->last_line-gui->parent->first_line-1; - } + GUI_WINDOW_REC *gui; + + g_return_if_fail(window != NULL); + g_return_if_fail(pos != NULL); + + gui = WINDOW_GUI(window); + + if (g_list_find(gui->bottom_startline, pos->data) == NULL) { + gui->startline = pos; + gui->subline = 0; + gui_window_update_ypos(gui); + gui->bottom = is_window_bottom(gui); + } else { + /* reached the last line */ + if (gui->bottom) return; + + gui->startline = gui->bottom_startline; + gui->subline = gui->bottom_subline; + gui->ypos = gui->parent->last_line-gui->parent->first_line; + gui->bottom = TRUE; + } - if (is_window_visible(window)) - gui_window_redraw(window); - signal_emit("gui page scrolled", 1, window); + if (is_window_visible(window)) + gui_window_redraw(window); + signal_emit("gui page scrolled", 1, window); } static void cmd_scrollback_goto(gchar *data) @@ -366,38 +364,39 @@ static void cmd_scrollback_goto(gchar *data) cmd_params_free(free_arg); } -static void cmd_scrollback_home(gchar *data) +static void cmd_scrollback_home(const char *data) { - GUI_WINDOW_REC *gui; + GUI_WINDOW_REC *gui; - gui = WINDOW_GUI(active_win); + gui = WINDOW_GUI(active_win); - if (gui->bottom_startline == gui->startline) - return; + if (gui->startline == gui->lines) + return; - gui->bottom = FALSE; - gui->startline = gui->lines; - gui->subline = 0; + gui->startline = gui->lines; + gui->subline = 0; + gui_window_update_ypos(gui); + gui->bottom = is_window_bottom(gui); - if (is_window_visible(active_win)) - gui_window_redraw(active_win); - signal_emit("gui page scrolled", 1, active_win); + if (is_window_visible(active_win)) + gui_window_redraw(active_win); + signal_emit("gui page scrolled", 1, active_win); } -static void cmd_scrollback_end(gchar *data) +static void cmd_scrollback_end(const char *data) { - GUI_WINDOW_REC *gui; + GUI_WINDOW_REC *gui; - gui = WINDOW_GUI(active_win); + gui = WINDOW_GUI(active_win); - gui->bottom = TRUE; - gui->startline = gui->bottom_startline; - gui->subline = gui->bottom_subline; - gui->ypos = gui->parent->last_line-gui->parent->first_line-1; + gui->startline = gui->bottom_startline; + gui->subline = gui->bottom_subline; + gui->ypos = gui->parent->last_line-gui->parent->first_line; + gui->bottom = TRUE; - if (is_window_visible(active_win)) - gui_window_redraw(active_win); - signal_emit("gui page scrolled", 1, active_win); + if (is_window_visible(active_win)) + gui_window_redraw(active_win); + signal_emit("gui page scrolled", 1, active_win); } static void sig_away_changed(IRC_SERVER_REC *server) diff --git a/src/fe-text/gui-windows.c b/src/fe-text/gui-windows.c index 96c62361..53f94416 100644 --- a/src/fe-text/gui-windows.c +++ b/src/fe-text/gui-windows.c @@ -184,9 +184,6 @@ static int gui_window_update_bottom(GUI_WINDOW_REC *gui, int lines) return last_linecount; } -#define is_window_bottom(gui) \ - ((gui)->ypos >= -1 && (gui)->ypos <= (gui)->parent->last_line-(gui)->parent->first_line) - void gui_window_newline(GUI_WINDOW_REC *gui, int visible) { /* FIXME: I'm pretty sure this could be done cleaner :) */ @@ -601,6 +598,17 @@ void gui_window_scroll(WINDOW_REC *window, int lines) signal_emit("gui page scrolled", 1, window); } +void gui_window_update_ypos(GUI_WINDOW_REC *gui) +{ + GList *tmp; + + g_return_if_fail(gui != NULL); + + gui->ypos = -gui->subline-1; + for (tmp = gui->startline; tmp != NULL; tmp = tmp->next) + gui->ypos += gui_window_get_linecount(gui, tmp->data); +} + void window_update_prompt(WINDOW_REC *window) { WI_ITEM_REC *item; diff --git a/src/fe-text/gui-windows.h b/src/fe-text/gui-windows.h index b3088731..4eb532e7 100644 --- a/src/fe-text/gui-windows.h +++ b/src/fe-text/gui-windows.h @@ -99,8 +99,12 @@ void gui_window_redraw(WINDOW_REC *window); void gui_window_resize(WINDOW_REC *window, int ychange, int xchange); void gui_window_reparent(WINDOW_REC *window, MAIN_WINDOW_REC *parent); +#define is_window_bottom(gui) \ + ((gui)->ypos >= -1 && (gui)->ypos <= (gui)->parent->last_line-(gui)->parent->first_line) + void window_update_prompt(WINDOW_REC *window); void gui_window_newline(GUI_WINDOW_REC *gui, int visible); void gui_window_scroll(WINDOW_REC *window, int lines); +void gui_window_update_ypos(GUI_WINDOW_REC *gui); #endif |