JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
update TODO
[st.git] / std.c
diff --git a/std.c b/std.c
index 4808db4..fcfead9 100644 (file)
--- a/std.c
+++ b/std.c
@@ -6,6 +6,9 @@
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
+#if !(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
+#include <pty.h>
+#endif
 #include <signal.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -25,7 +28,7 @@ void eprintn(const char *errstr, ...);
 void getpty(void);
 void movea(int x, int y);
 void mover(int x, int y);
-void parse(void);
+void parseesc(void);
 void scroll(int l);
 void shell(void);
 void sigchld(int n);
@@ -306,12 +309,24 @@ unbuffer(void) {
 
 int
 main(int argc, char *argv[]) {
-       fd_set rd;
        if(argc == 2 && !strcmp("-v", argv[1]))
                eprint("std-"VERSION", © 2008 Matthias-Christian Ott\n");
        else if(argc == 1)
                eprint("usage: st [-v]\n");
        getpty();
        shell();
+       fptm = fdopen(ptm, "r+");
+       if(!fptm)
+               eprintn("cannot open slave pty");
+       for(;;) {
+               c = getc(fptm);
+               switch(c) {
+               case '\033':
+                       parseesc();
+                       break;
+               default:
+                       putchar(c);
+               }
+       }
        return 0;
 }