X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/c1190260b27bab9d7ce68ff039c7658b9b839701..8412ec80fffa6d4e3422a7240409a9d775b29c44:/terminal.c diff --git a/terminal.c b/terminal.c index f58941fa..996a01fb 100644 --- a/terminal.c +++ b/terminal.c @@ -1223,6 +1223,8 @@ static void power_on(Terminal *term, int clear) term->erase_char = term->basic_erase_char; term->alt_which = 0; term_print_finish(term); + term->xterm_mouse = 0; + set_raw_mouse_mode(term->frontend, FALSE); { int i; for (i = 0; i < 256; i++) @@ -1448,7 +1450,7 @@ Terminal *term_init(Config *mycfg, struct unicode_data *ucsdata, term->vt52_mode = FALSE; term->cr_lf_return = FALSE; term->seen_disp_event = FALSE; - term->xterm_mouse = term->mouse_is_down = FALSE; + term->mouse_is_down = FALSE; term->reset_132 = FALSE; term->cblinker = term->tblinker = 0; term->has_focus = 1; @@ -1612,6 +1614,8 @@ void term_size(Terminal *term, int newrows, int newcols, int newsavelines) addpos234(term->screen, line, 0); term->curs.y += 1; term->savecurs.y += 1; + term->alt_y += 1; + term->alt_savecurs.y += 1; } else { /* Add a new blank line at the bottom of the screen. */ line = newline(term, newcols, FALSE); @@ -1632,6 +1636,8 @@ void term_size(Terminal *term, int newrows, int newcols, int newsavelines) term->tempsblines += 1; term->curs.y -= 1; term->savecurs.y -= 1; + term->alt_y -= 1; + term->alt_savecurs.y -= 1; } term->rows -= 1; } @@ -1691,12 +1697,26 @@ void term_size(Terminal *term, int newrows, int newcols, int newsavelines) term->savecurs.y = 0; if (term->savecurs.y >= newrows) term->savecurs.y = newrows - 1; + if (term->savecurs.x >= newcols) + term->savecurs.x = newcols - 1; + if (term->alt_savecurs.y < 0) + term->alt_savecurs.y = 0; + if (term->alt_savecurs.y >= newrows) + term->alt_savecurs.y = newrows - 1; + if (term->alt_savecurs.x >= newcols) + term->alt_savecurs.x = newcols - 1; if (term->curs.y < 0) term->curs.y = 0; if (term->curs.y >= newrows) term->curs.y = newrows - 1; if (term->curs.x >= newcols) term->curs.x = newcols - 1; + if (term->alt_y < 0) + term->alt_y = 0; + if (term->alt_y >= newrows) + term->alt_y = newrows - 1; + if (term->alt_x >= newcols) + term->alt_x = newcols - 1; term->alt_x = term->alt_y = 0; term->wrapnext = term->alt_wnext = FALSE; @@ -2365,11 +2385,11 @@ static void toggle_mode(Terminal *term, int mode, int query, int state) swap_screen(term, term->cfg.no_alt_screen ? 0 : state, FALSE, FALSE); term->disptop = 0; break; - case 1000: /* xterm mouse 1 */ + case 1000: /* xterm mouse 1 (normal) */ term->xterm_mouse = state ? 1 : 0; set_raw_mouse_mode(term->frontend, state); break; - case 1002: /* xterm mouse 2 */ + case 1002: /* xterm mouse 2 (inc. button drags) */ term->xterm_mouse = state ? 2 : 0; set_raw_mouse_mode(term->frontend, state); break; @@ -2850,6 +2870,13 @@ static void term_out(Terminal *term) term->wrapnext = FALSE; seen_disp_event(term); term->paste_hold = 0; + + if (term->cfg.crhaslf) { + 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) + term->curs.y++; + } if (term->logctx) logtraffic(term->logctx, (unsigned char) c, LGTYP_ASCII); break; @@ -3751,7 +3778,7 @@ static void term_out(Terminal *term) if (term->ldisc) ldisc_send(term->ldisc, is_iconic(term->frontend) ? - "\033[1t" : "\033[2t", 4, 0); + "\033[2t" : "\033[1t", 4, 0); break; case 13: if (term->ldisc) { @@ -3763,7 +3790,7 @@ static void term_out(Terminal *term) case 14: if (term->ldisc) { get_window_pixels(term->frontend, &x, &y); - len = sprintf(buf, "\033[4;%d;%dt", x, y); + len = sprintf(buf, "\033[4;%d;%dt", y, x); ldisc_send(term->ldisc, buf, len, 0); } break; @@ -5235,8 +5262,17 @@ static void clipme(Terminal *term, pos top, pos bottom, int rect, int desel) set = (uc & CSET_MASK); c = (uc & ~CSET_MASK); - cbuf[0] = uc; - cbuf[1] = 0; +#ifdef PLATFORM_IS_UTF16 + if (uc > 0x10000 && uc < 0x110000) { + cbuf[0] = 0xD800 | ((uc - 0x10000) >> 10); + cbuf[1] = 0xDC00 | ((uc - 0x10000) & 0x3FF); + cbuf[2] = 0; + } else +#endif + { + cbuf[0] = uc; + cbuf[1] = 0; + } if (DIRECT_FONT(uc)) { if (c >= ' ' && c != 0x7F) { @@ -5915,7 +5951,7 @@ void term_key(Terminal *term, Key_Sym keysym, wchar_t *text, size_t tlen, if (modifiers & PKM_CONTROL) c &= 0x1f; else if (modifiers & PKM_SHIFT) - c = toupper(c); + c = toupper((unsigned char)c); } *p++ = c; goto done; @@ -6398,6 +6434,7 @@ char *term_get_ttymode(Terminal *term, const char *mode) val = term->cfg.bksp_is_delete ? "^?" : "^H"; } /* FIXME: perhaps we should set ONLCR based on cfg.lfhascr as well? */ + /* FIXME: or ECHO and friends based on local echo state? */ return dupstr(val); }