X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=demo%2Fboxshell.c;h=806a1ff2394df7425546c764fc18d545df708dd0;hb=dc1e2fe77a99263de102a8e1d8819e929339a7bb;hp=76af9146ec6359744a719c820eea09f7e17f0f1a;hpb=2ce3ba8535147bd21ce80c140afb13083dd5d289;p=apps%2Fmadtty.git diff --git a/demo/boxshell.c b/demo/boxshell.c index 76af914..806a1ff 100644 --- a/demo/boxshell.c +++ b/demo/boxshell.c @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -56,13 +57,22 @@ static int is_expired(struct timeval now, struct timeval expiry) int main(void) { madtty_t *rt; - int dirty = 0; + int dirty = 0, pty; struct timeval next; signal(SIGCHLD, handler); signal(SIGWINCH, handler); - madtty_initialize(); + setlocale(LC_ALL, ""); + initscr(); + start_color(); + noecho(); + raw(); + nodelay(stdscr, TRUE); + keypad(stdscr, TRUE); + curs_set(0); + ESCDELAY=50; + madtty_init_colors(); getmaxyx(stdscr, screen_h, screen_w); /* create a window with a frame */ @@ -72,7 +82,7 @@ int main(void) const char *path = getenv("SHELL") ?: "/bin/sh"; const char *args[] = { path, "--login", NULL}; - madtty_forkpty(rt, path, args); + madtty_forkpty(rt, path, args, &pty); } /* keep reading keypresses from the user and passing them to the terminal; @@ -85,10 +95,10 @@ int main(void) FD_ZERO(&rfds); FD_SET(0, &rfds); - FD_SET(rt->pty, &rfds); + FD_SET(pty, &rfds); - if (select(rt->pty + 1, &rfds, NULL, NULL, &tv) > 0) { - if (FD_ISSET(rt->pty, &rfds)) { + if (select(pty + 1, &rfds, NULL, NULL, &tv) > 0) { + if (FD_ISSET(pty, &rfds)) { madtty_process(rt); dirty = 1; }