X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/720f700ea5af91c2faab20e74515f157e6e8cbdf..adb6167a29d4056ecf93843d46f87e4160298b0e:/terminal.c?ds=inline diff --git a/terminal.c b/terminal.c index aaf8705a..ba504d43 100644 --- a/terminal.c +++ b/terminal.c @@ -3290,8 +3290,8 @@ static void term_out(Terminal *term) } term->termstate = SEEN_CSI; } else if (c == ';') { - if (++term->esc_nargs <= ARGS_MAX) - term->esc_args[term->esc_nargs - 1] = ARG_DEFAULT; + if (term->esc_nargs < ARGS_MAX) + term->esc_args[term->esc_nargs++] = ARG_DEFAULT; term->termstate = SEEN_CSI; } else if (c < '@') { if (term->esc_query) @@ -5137,6 +5137,31 @@ void term_scroll(Terminal *term, int rel, int where) } /* + * Scroll the scrollback to centre it on the beginning or end of the + * current selection, if any. + */ +void term_scroll_to_selection(Terminal *term, int which_end) +{ + pos target; + int y; + int sbtop = -sblines(term); + + if (term->selstate != SELECTED) + return; + if (which_end) + target = term->selend; + else + target = term->selstart; + + y = target.y - term->rows/2; + if (y < sbtop) + y = sbtop; + else if (y > 0) + y = 0; + term_scroll(term, -1, y); +} + +/* * Helper routine for clipme(): growing buffer. */ typedef struct {