summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2017-07-21 20:47:30 -0400
committerJune McEnroe <june@causal.agency>2017-07-21 20:47:30 -0400
commit8dd24fbfac017e322de045cf00964775af48aaef (patch)
treef1a00604e223fd23ac51bf5f37b2c8c9aaeebdcf
parentAdd hnel (diff)
downloadsrc-8dd24fbfac017e322de045cf00964775af48aaef.tar.gz
src-8dd24fbfac017e322de045cf00964775af48aaef.zip
Set window size in hnel
Diffstat (limited to '')
-rwxr-xr-xhome/.bin/hnel.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/home/.bin/hnel.c b/home/.bin/hnel.c
index 0e270a5c..2f00711a 100755
--- a/home/.bin/hnel.c
+++ b/home/.bin/hnel.c
@@ -7,6 +7,8 @@ exec cc -Wall -Wextra -pedantic $@ -lutil -o $(dirname $0)/hnel $0
 #include <err.h>
 #include <poll.h>
 #include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/wait.h>
 #include <sysexits.h>
 #include <termios.h>
 #include <unistd.h>
@@ -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);
 
-05 15:37:49 +0200'>2019-06-05git: update to v2.21.0Christian Hesse 2019-06-05ui-ssdiff: ban strncat()Christian Hesse 2019-06-05global: make 'char *path' const where possibleChristian Hesse 2019-05-20ui-shared: restrict to 15 levelsJason A. Donenfeld 2019-02-23ui-diff,ui-tag: don't use htmlf with non-formatted stringsChris Mayo 2019-02-23ui-ssdiff: resolve HTML5 validation errorsChris Mayo 2019-01-03filters: migrate from luacrypto to luaosslJason A. Donenfeld 2019-01-02ui-shared: fix broken sizeof in title setting and rewriteJason A. Donenfeld 2018-12-09git: update to v2.20.0Christian Hesse 2018-11-25ui-blame: set repo for sbJason A. Donenfeld 2018-11-25auth-filter: pass url with query string attachedJason A. Donenfeld 2018-11-21git: use xz compressed archive for downloadChristian Hesse 2018-10-12git: update to v2.19.1Christian Hesse 2018-09-11ui-ssdiff: ban strcat()Christian Hesse 2018-09-11ui-ssdiff: ban strncpy()Christian Hesse 2018-09-11ui-shared: ban strcat()Christian Hesse 2018-09-11ui-patch: ban sprintf()Christian Hesse 2018-09-11ui-log: ban strncpy()Christian Hesse 2018-09-11ui-log: ban strcpy()Christian Hesse 2018-09-11parsing: ban sprintf()Christian Hesse 2018-09-11parsing: ban strncpy()Christian Hesse 2018-08-28filters: generate anchor links from markdownChristian Hesse 2018-08-03Bump version.Jason A. Donenfeld 2018-08-03clone: fix directory traversalJason A. Donenfeld 2018-08-03config: record repo.snapshot-prefix in the per-repo configKonstantin Ryabitsev