Note about CTRL-C trick for copying text of error dialogs
[u/mdw/putty] / terminal.c
index 738c754..37c75d7 100644 (file)
@@ -319,6 +319,7 @@ Terminal *term_init(void *frontend)
     term->repeat_off = FALSE;
     term->termstate = TOPLEVEL;
     term->selstate = NO_SELECTION;
+    term->curstype = 0;
 
     term->screen = term->alt_screen = term->scrollback = NULL;
     term->disptop = 0;
@@ -1226,7 +1227,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;
@@ -1372,12 +1373,12 @@ void term_out(Terminal *term)
                     * Perform an actual beep if we're not overloaded.
                     */
                    if (!cfg.bellovl || !term->beep_overloaded) {
+                       beep(term->frontend, cfg.beep);
                        if (cfg.beep == BELL_VISUAL) {
                            term->in_vbell = TRUE;
                            term->vbell_startpoint = ticks;
                            term_update(term);
-                       } else
-                           beep(term->frontend, cfg.beep);
+                       }
                    }
                    term->disptop = 0;
                }
@@ -1412,7 +1413,7 @@ void term_out(Terminal *term)
                    term->esc_query = FALSE;
                }
                break;
-             case '\r':
+             case '\015':
                term->curs.x = 0;
                term->wrapnext = FALSE;
                fix_cpos;
@@ -1432,7 +1433,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)
@@ -2499,7 +2500,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') {
                    /*
@@ -2982,7 +2983,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;
@@ -3106,7 +3107,7 @@ void term_invalidate(Terminal *term)
  * Paint the window in response to a WM_PAINT message.
  */
 void term_paint(Terminal *term, Context ctx,
-               int left, int top, int right, int bottom)
+               int left, int top, int right, int bottom, int immediately)
 {
     int i, j;
     if (left < 0) left = 0;
@@ -3128,7 +3129,7 @@ void term_paint(Terminal *term, Context ctx,
      * fails to actually do anything when re-sizing ... painting the wrong
      * window perhaps ?
      */
-    if (alt_pressed)
+    if (immediately)
         do_paint (term, ctx, FALSE);
 }
 
@@ -3250,12 +3251,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 {
@@ -3554,7 +3555,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;
@@ -3813,7 +3814,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)