From 70da200dd9cea399a9082bf03e161198b254d837 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Mon, 9 Jul 2012 16:57:09 -0400 Subject: [PATCH] move the scrollback with the selection cursor --- termite.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/termite.c b/termite.c index 480da1d..61294f3 100644 --- a/termite.c +++ b/termite.c @@ -148,6 +148,10 @@ static void toggle_visual(VteTerminal *vte, select_info *select, select_mode mod } static void move(VteTerminal *vte, select_info *select, long col, long row) { + GtkAdjustment *adjust = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vte)); + double scroll_row = gtk_adjustment_get_value(adjust); + long n_rows = vte_terminal_get_row_count(vte); + const long end_col = vte_terminal_get_column_count(vte) - 1; /*const long end_row = vte_terminal_get_row_count(vte) - 1;*/ @@ -155,6 +159,12 @@ static void move(VteTerminal *vte, select_info *select, long col, long row) { select->cursor_row = MAX(select->cursor_row + row, 0); /*select->cursor_row = CLAMP(select->cursor_row + row, 0, end_row);*/ + if (select->cursor_row < scroll_row) { + gtk_adjustment_set_value(adjust, (double)select->cursor_row); + } else if (select->cursor_row - n_rows >= (long)scroll_row) { + gtk_adjustment_set_value(adjust, (double)(select->cursor_row - n_rows + 1)); + } + update_selection(vte, select); }