#include <ncurses.h>
#include <fcntl.h>
+#include <locale.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
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 */
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;
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;
}