]> git.neil.brown.name Git - edlib.git/commitdiff
menu: allow memu to get wider
authorNeilBrown <neil@brown.name>
Fri, 21 Jul 2023 10:33:28 +0000 (20:33 +1000)
committerNeilBrown <neil@brown.name>
Fri, 21 Jul 2023 10:43:31 +0000 (20:43 +1000)
If menu gets smaller we already reduce size.
Now we do so when menu gets bigger too.
For this, we add 1 to width so there is a change for it to appear wider
as the width reported is only ever the visible width.

This makes all menus slightly wider.

Signed-off-by: NeilBrown <neil@brown.name>
lib-menu.c
tests.d/00-basic
tests.d/02-grep

index d1016e3e0d2a6c71f570466f700a5bd753dd4e23..2c9625f13f0f510c3d1e7fc441ea6d89750ff367 100644 (file)
@@ -44,9 +44,14 @@ DEF_CMD(menu_reposition)
        int cols = ci->num2;
        struct pane *p = call_ret(pane, "ThisPopup", ci->focus);
 
-       if (p && lines != 0 && cols != 0 &&
-           (lines <= p->h && cols <= p->w))
-               pane_resize(p, p->x, p->y, cols, lines);
+       if (!p || lines <= 0 || cols <= 0)
+               return Efallthrough;
+       if (lines > p->parent->h - p->y)
+               lines = p->parent->h - p->y;
+       if (cols > p->parent->w - p->x)
+               cols = p->parent->w - p->x;
+       /* Add 1 to cols so that if menu gets wider we will see that and resize */
+       pane_resize(p, p->x, p->y, cols+1, lines);
        return Efallthrough;
 }
 
index 9fcf782805ef1786a0c0c9c284a50b26939083f1..8e5501d533e5130cff85c6d471be6a8c1518654a 100644 (file)
@@ -542,11 +542,11 @@ Display 80,30 57B0121C30A300F9ED93171BD0D569BD 9,2
 Key ":A-/"
 Display 80,30 A1E582F95603809A9E8DC276497C1A05 12,2
 Key ":A-/"
-Display 80,30 F4601EC985A4AD3732CEC32383725B3E 5,3
+Display 80,30 CEB607FDD0638B06E07DA5E4ADBA26CD 5,3
 Key ":Down"
-Display 80,30 62BAE0BB16AD8E50349B3BC5215D639F 5,4
+Display 80,30 D157CC4D9FD3048B390C2B4A825BD7D5 5,4
 Key ":Down"
-Display 80,30 62BAE0BB16AD8E50349B3BC5215D639F 5,5
+Display 80,30 D157CC4D9FD3048B390C2B4A825BD7D5 5,5
 Key ":Enter"
 Display 80,30 2BD7C1E1B97545BEADE556086C9E25D6 13,2
 Key ":A:Backspace"
@@ -566,9 +566,9 @@ Display 80,30 2C925032938071DE257DE77D7EFF9A0B 9,2
 Key ":Backspace"
 Display 80,30 2C925032938071DE257DE77D7EFF9A0B 8,2
 Key ":A-/"
-Display 80,30 5C4CE8698100A7263286F46B34C24BD1 5,3
+Display 80,30 339EB5E1166F780D543CAAFD17373EE7 5,3
 Key ":Down"
-Display 80,30 9173D165F92FAC77DB0E1FCC7F1BAC5B 5,4
+Display 80,30 80EE162380B6A73F1AE5BDF002F3B6FA 5,4
 Key ":Enter"
 Display 80,30 01D3F32F892BC4076D6021BE085BF4D7 19,2
 Key ":C-U"
index 3a2d1d75f5320719603bbe8cd8f4ae1b8174d2d6..7b4c3b398bc7601cbc7fe719a203d304b759cdf8 100644 (file)
@@ -242,4 +242,4 @@ Key ":C-X"
 Display 80,30 1B93FE4A0F3F6D0DA9A9A7767239F356 1,6
 Key ":C-C"
 Display 80,30 010E4E8994BB534A4F27DD543E023E74 1,6
-Close 908
+Close 905