X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/0ce89525af77efe89d35cc4eb48945a57b9f08c0..3976728b1aa1805bee688fcfa9131edcbe4dae88:/terminal.c diff --git a/terminal.c b/terminal.c index 1e0a9fe4..410d8bb5 100644 --- a/terminal.c +++ b/terminal.c @@ -68,6 +68,9 @@ static void swap_screen(Terminal *, int, int, int); static void update_sbar(Terminal *); static void deselect(Terminal *); static void term_print_finish(Terminal *); +#ifdef OPTIMISE_SCROLL +static void scroll_display(Terminal *, int, int, int); +#endif /* OPTIMISE_SCROLL */ /* * Resize a line to make it `cols' columns wide. @@ -703,6 +706,32 @@ static void scroll(Terminal *term, int topline, int botline, int lines, int sb) } } +#ifdef OPTIMISE_SCROLL +/* + * Scroll the physical display, and our conception of it in disptext. + */ +static void scroll_display(Terminal *term, int topline, int botline, int lines) +{ + unsigned long *start, *end; + int distance, size, i; + + start = term->disptext + topline * (term->cols + 1); + end = term->disptext + (botline + 1) * (term->cols + 1); + distance = (lines > 0 ? lines : -lines) * (term->cols + 1); + size = end - start - distance; + if (lines > 0) { + memmove(start, start + distance, size * TSIZE); + for (i = 0; i < distance; i++) + (start + size)[i] |= ATTR_INVALID; + } else { + memmove(start + distance, start, size * TSIZE); + for (i = 0; i < distance; i++) + start[i] |= ATTR_INVALID; + } + do_scroll(term->frontend, topline, botline, lines); +} +#endif /* OPTIMISE_SCROLL */ + /* * Move the cursor to a given position, clipping at boundaries. We * may or may not want to clip at the scroll margin: marg_clip is 0 @@ -1227,7 +1256,7 @@ void term_out(Terminal *term) } /* Are we in the nasty ACS mode? Note: no sco in utf mode. */ else if(term->sco_acs && - (c!='\033' && c!='\n' && c!='\r' && c!='\b')) + (c!='\033' && c!='\012' && c!='\015' && c!='\b')) { if (term->sco_acs == 2) c ^= 0x80; c |= ATTR_SCOACS; @@ -1413,7 +1442,7 @@ void term_out(Terminal *term) term->esc_query = FALSE; } break; - case '\r': + case '\015': term->curs.x = 0; term->wrapnext = FALSE; fix_cpos; @@ -1433,7 +1462,7 @@ void term_out(Terminal *term) } case '\013': compatibility(VT100); - case '\n': + case '\012': if (term->curs.y == term->marg_b) scroll(term, term->marg_t, term->marg_b, 1, TRUE); else if (term->curs.y < term->rows - 1) @@ -2500,7 +2529,7 @@ void term_out(Terminal *term) * * -- RDB */ - if (c == '\n' || c == '\r') { + if (c == '\012' || c == '\015') { term->termstate = TOPLEVEL; } else if (c == 0234 || c == '\007') { /* @@ -2983,7 +3012,7 @@ static void do_paint(Terminal *term, Context ctx, int may_optimise) */ if ((tchar | tattr) != (term->disptext[idx]& ~ATTR_NARROW)) { if ((tattr & ATTR_WIDE) == 0 && - CharWidth(ctx, (tchar | tattr) & 0xFFFF) == 2) + char_width(ctx, (tchar | tattr) & 0xFFFF) == 2) tattr |= ATTR_NARROW; } else if (term->disptext[idx]&ATTR_NARROW) tattr |= ATTR_NARROW; @@ -3143,6 +3172,10 @@ void term_paint(Terminal *term, Context ctx, void term_scroll(Terminal *term, int rel, int where) { int sbtop = -count234(term->scrollback); +#ifdef OPTIMISE_SCROLL + int olddisptop = term->disptop; + int shift; +#endif /* OPTIMISE_SCROLL */ term->disptop = (rel < 0 ? 0 : rel > 0 ? sbtop : term->disptop) + where; if (term->disptop < sbtop) @@ -3150,6 +3183,11 @@ void term_scroll(Terminal *term, int rel, int where) if (term->disptop > 0) term->disptop = 0; update_sbar(term); +#ifdef OPTIMISE_SCROLL + shift = (term->disptop - olddisptop); + if (shift < term->rows && shift > -term->rows) + scroll_display(term, 0, term->rows - 1, shift); +#endif /* OPTIMISE_SCROLL */ term_update(term); } @@ -3251,12 +3289,12 @@ static void clipme(Terminal *term, pos top, pos bottom, int rect) if (DIRECT_FONT(uc)) { if (c >= ' ' && c != 0x7F) { - unsigned char buf[4]; + char buf[4]; WCHAR wbuf[4]; int rv; if (is_dbcs_leadbyte(font_codepage, (BYTE) c)) { buf[0] = c; - buf[1] = (unsigned char) ldata[top.x + 1]; + buf[1] = ldata[top.x + 1]; rv = mb_to_wc(font_codepage, 0, buf, 2, wbuf, 4); top.x++; } else { @@ -3555,7 +3593,7 @@ void term_do_paste(Terminal *term) if (p <= data + len - sel_nl_sz && !memcmp(p, sel_nl, sizeof(sel_nl))) { - term->paste_buffer[term->paste_len++] = '\r'; + term->paste_buffer[term->paste_len++] = '\015'; p += sel_nl_sz; } q = p; @@ -3814,7 +3852,7 @@ void term_paste(Terminal *term) while (term->paste_pos < term->paste_len) { int n = 0; while (n + term->paste_pos < term->paste_len) { - if (term->paste_buffer[term->paste_pos + n++] == '\r') + if (term->paste_buffer[term->paste_pos + n++] == '\015') break; } if (term->ldisc)