summaryrefslogtreecommitdiff
path: root/src/fe-text
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-01-28 09:16:22 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-01-28 09:16:22 +0000
commit96512a3d6acbaf5113a935573b0b478b569c6ba6 (patch)
tree790bd25da5bd10aa3bf1bc37ae157f638e196612 /src/fe-text
parent56abbcd2e350ba2d46773c21243fc9ab0844e45f (diff)
downloadirssi-96512a3d6acbaf5113a935573b0b478b569c6ba6.zip
/SB END: Don't do anything when already at the bottom (it was broken if
there was empty space at bottom) Horizontal resizing now keeps window position. Also some fixes to vertical resizing. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1156 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-text')
-rw-r--r--src/fe-text/gui-textwidget.c2
-rw-r--r--src/fe-text/gui-windows.c85
2 files changed, 68 insertions, 19 deletions
diff --git a/src/fe-text/gui-textwidget.c b/src/fe-text/gui-textwidget.c
index ef807a2f..ac8470d4 100644
--- a/src/fe-text/gui-textwidget.c
+++ b/src/fe-text/gui-textwidget.c
@@ -406,6 +406,8 @@ static void cmd_scrollback_end(const char *data)
GUI_WINDOW_REC *gui;
gui = WINDOW_GUI(active_win);
+ if (gui->bottom)
+ return;
gui->startline = gui->bottom_startline;
gui->subline = gui->bottom_subline;
diff --git a/src/fe-text/gui-windows.c b/src/fe-text/gui-windows.c
index 268d0d74..43a5b6a7 100644
--- a/src/fe-text/gui-windows.c
+++ b/src/fe-text/gui-windows.c
@@ -832,33 +832,76 @@ GList *gui_window_find_text(WINDOW_REC *window, gchar *text, GList *startline, i
return matches;
}
+static void gui_update_bottom_startline(GUI_WINDOW_REC *gui)
+{
+ GList *tmp;
+ int linecount, total;
+
+ if (gui->empty_linecount == 0) {
+ /* no empty lines in screen, don't try to keep the old
+ bottom startline */
+ gui->bottom_startline = NULL;
+ }
+
+ total = 0;
+ for (tmp = g_list_last(gui->lines); tmp != NULL; tmp = tmp->prev) {
+ LINE_REC *line = tmp->data;
+
+ linecount = gui_window_get_linecount(gui, line);
+ if (tmp == gui->bottom_startline) {
+ /* keep the old one, make sure that subline is ok */
+ if (gui->bottom_subline > linecount+1)
+ gui->bottom_subline = linecount+1;
+ gui->empty_linecount = gui->parent->lines-total-
+ gui->bottom_subline;
+ return;
+ }
+
+ total += linecount;
+ if (total >= gui->parent->lines) {
+ gui->bottom_startline = tmp;
+ gui->bottom_subline = total-gui->parent->lines;
+ gui->empty_linecount = 0;
+ return;
+ }
+ }
+
+ /* not enough lines so we must be at the beginning of the window */
+ gui->bottom_startline = gui->lines;
+ gui->bottom_subline = 0;
+ gui->empty_linecount = gui->parent->lines-total;
+}
+
static void gui_window_horiz_resize(WINDOW_REC *window)
{
GUI_WINDOW_REC *gui;
- int linecount;
+ int linecount, diff;
gui = WINDOW_GUI(window);
if (gui->lines == NULL) return;
g_hash_table_foreach_remove(gui->line_cache, (GHRFunc) line_cache_destroy, NULL);
- linecount = gui_window_get_linecount(gui, g_list_last(gui->lines)->data);
- gui->last_subline = linecount-1;
-
- /* fake a /CLEAR and scroll window up one page */
- gui->ypos = -1;
- gui->bottom = TRUE;
- gui->empty_linecount = gui->parent->lines-1;
-
- gui->bottom_startline = gui->startline = g_list_last(gui->lines);
- gui->bottom_subline = gui->subline = gui->last_subline+1;
- gui_window_scroll(window, -gui->empty_linecount-1);
+ linecount = gui_window_get_linecount(gui, gui->startline->data);
+ if (gui->subline > linecount+1)
+ gui->subline = linecount+1;
- gui->bottom_startline = gui->startline;
- gui->bottom_subline = gui->subline;
+ gui_window_update_ypos(gui);
+ gui_update_bottom_startline(gui);
- gui->bottom = TRUE;
- gui->empty_linecount = gui->parent->lines-1-gui->ypos;
+ if (gui->bottom) {
+ if (g_list_find(gui->startline,
+ gui->bottom_startline->data) == NULL ||
+ (gui->startline == gui->bottom_startline &&
+ gui->subline > gui->bottom_subline)) {
+ gui->startline = gui->bottom_startline;
+ gui->subline = gui->bottom_subline;
+ gui_window_update_ypos(gui);
+ } else {
+ diff = gui->ypos+1-gui->parent->lines;
+ if (diff > 0) gui_window_scroll(window, diff);
+ }
+ }
}
void gui_window_resize(WINDOW_REC *window, int ychange, int xchange)
@@ -885,12 +928,16 @@ void gui_window_resize(WINDOW_REC *window, int ychange, int xchange)
}
}
- if (gui->bottom && gui->startline == gui->lines && ychange > 0) {
- /* less than screenful of text, add empty space */
+ if (ychange > 0 && gui->bottom && gui->empty_linecount > 0)
gui->empty_linecount += ychange;
- } else {
+ else {
gui_window_update_bottom(WINDOW_GUI(window), -ychange);
gui_window_scroll(window, -ychange);
+
+ if (ychange > 0 && gui->bottom &&
+ gui->ypos+1 < gui->parent->lines) {
+ gui->empty_linecount += gui->parent->lines-gui->ypos-1;
+ }
}
}