Scrollbar was failing to update when no scrollback-reset event had happened
[u/mdw/putty] / terminal.c
index 9abb848..cf55f8e 100644 (file)
@@ -82,7 +82,7 @@ typedef struct {
 #define poslt(p1,p2) ( (p1).y < (p2).y || ( (p1).y == (p2).y && (p1).x < (p2).x ) )
 #define posle(p1,p2) ( (p1).y < (p2).y || ( (p1).y == (p2).y && (p1).x <= (p2).x ) )
 #define poseq(p1,p2) ( (p1).y == (p2).y && (p1).x == (p2).x )
-#define posdiff(p1,p2) ( ((p2).y - (p1).y) * (cols+1) + (p2).x - (p1).x )
+#define posdiff(p1,p2) ( ((p1).y - (p2).y) * (cols+1) + (p1).x - (p2).x )
 #define incpos(p) ( (p).x == cols ? ((p).x = 0, (p).y++, 1) : ((p).x++, 0) )
 #define decpos(p) ( (p).x == 0 ? ((p).x = cols, (p).y--, 1) : ((p).x--, 0) )
 
@@ -298,11 +298,12 @@ void term_update(void)
     Context ctx;
     ctx = get_ctx();
     if (ctx) {
+       if (seen_disp_event)
+           update_sbar();
        if ((seen_key_event && (cfg.scroll_on_key)) ||
            (seen_disp_event && (cfg.scroll_on_disp))) {
            disptop = 0;               /* return to main screen */
            seen_disp_event = seen_key_event = 0;
-           update_sbar();
        }
        do_paint(ctx, TRUE);
        sys_cursor(curs.x, curs.y - disptop);
@@ -358,9 +359,9 @@ void term_init(void)
  */
 void term_size(int newrows, int newcols, int newsavelines)
 {
-    tree234 *newsb, *newscreen, *newalt;
-    unsigned long *newdisp, *oldline, *line;
-    int i, j, ccols;
+    tree234 *newalt;
+    unsigned long *newdisp, *line;
+    int i, j;
     int sblen;
     int save_alt_which = alt_which;
 
@@ -1142,11 +1143,9 @@ void term_out(void)
                    /*
                     * Perform an actual beep if we're not overloaded.
                     */
-                   if ((!cfg.bellovl || !beep_overloaded)
-                       && cfg.beep != 0) {
-                       if (cfg.beep != 2)
-                           beep(cfg.beep);
-                       else if (cfg.beep == 2) {
+                   if (!cfg.bellovl || !beep_overloaded) {
+                       beep(cfg.beep);
+                       if (cfg.beep == BELL_VISUAL) {
                            in_vbell = TRUE;
                            vbell_timeout = ticks + VBELL_TIMEOUT;
                            term_update();
@@ -1444,7 +1443,7 @@ void term_out(void)
                          case ANSI('5', '#'):
                            nlattr = LATTR_NORM;
                            break;
-                         case ANSI('6', '#'):
+                         default: /* spiritually case ANSI('6', '#'): */
                            nlattr = LATTR_WIDE;
                            break;
                        }
@@ -2064,8 +2063,10 @@ void term_out(void)
                        val = c - 'A' + 10;
                    else if (c >= 'a' && c <= 'a' + max - 10)
                        val = c - 'a' + 10;
-                   else
+                   else {
                        termstate = TOPLEVEL;
+                       break;
+                   }
                    osc_string[osc_strlen++] = val;
                    if (osc_strlen >= 7) {
                        palette_set(osc_string[0],
@@ -2359,6 +2360,7 @@ void term_out(void)
                                    ATTR_BLINK)));
                break;
 #endif
+             default: break;          /* placate gcc warning about enum use */
            }
        if (selstate != NO_SELECTION) {
            pos cursplus = curs;
@@ -2997,6 +2999,7 @@ void term_mouse(Mouse_Button b, Mouse_Action a, int x, int y,
          case MBT_WHEEL_DOWN:
            encstate = 0x61;
            break;
+         default: break;              /* placate gcc warning about enum use */
        }
        switch (a) {
          case MA_DRAG:
@@ -3013,6 +3016,7 @@ void term_mouse(Mouse_Button b, Mouse_Action a, int x, int y,
                return;
            is_down = b;
            break;
+         default: break;              /* placate gcc warning about enum use */
        }
        if (shift)
            encstate += 0x04;