: nply/wmenu

commit 3bd664498600d92ca1be6e01e35311bceea2e977
parent 4aecb462e5fccf9b2faceb0c4d21bc0f64ee82e2
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Tue, 13 Oct 2026 23:14:00 +0530

Support -l-1 for a screen-filling list
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/README b/README
@@ -27,7 +27,7 @@ Useful flags:
 -e utf8|ansi|oem    stdin/stdout/prompt encoding; default utf8
 -x px -y px -w px   position and width
 -c                  center window
--l lines            visible list lines (capped to screen height)
+-l lines            visible list lines; -l-1 fills the screen (default 5)
 -m                  select multiple entries; Ctrl+Enter adds one
 -V                  enable vi support; Ctrl+Alt+V toggles vi mode
 -d                  use normal Windows edit shortcuts instead of emacs-ish keys
diff --git a/test_stream.c b/test_stream.c
@@ -17,7 +17,8 @@ static LRESULT CALLBACK TestWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
 
 int main(int argc, char **argv)
 {
-    assert(fit_lines(INT_MAX, 300) == 12);
+    assert(fit_lines(INT_MAX, 300) == 12); /* Oversized values are still safe. */
+    assert(fit_lines(-1, 300) == 12); /* -l-1 fills the screen. */
     assert(fit_lines(0, 300) == 5);
     assert(fit_lines(7, 35) == 1);
     assert(has_match("aC", "ABC"));
diff --git a/wmenu.c b/wmenu.c
@@ -771,6 +771,7 @@ static int fit_lines(int requested, int screen_height)
     int row_height = S(22);
     int fit = row_height > 0 && screen_height > S(28) ? (screen_height - S(28)) / row_height : 1;
     if (fit < 1) fit = 1;
+    if (requested == -1) return fit;
     if (requested < 1) requested = 5;
     return requested < fit ? requested : fit;
 }