53,10 → 53,12 |
#define MAX_CONTROL 20 |
|
static void serial_sgr(const unsigned int mode); |
void serial_putchar(wchar_t ch); |
|
static int scr_width; |
static int scr_height; |
static bool color = true; /** True if producing color output. */ |
static bool utf8 = false; /** True if producing UTF8 output. */ |
static putc_function_t putc_function; |
|
/* Allow only 1 connection */ |
102,6 → 104,30 |
putc_function(*(str++)); |
} |
|
void serial_putchar(wchar_t ch) |
{ |
uint8_t buf[STR_BOUNDS(1)]; |
size_t offs; |
size_t i; |
|
if (utf8 != true) { |
if (ch >= 0 && ch < 128) |
(*putc_function)((uint8_t) ch); |
else |
(*putc_function)('?'); |
return; |
} |
|
offs = 0; |
if (chr_encode(ch, buf, &offs, STR_BOUNDS(1)) == EOK) { |
for (i = 0; i < offs; i++) |
(*putc_function)(buf[i]); |
} else { |
(*putc_function)('?'); |
} |
|
} |
|
void serial_goto(const unsigned int row, const unsigned int col) |
{ |
if ((row > scr_height) || (col > scr_width)) |
248,15 → 274,12 |
serial_goto(y, x); |
|
for (i = 0; i < w; i++) { |
unsigned int col = x + i; |
unsigned int row = y + j; |
|
field = &data[j * w + i]; |
|
a1 = &field->attrs; |
if (!attrs_same(*a0, *a1)) |
serial_set_attrs(a1); |
(*putc_function)(field->character); |
serial_putchar(field->character); |
a0 = a1; |
} |
} |
276,14 → 299,11 |
keyfield_t *interbuf = NULL; |
size_t intersize = 0; |
|
char c; |
wchar_t c; |
int col, row, w, h; |
int fgcolor; |
int bgcolor; |
int flags; |
int style; |
int i; |
|
attrs_t cur_attr; |
|
if (client_connected) { |
ipc_answer_0(iid, ELIMIT); |
292,6 → 312,9 |
|
client_connected = 1; |
ipc_answer_0(iid, EOK); |
|
cur_attr.t = at_style; |
cur_attr.a.s.style = STYLE_NORMAL; |
|
/* Clear the terminal, set scrolling region |
to 0 - height rows. */ |
343,7 → 366,7 |
serial_goto(row, col); |
lastcol = col + 1; |
lastrow = row; |
(*putc_function)(c); |
serial_putchar(c); |
retval = 0; |
break; |
case FB_CURSOR_GOTO: |
362,23 → 385,28 |
retval = 0; |
break; |
case FB_SET_STYLE: |
style = IPC_GET_ARG1(call); |
serial_set_style(style); |
cur_attr.t = at_style; |
cur_attr.a.s.style = IPC_GET_ARG1(call); |
cur_attr.a.i.bg_color = IPC_GET_ARG2(call); |
serial_set_attrs(&cur_attr); |
|
retval = 0; |
break; |
case FB_SET_COLOR: |
fgcolor = IPC_GET_ARG1(call); |
bgcolor = IPC_GET_ARG2(call); |
flags = IPC_GET_ARG3(call); |
cur_attr.t = at_idx; |
cur_attr.a.i.fg_color = IPC_GET_ARG1(call); |
cur_attr.a.i.bg_color = IPC_GET_ARG2(call); |
cur_attr.a.i.flags = IPC_GET_ARG3(call); |
serial_set_attrs(&cur_attr); |
|
serial_set_idx(fgcolor, bgcolor, flags); |
retval = 0; |
break; |
case FB_SET_RGB_COLOR: |
fgcolor = IPC_GET_ARG1(call); |
bgcolor = IPC_GET_ARG2(call); |
cur_attr.t = at_rgb; |
cur_attr.a.i.fg_color = IPC_GET_ARG1(call); |
cur_attr.a.i.bg_color = IPC_GET_ARG2(call); |
serial_set_attrs(&cur_attr); |
|
serial_set_rgb(fgcolor, bgcolor); |
retval = 0; |
break; |
case FB_SCROLL: |
398,6 → 426,18 |
serial_cursor_disable(); |
retval = 0; |
break; |
case FB_SCREEN_YIELD: |
serial_sgr(SGR_RESET); |
serial_puts("\033[2J"); |
serial_goto(0, 0); |
serial_cursor_enable(); |
retval = 0; |
break; |
case FB_SCREEN_RECLAIM: |
serial_clrscr(); |
serial_set_attrs(&cur_attr); |
retval = 0; |
break; |
default: |
retval = ENOENT; |
} |