Usermode/IRC - Added basic PTY support
authorJohn Hodge <[email protected]>
Tue, 6 Aug 2013 01:55:26 +0000 (09:55 +0800)
committerJohn Hodge <[email protected]>
Tue, 6 Aug 2013 01:55:26 +0000 (09:55 +0800)
Usermode/Applications/irc_src/main.c

index b96fcc9..a348277 100644 (file)
@@ -7,6 +7,7 @@
 #include <string.h>\r
 #include <net.h>\r
 #include <readline.h>\r
+#include <acess/devices/pty.h>\r
 \r
 // === TYPES ===\r
 typedef struct sServer {\r
@@ -102,8 +103,17 @@ int main(int argc, const char *argv[], const char *envp[])
        \r
        atexit(ExitHandler);\r
        \r
-       giTerminal_Width = _SysIOCtl(1, 5, NULL);       // getset_width\r
-       giTerminal_Height = _SysIOCtl(1, 6, NULL);      // getset_height\r
+       if( _SysIOCtl(1, DRV_IOCTL_TYPE, NULL) != DRV_TYPE_TERMINAL ) {\r
+               printf(stderr, "note: assuming 80x25, can't get terminal dimensions\n");\r
+               giTerminal_Width = 80;\r
+               giTerminal_Height = 25;\r
+       }\r
+       else {\r
+               struct ptydims  dims;\r
+               _SysIOCtl(1, PTY_IOCTL_GETDIMS, &dims);\r
+               giTerminal_Width = dims.W;\r
+               giTerminal_Height = dims.H;\r
+       }\r
        \r
        printf("\x1B[?1047h");\r
        printf("\x1B[%i;%ir", 0, giTerminal_Height-1);\r

UCC git Repository :: git.ucc.asn.au