From: NeilBrown Date: Fri, 21 Jul 2023 10:33:28 +0000 (+1000) Subject: menu: allow memu to get wider X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=7908e48f041323b30a6e31d10e170b40d6799d72;p=edlib.git menu: allow memu to get wider 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 --- diff --git a/lib-menu.c b/lib-menu.c index d1016e3e..2c9625f1 100644 --- a/lib-menu.c +++ b/lib-menu.c @@ -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; } diff --git a/tests.d/00-basic b/tests.d/00-basic index 9fcf7828..8e5501d5 100644 --- a/tests.d/00-basic +++ b/tests.d/00-basic @@ -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" diff --git a/tests.d/02-grep b/tests.d/02-grep index 3a2d1d75..7b4c3b39 100644 --- a/tests.d/02-grep +++ b/tests.d/02-grep @@ -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