4 unsigned short _COLS = 80;
5 unsigned short _LINES = 25;
7 static void ansiscr_init ( struct _curses_screen *scr __unused ) {
8 /* Reset terminal attributes and clear screen */
9 printf ( "\033[0m\033[2J" );
12 static void ansiscr_exit ( struct _curses_screen *scr __unused ) {
15 static void ansiscr_movetoyx ( struct _curses_screen *scr __unused,
16 unsigned int y, unsigned int x ) {
17 /* ANSI escape sequence to update cursor position */
18 printf ( "\033[%d;%dH", ( y + 1 ), ( x + 1 ) );
21 static void ansiscr_putc ( struct _curses_screen *scr, chtype c ) {
22 unsigned int character = ( c & A_CHARTEXT );
23 attr_t attrs = ( c & ( A_ATTRIBUTES | A_COLOR ) );
24 int bold = ( attrs & A_BOLD );
25 attr_t cpair = PAIR_NUMBER ( attrs );
29 if ( attrs != scr->attrs ) {
31 pair_content ( cpair, &fcol, &bcol );
32 /* ANSI escape sequence to update character attributes */
33 printf ( "\033[0;%d;3%d;4%dm", ( bold ? 1 : 22 ), fcol, bcol );
35 putchar ( character );
38 static int ansiscr_getc ( struct _curses_screen *scr __unused ) {
42 static bool ansiscr_peek ( struct _curses_screen *scr __unused ) {
46 SCREEN _ansi_screen = {
49 .movetoyx = ansiscr_movetoyx,