sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit 4bc4a1d030dead3308020db6fdddf4b042a83a7e
parent 60d9f7a5a9f0b55660915b06fdc73db6811a9f9d
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Wed, 31 Dec 2025 12:38:39 +0100

ed: Use the variable LINES for z

Some shells keep a variable LINES with the number of lines of the terminal
updated in every SIGWINCH. Using that variable makes easier to get a
full listing.

Diffstat:
Med.1 | 7+++++--
Med.c | 9+++++++--
2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/ed.1 b/ed.1 @@ -1,4 +1,4 @@ -.Dd December 27, 2025 +.Dd December 31, 2025 .Dt ED 1 .Os sbase .Sh NAME @@ -233,7 +233,10 @@ lines starting at the addressed line. If .Ar n is not specified then -it is defaulted to 24. +the value of $LINES - 1 is used. +If the value of +.Ar n +is 0 or negative then the default value of 23 is used. .It ($)= Print the line number of the addressed line. The dot is unchanged. diff --git a/ed.c b/ed.c @@ -1270,6 +1270,7 @@ subst(int nth) static void docmd(void) { + char *var; int cmd, c, line3, num, trunc; repeat: @@ -1406,10 +1407,14 @@ repeat: case 'z': if (nlines > 1) goto bad_address; + + num = 0; if (isdigit(back(input()))) num = getnum(); - else - num = 24; + else if ((var = getenv("LINES")) != NULL) + num = atoi(var) - 1; + if (num <= 0) + num = 23; chkprint(1); deflines(curln, curln); scroll(num);