aboutsummaryrefslogtreecommitdiffstats
path: root/src/termios_wrapper.c
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-03-20 00:36:08 -0500
committerJesse Luehrs <doy@tozt.net>2013-03-20 00:36:08 -0500
commit8fc473d033a4c38f7c0024bd259ff54b9867d50d (patch)
tree945a6323eb4d457871c7e2e26fc2684cc26ddcaa /src/termios_wrapper.c
parent28eeecd93029db4b756844852e3608eba83bf455 (diff)
downloadrust-term-8fc473d033a4c38f7c0024bd259ff54b9867d50d.tar.gz
rust-term-8fc473d033a4c38f7c0024bd259ff54b9867d50d.zip
implement getting terminal size
Diffstat (limited to 'src/termios_wrapper.c')
-rw-r--r--src/termios_wrapper.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/termios_wrapper.c b/src/termios_wrapper.c
index a245322..097f470 100644
--- a/src/termios_wrapper.c
+++ b/src/termios_wrapper.c
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <errno.h>
#include <termios.h>
+#include <sys/ioctl.h>
/* very simplistic, ignores a lot of the settings that i don't understand,
* patches welcome */
@@ -87,3 +88,11 @@ void set(struct termios *t)
tcsetattr(0, TCSANOW, t);
free(t);
}
+
+void size(unsigned int *rows, unsigned int *cols)
+{
+ struct winsize ws;
+ ioctl(0, TIOCGWINSZ, &ws);
+ *rows = ws.ws_row;
+ *cols = ws.ws_col;
+}