getout = 1;
}
-int my_custom_handler(RoteTerm *rt __attribute__((unused)), const char *es)
-{
- int color;
- int i, j;
-
- /* if the escape sequence does not begin with '{', we give up */
- if (*es != '{') return ROTE_HANDLERESULT_NOWAY;
-
- /* ok, now we know it begins with '{'. Now, if it does not end with '}',
- * it is not yet complete */
- if (es[strlen(es)-1] != '}') return ROTE_HANDLERESULT_NOTYET;
-
- /* ok, the sequence is complete */
- color = atoi(es + 1);
- if (color < 0 || color > 7) return false; /* don't recognize it */
-
- /* paint the background with that color */
- attrset(COLOR_PAIR(color * 8));
- move(0, 0);
- for (i = 0; i < screen_h; i++) for (j = 0; j < screen_w; j++) addch(' ');
- touchwin(stdscr);
- refresh();
-
- /* touch term_win to force it to do a full redraw next time */
- touchwin(term_win);
-
- /* and redraw the terminal window */
- wrefresh(term_win);
-
- /* escape sequence was handled ok */
- return ROTE_HANDLERESULT_OK;
-}
-
int main(int argc, char *argv[])
{
RoteTerm *rt;
rt = rote_vt_create(h, w);
rote_vt_forkpty(rt, "/bin/bash --login");
- /* add a sample custom escape sequence handler... say we want to handle
- * the sequence, say, \e{N}, which will change the application's background
- * color to N (where N is a number between 0 and 7). */
- rote_vt_install_handler(rt, my_custom_handler);
-
/* keep reading keypresses from the user and passing them to the terminal;
* also, redraw the terminal to the window at each iteration */
ch = '\0';