#ifndef MADTTY_MADTTY_H
#define MADTTY_MADTTY_H
-#include <ncursesw/curses.h>
+#include <ncurses.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
+#include <wchar.h>
#define MAX_CSI_ES_PARAMS 32
-#define ESEQ_BUF_SIZE 128 /* size of escape sequence buffer */
-/* Represents each of the text cells in the terminal screen */
-typedef struct {
- char s[4];
- char len;
- attr_t attrs;
-} RoteCell;
+typedef struct mtty_row_t mtty_row_t;
typedef struct {
int pty;
pid_t childpid;
/* flags */
- unsigned insert : 1;
- unsigned escaped : 1;
- unsigned graphmode : 1;
+ unsigned seen_input : 1;
+ unsigned insert : 1;
+ unsigned escaped : 1;
+ unsigned graphmode : 1;
+ unsigned curshid : 1;
/* geometry */
int rows, cols;
- int scrolltop, scrollbottom;
- RoteCell **cells;
+
+ mtty_row_t *lines;
+ mtty_row_t *scroll_top;
+ mtty_row_t *scroll_bot;
/* cursor */
- attr_t curattrs;
- int curs_row, curs_col;
+ unsigned curattrs;
+ mtty_row_t *curs_row;
+ int curs_col;
int curs_srow, curs_scol;
- char esbuf[ESEQ_BUF_SIZE];
- int esbuf_len;
+ /* buffers and parsing state */
+ mbstate_t ps;
+ char rbuf[BUFSIZ];
+ char ebuf[BUFSIZ];
+ int rlen, elen;
} madtty_t;
void madtty_initialize(void);
void madtty_destroy(madtty_t *rt);
pid_t madtty_forkpty(madtty_t *rt, const char *path, const char *argv[]);
-int madtty_read(madtty_t *rt, char *buf, int buflen);
-int madtty_write(madtty_t *rt, const char *data, int length);
-
-int madtty_inject(madtty_t *rt, const char *data, int length);
+int madtty_process(madtty_t *rt);
+void madtty_keypress(madtty_t *rt, int keycode);
void madtty_draw(madtty_t *rt, WINDOW *win, int startrow, int startcol);
-void madtty_keypress(madtty_t *rt, int keycode);
#endif /* MADTTY_MADTTY_H */