X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/5063f6911e42650ead6921e55dda6a7a42a92555..b8af224e6169e1eec348e8af10b01ac2ebe54347:/terminal.c diff --git a/terminal.c b/terminal.c index cc4b0d8f..a29645a0 100644 --- a/terminal.c +++ b/terminal.c @@ -1065,32 +1065,32 @@ static termline *lineptr(Terminal *term, int y, int lineno, int screen) static void term_schedule_tblink(Terminal *term); static void term_schedule_cblink(Terminal *term); -static void term_timer(void *ctx, long now) +static void term_timer(void *ctx, unsigned long now) { Terminal *term = (Terminal *)ctx; int update = FALSE; - if (term->tblink_pending && now - term->next_tblink >= 0) { + if (term->tblink_pending && now == term->next_tblink) { term->tblinker = !term->tblinker; term->tblink_pending = FALSE; term_schedule_tblink(term); update = TRUE; } - if (term->cblink_pending && now - term->next_cblink >= 0) { + if (term->cblink_pending && now == term->next_cblink) { term->cblinker = !term->cblinker; term->cblink_pending = FALSE; term_schedule_cblink(term); update = TRUE; } - if (term->in_vbell && now - term->vbell_end >= 0) { + if (term->in_vbell && now == term->vbell_end) { term->in_vbell = FALSE; update = TRUE; } if (update || - (term->window_update_pending && now - term->next_update >= 0)) + (term->window_update_pending && now == term->next_update)) term_update(term); } @@ -1978,7 +1978,7 @@ static void check_selection(Terminal *term, pos from, pos to) static void scroll(Terminal *term, int topline, int botline, int lines, int sb) { termline *line; - int i, seltop; + int i, seltop, scrollwinsize; #ifdef OPTIMISE_SCROLL int olddisptop, shift; #endif /* OPTIMISE_SCROLL */ @@ -1990,8 +1990,14 @@ static void scroll(Terminal *term, int topline, int botline, int lines, int sb) olddisptop = term->disptop; shift = lines; #endif /* OPTIMISE_SCROLL */ + + scrollwinsize = botline - topline + 1; + if (lines < 0) { - while (lines < 0) { + lines = -lines; + if (lines > scrollwinsize) + lines = scrollwinsize; + while (lines-- > 0) { line = delpos234(term->screen, botline); resizeline(term, line, term->cols); for (i = 0; i < term->cols; i++) @@ -2013,11 +2019,11 @@ static void scroll(Terminal *term, int topline, int botline, int lines, int sb) term->selend.x = 0; } } - - lines++; } } else { - while (lines > 0) { + if (lines > scrollwinsize) + lines = scrollwinsize; + while (lines-- > 0) { line = delpos234(term->screen, topline); #ifdef TERM_CC_DIAGS cc_check(line); @@ -2103,8 +2109,6 @@ static void scroll(Terminal *term, int topline, int botline, int lines, int sb) } } } - - lines--; } } #ifdef OPTIMISE_SCROLL @@ -5622,7 +5626,8 @@ static pos sel_spread_half(Terminal *term, pos p, int dir) else break; } else { - if (ldata->lattr & LATTR_WRAPPED) { + if (p.y+1 < term->rows && + (ldata->lattr & LATTR_WRAPPED)) { termline *ldata2; ldata2 = lineptr(p.y+1); if (wordtype(term, UCSGET(ldata2->chars, 0))