GIT.Harvie.CZ
/
mirrors
/
Programs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2637289
)
Winsize ioctl terminal size detection example
author
Harvie
<tomas@mudrunka.cz>
Sun, 6 Nov 2011 13:41:41 +0000
(14:41 +0100)
committer
Harvie
<tomas@mudrunka.cz>
Sun, 6 Nov 2011 13:41:41 +0000
(14:41 +0100)
c/winsize.c
[new file with mode: 0644]
patch
|
blob
diff --git a/c/winsize.c
b/c/winsize.c
new file mode 100644
(file)
index 0000000..
03c1f7c
--- /dev/null
+++ b/
c/winsize.c
@@ -0,0
+1,14
@@
+#include <stdio.h>
+#include <sys/ioctl.h>
+
+static int get_win_size (int fd, struct winsize *win)
+{
+ int err = ioctl (fd, TIOCGWINSZ, (char *) win);
+ return err;
+}
+
+int main(void) {
+ struct winsize win;
+ if(!get_win_size(1, &win)) puts("Chyba!");
+ printf("%d %d :-)\n", win.ws_row, win.ws_col);
+}
This page took
0.184171 seconds
and
4
git commands to generate.