X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=madtty%2Fmadtty.c;h=b876a732c455ae2d962783cb90d93abef9943927;hb=f624c13a046e879c373e1a2927089e4f2fc8c059;hp=317712c147756556deca45b2eb9abe76151c8536;hpb=c50afdbb8673cc2becc273935b05833c0b06daf2;p=apps%2Fmadtty.git diff --git a/madtty/madtty.c b/madtty/madtty.c index 317712c..b876a73 100644 --- a/madtty/madtty.c +++ b/madtty/madtty.c @@ -106,6 +106,8 @@ struct madtty_t { char rbuf[BUFSIZ]; char ebuf[BUFSIZ]; int rlen, elen; + madtty_handler_t handler; + void *data; }; typedef struct t_row_t { @@ -597,11 +599,17 @@ static void es_interpret_csi(madtty_t *t) static void try_interpret_escape_seq(madtty_t *t) { char lastchar = t->ebuf[t->elen-1]; - + if(!*t->ebuf) + return; + if(t->handler){ + switch((*(t->handler))(t, t->ebuf)){ + case MADTTY_HANDLER_OK: + goto cancel; + case MADTTY_HANDLER_NOTYET: + return; + } + } switch (*t->ebuf) { - case '\0': - return; - case 'M': interpret_csi_SR(t); cancel_escape_sequence(t); @@ -730,13 +738,15 @@ void madtty_init_vt100_graphics(void) vt100['f' - 0x41] = ACS_DEGREE; vt100['g' - 0x41] = ACS_PLMINUS; vt100['~' - 0x41] = ACS_BULLET; +#if 0 /* out of bounds */ vt100[',' - 0x41] = ACS_LARROW; vt100['+' - 0x41] = ACS_RARROW; vt100['.' - 0x41] = ACS_DARROW; vt100['-' - 0x41] = ACS_UARROW; + vt100['0' - 0x41] = ACS_BLOCK; +#endif vt100['h' - 0x41] = ACS_BOARD; vt100['i' - 0x41] = ACS_LANTERN; - vt100['0' - 0x41] = ACS_BLOCK; /* these defaults were invented for ncurses */ vt100['p' - 0x41] = ACS_S3; vt100['r' - 0x41] = ACS_S7; @@ -1083,3 +1093,18 @@ int madtty_color_pair(int fg, int bg) bg = COLOR_BLACK; return COLOR_PAIR((7 - fg) * 8 + bg); } + +void madtty_set_handler(madtty_t *t, madtty_handler_t handler) +{ + t->handler = handler; +} + +void madtty_set_data(madtty_t *t, void *data) +{ + t->data = data; +} + +void *madtty_get_data(madtty_t *t) +{ + return t->data; +}