X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/fc9748e2e887d65f58219e2d013d8ff6695688c3..99a3b3c9a7b45478ce4f279236ebb3c038278f30:/terminal.c diff --git a/terminal.c b/terminal.c index b88fe069..3a2ab620 100644 --- a/terminal.c +++ b/terminal.c @@ -65,6 +65,8 @@ #define has_compat(x) ( ((CL_##x)&term->compatibility_level) != 0 ) +char *EMPTY_WINDOW_TITLE = ""; + const char sco2ansicolour[] = { 0, 4, 2, 6, 1, 5, 3, 7 }; #define sel_nl_sz (sizeof(sel_nl)/sizeof(wchar_t)) @@ -1221,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 = FALSE; + set_raw_mouse_mode(term->frontend, FALSE); { int i; for (i = 0; i < 256; i++) @@ -1446,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; @@ -1610,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); @@ -1630,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; } @@ -1689,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; @@ -1720,7 +1742,7 @@ void term_provide_resize_fn(Terminal *term, { term->resize_fn = resize_fn; term->resize_ctx = resize_ctx; - if (term->cols > 0 && term->rows > 0) + if (resize_fn && term->cols > 0 && term->rows > 0) resize_fn(resize_ctx, term->cols, term->rows); } @@ -2848,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; @@ -3346,10 +3375,17 @@ static void term_out(Terminal *term) break; case 'J': /* ED: erase screen or parts of it */ { - unsigned int i = def(term->esc_args[0], 0) + 1; - if (i > 3) - i = 0; - erase_lots(term, FALSE, !!(i & 2), !!(i & 1)); + unsigned int i = def(term->esc_args[0], 0); + if (i == 3) { + /* Erase Saved Lines (xterm) + * This follows Thomas Dickey's xterm. */ + term_clrsb(term); + } else { + i++; + if (i > 3) + i = 0; + erase_lots(term, FALSE, !!(i & 2), !!(i & 1)); + } } term->disptop = 0; seen_disp_event(term); @@ -3784,8 +3820,11 @@ static void term_out(Terminal *term) break; case 20: if (term->ldisc && - !term->cfg.no_remote_qtitle) { - p = get_window_title(term->frontend, TRUE); + term->cfg.remote_qtitle_action != TITLE_NONE) { + if(term->cfg.remote_qtitle_action == TITLE_REAL) + p = get_window_title(term->frontend, TRUE); + else + p = EMPTY_WINDOW_TITLE; len = strlen(p); ldisc_send(term->ldisc, "\033]L", 3, 0); ldisc_send(term->ldisc, p, len, 0); @@ -3794,8 +3833,11 @@ static void term_out(Terminal *term) break; case 21: if (term->ldisc && - !term->cfg.no_remote_qtitle) { - p = get_window_title(term->frontend,FALSE); + term->cfg.remote_qtitle_action != TITLE_NONE) { + if(term->cfg.remote_qtitle_action == TITLE_REAL) + p = get_window_title(term->frontend, FALSE); + else + p = EMPTY_WINDOW_TITLE; len = strlen(p); ldisc_send(term->ldisc, "\033]l", 3, 0); ldisc_send(term->ldisc, p, len, 0); @@ -6383,6 +6425,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); } @@ -6426,7 +6469,7 @@ int term_get_userpass_input(Terminal *term, prompts_t *p, */ { int i; - for (i = 0; i < p->n_prompts; i++) + for (i = 0; i < (int)p->n_prompts; i++) memset(p->prompts[i]->result, 0, p->prompts[i]->result_len); } }