From d4be6d8760a84fa26dfcbb30f5eae35f124dcf76 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Fri, 21 Jul 2017 20:47:30 -0400 Subject: Set window size in hnel --- curtis/.bin/hnel.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'curtis') diff --git a/curtis/.bin/hnel.c b/curtis/.bin/hnel.c index 0e270a5c..2f00711a 100755 --- a/curtis/.bin/hnel.c +++ b/curtis/.bin/hnel.c @@ -7,6 +7,8 @@ exec cc -Wall -Wextra -pedantic $@ -lutil -o $(dirname $0)/hnel $0 #include #include #include +#include +#include #include #include #include @@ -35,6 +37,7 @@ static void restoreTerm(void) { } int main(int argc, char *argv[]) { + int error; if (argc < 2) return EX_USAGE; char table[256] = {0}; @@ -43,8 +46,12 @@ int main(int argc, char *argv[]) { table['j'] = 'e'; table['J'] = 'E'; table[CTRL('J')] = CTRL('E'); table['k'] = 'n'; table['K'] = 'N'; table[CTRL('K')] = CTRL('N'); + struct winsize window; + error = ioctl(STDERR_FILENO, TIOCGWINSZ, &window); + if (error) err(EX_IOERR, "ioctl"); + int master; - pid_t pid = forkpty(&master, NULL, NULL, NULL); + pid_t pid = forkpty(&master, NULL, NULL, &window); if (pid < 0) err(EX_OSERR, "forkpty"); if (!pid) { @@ -52,7 +59,7 @@ int main(int argc, char *argv[]) { err(EX_OSERR, "%s", argv[1]); } - int error = tcgetattr(STDERR_FILENO, &saveTerm); + error = tcgetattr(STDERR_FILENO, &saveTerm); if (error) err(EX_IOERR, "tcgetattr"); atexit(restoreTerm); -- cgit 1.4.1