@@ -113,6 +113,7 @@ size_t common_hal_terminalio_terminal_write(terminalio_terminal_obj_t *self, con
113
113
// Handle commands of the form [ESC].<digits><command-char> where . is not yet known.
114
114
uint16_t n = 0 ;
115
115
uint8_t j = 1 ;
116
+ uint8_t j2 = 0 ;
116
117
for (; j < 6 ; j ++ ) {
117
118
if ('0' <= i [j ] && i [j ] <= '9' ) {
118
119
n = n * 10 + (i [j ] - '0' );
@@ -128,6 +129,18 @@ size_t common_hal_terminalio_terminal_write(terminalio_terminal_obj_t *self, con
128
129
common_hal_displayio_tilegrid_set_tile (self -> scroll_area , k , self -> cursor_y , 0 );
129
130
}
130
131
i += 2 ;
132
+ } else if (i [1 ] == '?' ) {
133
+ if (i [2 ] == '2' && i [3 ] == '5' ) {
134
+ // cursor visibility commands
135
+ if (i [4 ] == 'h' ) {
136
+ // make cursor visible
137
+ // not implemented yet
138
+ } else if (i [4 ] == 'l' ) {
139
+ // make cursor invisible
140
+ // not implemented yet
141
+ }
142
+ }
143
+ i += 5 ;
131
144
} else {
132
145
if (c == 'D' ) {
133
146
if (n > self -> cursor_x ) {
@@ -153,8 +166,12 @@ size_t common_hal_terminalio_terminal_write(terminalio_terminal_obj_t *self, con
153
166
common_hal_displayio_palette_set_color (terminal_palette , 1 , 0xffffff );
154
167
}
155
168
}
169
+ if (c == 'H' ) {
170
+ self -> cursor_x = self -> cursor_y = start_y = 0 ;
171
+ }
156
172
if (c == ';' ) {
157
173
uint16_t m = 0 ;
174
+ uint8_t m2 = 0 ;
158
175
for (++ j ; j < 9 ; j ++ ) {
159
176
if ('0' <= i [j ] && i [j ] <= '9' ) {
160
177
m = m * 10 + (i [j ] - '0' );
@@ -163,6 +180,16 @@ size_t common_hal_terminalio_terminal_write(terminalio_terminal_obj_t *self, con
163
180
break ;
164
181
}
165
182
}
183
+ if (c == ';' ) {
184
+ for (++ j2 ; j2 < 9 ; j2 ++ ) {
185
+ if ('0' <= i [j2 ] && i [j2 ] <= '9' ) {
186
+ m2 = m2 * 10 + (i [j2 ] - '0' );
187
+ } else {
188
+ c = i [j2 ];
189
+ break ;
190
+ }
191
+ }
192
+ }
166
193
if (c == 'H' ) {
167
194
if (n > 0 ) {
168
195
n -- ;
@@ -196,11 +223,51 @@ size_t common_hal_terminalio_terminal_write(terminalio_terminal_obj_t *self, con
196
223
common_hal_displayio_palette_set_color (terminal_palette , 0 , 0x000000 );
197
224
common_hal_displayio_palette_set_color (terminal_palette , 1 , 0xffffff );
198
225
}
226
+ if ((m2 >= 40 && m2 <= 47 ) || (m2 >= 30 && m2 <= 37 )) {
227
+ common_hal_displayio_palette_set_color (terminal_palette , 1 - (m2 / 40 ), _select_color (m2 % 10 ));
228
+ }
229
+ if (m2 == 0 ) {
230
+ common_hal_displayio_palette_set_color (terminal_palette , 0 , 0x000000 );
231
+ common_hal_displayio_palette_set_color (terminal_palette , 1 , 0xffffff );
232
+ }
199
233
}
200
234
}
201
- i += j + 1 ;
235
+ i += j + j2 + 1 ;
202
236
continue ;
203
237
}
238
+ } else if (i [0 ] == 'M' ) {
239
+ if (self -> cursor_y != self -> scroll_area -> top_left_y ) {
240
+ if (self -> cursor_y > 0 ) {
241
+ self -> cursor_y = self -> cursor_y - 1 ;
242
+ } else {
243
+ self -> cursor_y = self -> scroll_area -> height_in_tiles - 1 ;
244
+ }
245
+ } else {
246
+ if (self -> cursor_y > 0 ) {
247
+ common_hal_displayio_tilegrid_set_top_left (self -> scroll_area , 0 , self -> cursor_y - 1 );
248
+ } else {
249
+ common_hal_displayio_tilegrid_set_top_left (self -> scroll_area , 0 , self -> scroll_area -> height_in_tiles - 1 );
250
+ }
251
+ for (uint8_t icol = 0 ; icol < self -> scroll_area -> width_in_tiles ; icol ++ ) {
252
+ common_hal_displayio_tilegrid_set_tile (self -> scroll_area , icol , self -> scroll_area -> top_left_y , 0 );
253
+ }
254
+
255
+ self -> cursor_x = 0 ;
256
+ self -> cursor_y = self -> scroll_area -> top_left_y ;
257
+ }
258
+ start_y = self -> cursor_y ;
259
+ i ++ ;
260
+ } else if (i [0 ] == 'D' ) {
261
+ self -> cursor_y = (self -> cursor_y + 1 ) % self -> scroll_area -> height_in_tiles ;
262
+ if (self -> cursor_y == self -> scroll_area -> top_left_y ) {
263
+ common_hal_displayio_tilegrid_set_top_left (self -> scroll_area , 0 , (self -> cursor_y + 1 ) % self -> scroll_area -> height_in_tiles );
264
+ for (uint8_t icol = 0 ; icol < self -> scroll_area -> width_in_tiles ; icol ++ ) {
265
+ common_hal_displayio_tilegrid_set_tile (self -> scroll_area , icol , self -> cursor_y , 0 );
266
+ }
267
+ self -> cursor_x = 0 ;
268
+ }
269
+ start_y = self -> cursor_y ;
270
+ i ++ ;
204
271
} else if (i [0 ] == ']' && c == ';' ) {
205
272
self -> in_osc_command = true;
206
273
self -> osc_command = n ;
0 commit comments