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)) |
223,26 → 249,48 |
} |
} |
|
static void draw_text_data(keyfield_t *data) |
/** Draw text data to viewport. |
* |
* @param vport Viewport id |
* @param data Text data. |
* @param x Leftmost column of the area. |
* @param y Topmost row of the area. |
* @param w Number of rows. |
* @param h Number of columns. |
*/ |
static void draw_text_data(keyfield_t *data, unsigned int x, |
unsigned int y, unsigned int w, unsigned int h) |
{ |
int i, j; |
unsigned int i, j; |
keyfield_t *field; |
attrs_t *a0, *a1; |
|
serial_goto(0, 0); |
serial_goto(y, x); |
a0 = &data[0].attrs; |
serial_set_attrs(a0); |
|
for (i = 0; i < scr_height; i++) { |
for (j = 0; j < scr_width; j++) { |
a1 = &data[i * scr_width + j].attrs; |
for (j = 0; j < h; j++) { |
if (j > 0 && w != scr_width) |
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)(data[i * scr_width + j].character); |
serial_putchar(field->character); |
a0 = a1; |
} |
} |
} |
|
int lastcol = 0; |
int lastrow = 0; |
|
/** |
* Main function of the thread serving client connections. |
*/ |
254,11 → 302,8 |
keyfield_t *interbuf = NULL; |
size_t intersize = 0; |
|
char c; |
int lastcol = 0; |
int lastrow = 0; |
int newcol; |
int newrow; |
wchar_t c; |
int col, row, w, h; |
int fgcolor; |
int bgcolor; |
int flags; |
299,30 → 344,40 |
retval = EINVAL; |
break; |
case FB_DRAW_TEXT_DATA: |
col = IPC_GET_ARG1(call); |
row = IPC_GET_ARG2(call); |
w = IPC_GET_ARG3(call); |
h = IPC_GET_ARG4(call); |
if (!interbuf) { |
retval = EINVAL; |
break; |
} |
draw_text_data(interbuf); |
if (col + w > scr_width || row + h > scr_height) { |
retval = EINVAL; |
break; |
} |
draw_text_data(interbuf, col, row, w, h); |
lastrow = row + h - 1; |
lastcol = col + w; |
retval = 0; |
break; |
case FB_PUTCHAR: |
c = IPC_GET_ARG1(call); |
newrow = IPC_GET_ARG2(call); |
newcol = IPC_GET_ARG3(call); |
if ((lastcol != newcol) || (lastrow != newrow)) |
serial_goto(newrow, newcol); |
lastcol = newcol + 1; |
lastrow = newrow; |
(*putc_function)(c); |
row = IPC_GET_ARG2(call); |
col = IPC_GET_ARG3(call); |
if ((lastcol != col) || (lastrow != row)) |
serial_goto(row, col); |
lastcol = col + 1; |
lastrow = row; |
serial_putchar(c); |
retval = 0; |
break; |
case FB_CURSOR_GOTO: |
newrow = IPC_GET_ARG1(call); |
newcol = IPC_GET_ARG2(call); |
serial_goto(newrow, newcol); |
lastrow = newrow; |
lastcol = newcol; |
row = IPC_GET_ARG1(call); |
col = IPC_GET_ARG2(call); |
serial_goto(row, col); |
lastrow = row; |
lastcol = col; |
retval = 0; |
break; |
case FB_GET_CSIZE: |