gcc says those values are out of bounds
[apps/madtty.git] / madtty / madtty.h
index c7e2a82..2859bfe 100644 (file)
 #include <unistd.h>
 #include <wchar.h>
 
-#define MAX_CSI_ES_PARAMS 32
-
-typedef struct mtty_row_t mtty_row_t;
-
-typedef struct {
-    int   pty;
-    pid_t childpid;
-
-    /* flags */
-    unsigned seen_input : 1;
-    unsigned insert     : 1;
-    unsigned escaped    : 1;
-    unsigned graphmode  : 1;
-    unsigned curshid    : 1;
-
-    /* geometry */
-    int rows, cols;
-
-    mtty_row_t *lines;
-    mtty_row_t *scroll_top;
-    mtty_row_t *scroll_bot;
-
-    /* cursor */
-    unsigned curattrs;
-    mtty_row_t *curs_row;
-    int curs_col;
-    int curs_srow, curs_scol;
-
-    /* buffers and parsing state */
-    mbstate_t ps;
-    char rbuf[BUFSIZ];
-    char ebuf[BUFSIZ];
-    int  rlen, elen;
-} madtty_t;
-
-void madtty_initialize(void);
+enum {
+    /* means escape sequence was handled */
+    MADTTY_HANDLER_OK,
+    /* means the escape sequence was not  recognized yet, but
+     * there is hope that it still will once more characters
+     * arrive (i.e. it is not yet complete).
+     *
+     * The library will thus continue collecting characters
+     * and calling the handler as each character arrives until
+     * either OK or NOWAY is returned.
+     */
+    MADTTY_HANDLER_NOTYET,
+    /* means the escape sequence was not recognized, and there
+     * is no chance that it will even if more characters  are
+     * added to it.
+     */
+    MADTTY_HANDLER_NOWAY
+};
+
+typedef struct madtty_t madtty_t;
+typedef int (*madtty_handler_t)(madtty_t *, char *es);
+
+void madtty_init_colors(void);
+void madtty_init_vt100_graphics(void);
+void madtty_set_handler(madtty_t *, madtty_handler_t);
+void madtty_set_data(madtty_t *, void *);
+void *madtty_get_data(madtty_t *);
+int madtty_color_pair(int fg, int bg);
 
 madtty_t *madtty_create(int rows, int cols);
-void madtty_destroy(madtty_t *rt);
-pid_t madtty_forkpty(madtty_t *rt, const char *path, const char *argv[]);
-
-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_resize(madtty_t *, int rows, int cols);
+void madtty_destroy(madtty_t *);
+pid_t madtty_forkpty(madtty_t *, const char *, const char *argv[], int *pty);
+int madtty_getpty(madtty_t *);
+
+int madtty_process(madtty_t *);
+void madtty_keypress(madtty_t *, int keycode);
+void madtty_draw(madtty_t *, WINDOW *win, int startrow, int startcol);
 
 #endif /* MADTTY_MADTTY_H */