Rev 4211 | Rev 4325 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4211 | Rev 4235 | ||
|---|---|---|---|
| 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 102... | Line 104... | ||
| 102 | putc_function(*(str++)); |
104 | putc_function(*(str++)); |
| 103 | } |
105 | } |
| 104 | 106 | ||
| 105 | void serial_putchar(wchar_t ch) |
107 | void serial_putchar(wchar_t ch) |
| 106 | { |
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 { |
|
| 107 | (*putc_function)(ch); |
126 | (*putc_function)('?'); |
| - | 127 | } |
|
| - | 128 | ||
| 108 | } |
129 | } |
| 109 | 130 | ||
| 110 | void serial_goto(const unsigned int row, const unsigned int col) |
131 | void serial_goto(const unsigned int row, const unsigned int col) |
| 111 | { |
132 | { |
| 112 | if ((row > scr_height) || (col > scr_width)) |
133 | if ((row > scr_height) || (col > scr_width)) |