diff options
author | pgen <p.gen.progs@gmail.com> | 2018-08-14 22:57:03 +0200 |
---|---|---|
committer | pgen <p.gen.progs@gmail.com> | 2018-08-14 23:15:29 +0200 |
commit | a75542771d367a248371bb3cd04d4ac4053fcf92 (patch) | |
tree | 9bf6860529a50714376611ef7c39538411ef95f7 | |
parent | 893b3ce0f54b1810610261f5ab5b16dd854c9e8a (diff) |
Add a special "full height" value to the -n option
-rw-r--r-- | smenu.1 | 4 | ||||
-rw-r--r-- | smenu.c | 36 |
2 files changed, 34 insertions, 6 deletions
@@ -456,6 +456,10 @@ directory, if present, will be ignored when this option is used. Gives the maximum number of lines in the scrolling selection window. By default five lines at most are displayed and the other ones, if any, need you to scroll the window. + +The special value \fI0\fP sets this number to match the number of lines +in the terminal (minus the lines taken by the message if any). +This remains true even if the terminal is resized. .IP "\fB-t\fP [\fIcolumns\fP]" This option sets the tabulation mode and, if a number is specified, attents to set the number of displayed columns to that number. @@ -1627,7 +1627,7 @@ ini_cb(win_t * win, term_t * term, limits_t * limits, timers_t * timers, /* """""""""""""""" */ if (strcmp(name, "lines") == 0) { - if ((error = !(sscanf(value, "%d", &v) == 1 && v > 0))) + if ((error = !(sscanf(value, "%d", &v) == 1 && v >= 0))) goto out; else win->asked_max_lines = v; @@ -7019,7 +7019,7 @@ main(int argc, char * argv[]) case 'n': if (optarg && *optarg != '-') - win.asked_max_lines = atoi(optarg); + win.asked_max_lines = abs(atoi(optarg)); else TELL("Option requires an argument -- "); break; @@ -8325,8 +8325,20 @@ main(int argc, char * argv[]) /* Force the maximum number of window's line if -n is used */ /* """"""""""""""""""""""""""""""""""""""""""""""""""""""" */ - if (win.asked_max_lines > 0) - win.max_lines = win.asked_max_lines; + if (term.nlines <= win.message_lines) + win.max_lines = 0; + else if (win.asked_max_lines >= 0) + { + if (win.asked_max_lines == 0) + win.max_lines = term.nlines - win.message_lines; + else + { + if (win.asked_max_lines > term.nlines - win.message_lines) + win.max_lines = term.nlines - win.message_lines; + else + win.max_lines = win.asked_max_lines; + } + } else win.asked_max_lines = win.max_lines; @@ -10164,8 +10176,20 @@ main(int argc, char * argv[]) /* Reset the number of lines if the terminal has enough lines */ /* """""""""""""""""""""""""""""""""""""""""""""""""""""""""" */ - if (win.max_lines < term.nlines - win.message_lines) - win.max_lines = win.asked_max_lines; + if (term.nlines <= win.message_lines) + win.max_lines = 0; + else if (win.max_lines < term.nlines - win.message_lines) + { + if (win.asked_max_lines == 0) + win.max_lines = term.nlines - win.message_lines; + else + { + if (win.asked_max_lines > term.nlines - win.message_lines) + win.max_lines = term.nlines - win.message_lines; + else + win.max_lines = win.asked_max_lines; + } + } else win.max_lines = term.nlines - win.message_lines; |