Rev 4201 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4201 | Rev 4296 | ||
---|---|---|---|
Line 51... | Line 51... | ||
51 | #include "serial_console.h" |
51 | #include "serial_console.h" |
52 | 52 | ||
53 | #define MAX_CONTROL 20 |
53 | #define MAX_CONTROL 20 |
54 | 54 | ||
55 | static void serial_sgr(const unsigned int mode); |
55 | static void serial_sgr(const unsigned int mode); |
- | 56 | void serial_putchar(wchar_t ch); |
|
56 | 57 | ||
57 | static int scr_width; |
58 | static int scr_width; |
58 | static int scr_height; |
59 | static int scr_height; |
59 | static bool color = true; /** True if producing color output. */ |
60 | static bool color = true; /** True if producing color output. */ |
- | 61 | static bool utf8 = false; /** True if producing UTF8 output. */ |
|
60 | static putc_function_t putc_function; |
62 | static putc_function_t putc_function; |
61 | 63 | ||
62 | /* Allow only 1 connection */ |
64 | /* Allow only 1 connection */ |
63 | static int client_connected = 0; |
65 | static int client_connected = 0; |
64 | 66 | ||
Line 100... | Line 102... | ||
100 | { |
102 | { |
101 | while (*str) |
103 | while (*str) |
102 | putc_function(*(str++)); |
104 | putc_function(*(str++)); |
103 | } |
105 | } |
104 | 106 | ||
- | 107 | void serial_putchar(wchar_t ch) |
|
- | 108 | { |
|
- | 109 | uint8_t buf[STR_BOUNDS(1)]; |
|
- | 110 | size_t offs; |
|
- | 111 | size_t i; |
|
- | 112 | ||
- | 113 | if (utf8 != true) { |
|
- | 114 | if (ch >= 0 && ch < 128) |
|
- | 115 | (*putc_function)((uint8_t) ch); |
|
- | 116 | else |
|
- | 117 | (*putc_function)('?'); |
|
- | 118 | return; |
|
- | 119 | } |
|
- | 120 | ||
- | 121 | offs = 0; |
|
- | 122 | if (chr_encode(ch, buf, &offs, STR_BOUNDS(1)) == EOK) { |
|
- | 123 | for (i = 0; i < offs; i++) |
|
- | 124 | (*putc_function)(buf[i]); |
|
- | 125 | } else { |
|
- | 126 | (*putc_function)('?'); |
|
- | 127 | } |
|
- | 128 | ||
- | 129 | } |
|
- | 130 | ||
105 | void serial_goto(const unsigned int row, const unsigned int col) |
131 | void serial_goto(const unsigned int row, const unsigned int col) |
106 | { |
132 | { |
107 | if ((row > scr_height) || (col > scr_width)) |
133 | if ((row > scr_height) || (col > scr_width)) |
108 | return; |
134 | return; |
109 | 135 | ||
Line 254... | Line 280... | ||
254 | field = &data[j * w + i]; |
280 | field = &data[j * w + i]; |
255 | 281 | ||
256 | a1 = &field->attrs; |
282 | a1 = &field->attrs; |
257 | if (!attrs_same(*a0, *a1)) |
283 | if (!attrs_same(*a0, *a1)) |
258 | serial_set_attrs(a1); |
284 | serial_set_attrs(a1); |
259 | (*putc_function)(field->character); |
285 | serial_putchar(field->character); |
260 | a0 = a1; |
286 | a0 = a1; |
261 | } |
287 | } |
262 | } |
288 | } |
263 | } |
289 | } |
264 | 290 | ||
Line 274... | Line 300... | ||
274 | ipc_callid_t callid; |
300 | ipc_callid_t callid; |
275 | ipc_call_t call; |
301 | ipc_call_t call; |
276 | keyfield_t *interbuf = NULL; |
302 | keyfield_t *interbuf = NULL; |
277 | size_t intersize = 0; |
303 | size_t intersize = 0; |
278 | 304 | ||
279 | char c; |
305 | wchar_t c; |
280 | int col, row, w, h; |
306 | int col, row, w, h; |
281 | int fgcolor; |
307 | int fgcolor; |
282 | int bgcolor; |
308 | int bgcolor; |
283 | int flags; |
309 | int flags; |
284 | int style; |
310 | int style; |
Line 341... | Line 367... | ||
341 | col = IPC_GET_ARG3(call); |
367 | col = IPC_GET_ARG3(call); |
342 | if ((lastcol != col) || (lastrow != row)) |
368 | if ((lastcol != col) || (lastrow != row)) |
343 | serial_goto(row, col); |
369 | serial_goto(row, col); |
344 | lastcol = col + 1; |
370 | lastcol = col + 1; |
345 | lastrow = row; |
371 | lastrow = row; |
346 | (*putc_function)(c); |
372 | serial_putchar(c); |
347 | retval = 0; |
373 | retval = 0; |
348 | break; |
374 | break; |
349 | case FB_CURSOR_GOTO: |
375 | case FB_CURSOR_GOTO: |
350 | row = IPC_GET_ARG1(call); |
376 | row = IPC_GET_ARG1(call); |
351 | col = IPC_GET_ARG2(call); |
377 | col = IPC_GET_ARG2(call); |