40,6 → 40,8 |
/* Allow only 1 connection */ |
static int client_connected = 0; |
|
#define CLRSCR "\033[2J" |
|
static void sysput(char c) |
{ |
__SYSCALL3(SYS_IO, 1, (sysarg_t)&c, (sysarg_t) 1); |
50,18 → 52,11 |
__SYSCALL3(SYS_IO, 1, (sysarg_t)s, strlen(s)); |
} |
|
/** Send clearscreen sequence to console */ |
static void clrscr(void) |
{ |
sysputs("\033[2J"); |
} |
|
/** Send ansi sequence to console to change cursor position */ |
static void curs_goto(unsigned int row, unsigned int col) |
{ |
char control[20]; |
|
if (row > 200 || col > 200) |
if (row > 100 || col > 100) |
return; |
|
snprintf(control, 20, "\033[%d;%df",row, col); |
68,7 → 63,6 |
sysputs(control); |
} |
|
/** ANSI terminal emulation main thread */ |
static void sysio_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
{ |
int retval; |
112,7 → 106,7 |
ipc_answer_fast(callid, 0, 25, 80); |
continue; |
case FB_CLEAR: |
clrscr(); |
sysputs(CLRSCR); |
retval = 0; |
break; |
default: |
122,10 → 116,9 |
} |
} |
|
/** ANSI terminal emulation initialization */ |
void sysio_init(void) |
{ |
async_set_client_connection(sysio_client_connection); |
clrscr(); |
sysputs(CLRSCR); |
curs_goto(0,0); |
} |