|
8 | 8 |
|
9 | 9 | #include "shared-module/fontio/BuiltinFont.h"
|
10 | 10 | #include "shared-bindings/displayio/TileGrid.h"
|
| 11 | +#include "shared-bindings/displayio/Palette.h" |
11 | 12 | #include "shared-bindings/terminalio/Terminal.h"
|
12 | 13 |
|
13 | 14 | #if CIRCUITPY_STATUS_BAR
|
@@ -46,6 +47,22 @@ size_t common_hal_terminalio_terminal_write(terminalio_terminal_obj_t *self, con
|
46 | 47 | return len;
|
47 | 48 | }
|
48 | 49 |
|
| 50 | + uint32_t _select_color(uint16_t ascii_color) { |
| 51 | + uint32_t color_value = 0; |
| 52 | + if ((ascii_color & 1) > 0) { |
| 53 | + color_value += 0xff0000; |
| 54 | + } |
| 55 | + if ((ascii_color & 2) > 0) { |
| 56 | + color_value += 0x00ff00; |
| 57 | + } |
| 58 | + if ((ascii_color & 4) > 0) { |
| 59 | + color_value += 0x0000ff; |
| 60 | + } |
| 61 | + |
| 62 | + return color_value; |
| 63 | + } |
| 64 | + |
| 65 | + displayio_palette_t *terminal_palette = self->scroll_area->pixel_shader; |
49 | 66 | const byte *i = data;
|
50 | 67 | uint16_t start_y = self->cursor_y;
|
51 | 68 | while (i < data + len) {
|
@@ -127,6 +144,15 @@ size_t common_hal_terminalio_terminal_write(terminalio_terminal_obj_t *self, con
|
127 | 144 | common_hal_displayio_tilegrid_set_all_tiles(self->scroll_area, 0);
|
128 | 145 | }
|
129 | 146 | }
|
| 147 | + if (c == 'm') { |
| 148 | + if ((n >= 40 && n <= 47) || (n >= 30 && n <= 37)) { |
| 149 | + common_hal_displayio_palette_set_color(terminal_palette, 1 - (n / 40), _select_color(n % 10)); |
| 150 | + } |
| 151 | + if (n == 0) { |
| 152 | + common_hal_displayio_palette_set_color(terminal_palette, 0, 0x000000); |
| 153 | + common_hal_displayio_palette_set_color(terminal_palette, 1, 0xffffff); |
| 154 | + } |
| 155 | + } |
130 | 156 | if (c == ';') {
|
131 | 157 | uint16_t m = 0;
|
132 | 158 | for (++j; j < 9; j++) {
|
@@ -155,6 +181,22 @@ size_t common_hal_terminalio_terminal_write(terminalio_terminal_obj_t *self, con
|
155 | 181 | self->cursor_y = n;
|
156 | 182 | start_y = self->cursor_y;
|
157 | 183 | }
|
| 184 | + if (c == 'm') { |
| 185 | + if ((n >= 40 && n <= 47) || (n >= 30 && n <= 37)) { |
| 186 | + common_hal_displayio_palette_set_color(terminal_palette, 1 - (n / 40), _select_color(n % 10)); |
| 187 | + } |
| 188 | + if (n == 0) { |
| 189 | + common_hal_displayio_palette_set_color(terminal_palette, 0, 0x000000); |
| 190 | + common_hal_displayio_palette_set_color(terminal_palette, 1, 0xffffff); |
| 191 | + } |
| 192 | + if ((m >= 40 && m <= 47) || (m >= 30 && m <= 37)) { |
| 193 | + common_hal_displayio_palette_set_color(terminal_palette, 1 - (m / 40), _select_color(m % 10)); |
| 194 | + } |
| 195 | + if (m == 0) { |
| 196 | + common_hal_displayio_palette_set_color(terminal_palette, 0, 0x000000); |
| 197 | + common_hal_displayio_palette_set_color(terminal_palette, 1, 0xffffff); |
| 198 | + } |
| 199 | + } |
158 | 200 | }
|
159 | 201 | i += j + 1;
|
160 | 202 | continue;
|
|
0 commit comments