]> granicus.if.org Git - nethack/commitdiff
curses: scrollbars on clipped map
authorPatR <rankin@nethack.org>
Thu, 29 Sep 2022 20:58:50 +0000 (13:58 -0700)
committerPatR <rankin@nethack.org>
Thu, 29 Sep 2022 20:58:50 +0000 (13:58 -0700)
A change to the curses interface from three years ago to make sure
that round-off didn't make the horizontal and vertical clipped map
indicators appear to not be clipped was using ROWNO for both instead
of COLNO for the horizontal one.  For modest clipping the mistake
was unnoticeable; I don't know whether that remained true for more
extreme clipping.

[Not fixed:  the curses scrollbar stuff ignores the fact that map
column 0 is unused.]

win/curses/curswins.c

index 8491a1e359bff5a95a35458edba17310b207a0bb..e1a8a65c07bb4f2f0a246b5ef45184bab23f92d7 100644 (file)
@@ -252,13 +252,7 @@ curses_add_nhwin(winid wid, int height, int width, int y, int x,
         break;
     case MAP_WIN:
         mapwin = win;
-
-        if ((width < COLNO) || (height < ROWNO)) {
-            map_clipped = TRUE;
-        } else {
-            map_clipped = FALSE;
-        }
-
+        map_clipped = (width < COLNO || height < ROWNO);
         break;
     }
 
@@ -656,17 +650,15 @@ curses_draw_map(int sx, int sy, int ex, int ey)
 
         if (sx > 0 && sbsx == 0)
             ++sbsx;
-        if (ex < ROWNO - 1 && sbex == ROWNO - 1)
+        if (ex < COLNO - 1 && sbex == COLNO - 1)
             --sbex;
 
         for (count = 0; count < sbsx; count++) {
             write_char(mapwin, count + bspace, ey - sy + 1 + bspace, hsb_back);
         }
-
         for (count = sbsx; count <= sbex; count++) {
             write_char(mapwin, count + bspace, ey - sy + 1 + bspace, hsb_bar);
         }
-
         for (count = sbex + 1; count <= (ex - sx); count++) {
             write_char(mapwin, count + bspace, ey - sy + 1 + bspace, hsb_back);
         }
@@ -685,11 +677,9 @@ curses_draw_map(int sx, int sy, int ex, int ey)
         for (count = 0; count < sbsy; count++) {
             write_char(mapwin, ex - sx + 1 + bspace, count + bspace, vsb_back);
         }
-
         for (count = sbsy; count <= sbey; count++) {
             write_char(mapwin, ex - sx + 1 + bspace, count + bspace, vsb_bar);
         }
-
         for (count = sbey + 1; count <= (ey - sy); count++) {
             write_char(mapwin, ex - sx + 1 + bspace, count + bspace, vsb_back);
         }