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 /smenu.c | |
parent | 893b3ce0f54b1810610261f5ab5b16dd854c9e8a (diff) |
Add a special "full height" value to the -n option
Diffstat (limited to 'smenu.c')
-rw-r--r-- | smenu.c | 36 |
1 files changed, 30 insertions, 6 deletions
@@ -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; |