X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/f6b14226f4e832f6cb2a523ebd843f72bb9862cc..b2b8c9cad5e26edd82d4987dfcfa16463c603229:/terminal.c diff --git a/terminal.c b/terminal.c index 8b48a3c5..3fcff47f 100644 --- a/terminal.c +++ b/terminal.c @@ -62,6 +62,8 @@ const wchar_t sel_nl[] = SEL_NL; /* * Internal prototypes. */ +static unsigned long *resizeline(unsigned long *, int); +static unsigned long *lineptr(Terminal *, int, int); static void do_paint(Terminal *, Context, int); static void erase_lots(Terminal *, int, int, int); static void swap_screen(Terminal *, int, int, int); @@ -75,7 +77,7 @@ static void scroll_display(Terminal *, int, int, int); /* * Resize a line to make it `cols' columns wide. */ -unsigned long *resizeline(unsigned long *line, int cols) +static unsigned long *resizeline(unsigned long *line, int cols) { int i, oldlen; unsigned long lineattrs; @@ -102,7 +104,7 @@ unsigned long *resizeline(unsigned long *line, int cols) * whether the y coordinate is non-negative or negative * (respectively). */ -unsigned long *lineptr(Terminal *term, int y, int lineno) +static unsigned long *lineptr(Terminal *term, int y, int lineno) { unsigned long *line, *newline; tree234 *whichtree; @@ -336,6 +338,7 @@ Terminal *term_init(Config *mycfg, void *frontend) term->nbeeps = 0; term->lastbeep = FALSE; term->beep_overloaded = FALSE; + term->attr_mask = 0xffffffff; term->resize_fn = NULL; term->resize_ctx = NULL; @@ -592,11 +595,13 @@ static void check_selection(Terminal *term, pos from, pos to) static void scroll(Terminal *term, int topline, int botline, int lines, int sb) { unsigned long *line, *line2; - int i, seltop; + int i, seltop, olddisptop, shift; if (topline != 0 || term->alt_which != 0) sb = FALSE; + olddisptop = term->disptop; + shift = lines; if (lines < 0) { while (lines < 0) { line = delpos234(term->screen, botline); @@ -705,6 +710,11 @@ static void scroll(Terminal *term, int topline, int botline, int lines, int sb) lines--; } } +#ifdef OPTIMISE_SCROLL + shift += term->disptop - olddisptop; + if (shift < term->rows && shift > -term->rows && shift != 0) + scroll_display(term, topline, botline, shift); +#endif /* OPTIMISE_SCROLL */ } #ifdef OPTIMISE_SCROLL @@ -722,10 +732,15 @@ static void scroll_display(Terminal *term, int topline, int botline, int lines) size = end - start - distance; if (lines > 0) { memmove(start, start + distance, size * TSIZE); + if (term->dispcurs >= start + distance && + term->dispcurs <= start + distance + size) + term->dispcurs -= distance; for (i = 0; i < distance; i++) (start + size)[i] |= ATTR_INVALID; } else { memmove(start + distance, start, size * TSIZE); + if (term->dispcurs >= start && term->dispcurs <= start + size) + term->dispcurs += distance; for (i = 0; i < distance; i++) start[i] |= ATTR_INVALID; } @@ -1527,7 +1542,6 @@ void term_out(Terminal *term) term->logctx) logtraffic(term->logctx, (unsigned char) c, LGTYP_ASCII); { - extern int wcwidth(wchar_t ucs); int width = 0; if (DIRECT_CHAR(c)) width = 1; @@ -3027,7 +3041,8 @@ static void do_paint(Terminal *term, Context ctx, int may_optimise) if ((term->disptext[idx] ^ tattr) & ATTR_WIDE) dirty_line = TRUE; - break_run = (tattr != attr || j - start >= sizeof(ch)); + break_run = (((tattr ^ attr) & term->attr_mask) || + j - start >= sizeof(ch)); /* Special hack for VT100 Linedraw glyphs */ if ((attr & CSET_MASK) == 0x2300 && tchar >= 0xBA @@ -3295,7 +3310,7 @@ static void clipme(Terminal *term, pos top, pos bottom, int rect) int rv; if (is_dbcs_leadbyte(font_codepage, (BYTE) c)) { buf[0] = c; - buf[1] = ldata[top.x + 1]; + buf[1] = (char) (0xFF & ldata[top.x + 1]); rv = mb_to_wc(font_codepage, 0, buf, 2, wbuf, 4); top.x++; } else {