@@ -93,6 +93,41 @@ size_t common_hal_terminalio_terminal_write(terminalio_terminal_obj_t *self, con
93
93
self -> cursor_x -= n ;
94
94
}
95
95
}
96
+ if (c == 'J' ) {
97
+ if (n == 2 ) {
98
+ common_hal_displayio_tilegrid_set_top_left (self -> tilegrid , 0 , 0 );
99
+ self -> cursor_x = self -> cursor_y = start_y = 0 ;
100
+ n = 0 ;
101
+ for (uint16_t x = 0 ; x < self -> tilegrid -> width_in_tiles ; x ++ ) {
102
+ for (uint16_t y = 0 ; y < self -> tilegrid -> height_in_tiles ; y ++ ) {
103
+ common_hal_displayio_tilegrid_set_tile (self -> tilegrid , x , y , 0 );
104
+ }
105
+ }
106
+ }
107
+ }
108
+ if (c == ';' ) {
109
+ int16_t m = 0 ;
110
+ for (++ j ; j < 9 ; j ++ ) {
111
+ if ('0' <= i [j ] && i [j ] <= '9' ) {
112
+ m = m * 10 + (i [j ] - '0' );
113
+ } else {
114
+ c = i [j ];
115
+ break ;
116
+ }
117
+ }
118
+ if (c == 'H' ) {
119
+ if (n >= self -> tilegrid -> height_in_tiles ) {
120
+ n = self -> tilegrid -> height_in_tiles - 1 ;
121
+ }
122
+ if (m >= self -> tilegrid -> width_in_tiles ) {
123
+ m = self -> tilegrid -> width_in_tiles - 1 ;
124
+ }
125
+ n = (n + self -> tilegrid -> top_left_y ) % self -> tilegrid -> height_in_tiles ;
126
+ self -> cursor_x = m ;
127
+ self -> cursor_y = n ;
128
+ start_y = self -> cursor_y ;
129
+ }
130
+ }
96
131
i += j + 1 ;
97
132
continue ;
98
133
}
@@ -114,12 +149,14 @@ size_t common_hal_terminalio_terminal_write(terminalio_terminal_obj_t *self, con
114
149
self -> cursor_y %= self -> tilegrid -> height_in_tiles ;
115
150
}
116
151
if (self -> cursor_y != start_y ) {
117
- // clear the new row
118
- for (uint16_t j = 0 ; j < self -> tilegrid -> width_in_tiles ; j ++ ) {
119
- common_hal_displayio_tilegrid_set_tile (self -> tilegrid , j , self -> cursor_y , 0 );
120
- start_y = self -> cursor_y ;
152
+ // clear the new row in case of scroll up
153
+ if (self -> cursor_y == self -> tilegrid -> top_left_y ) {
154
+ for (uint16_t j = 0 ; j < self -> tilegrid -> width_in_tiles ; j ++ ) {
155
+ common_hal_displayio_tilegrid_set_tile (self -> tilegrid , j , self -> cursor_y , 0 );
156
+ }
157
+ common_hal_displayio_tilegrid_set_top_left (self -> tilegrid , 0 , (self -> cursor_y + self -> tilegrid -> height_in_tiles + 1 ) % self -> tilegrid -> height_in_tiles );
121
158
}
122
- common_hal_displayio_tilegrid_set_top_left ( self -> tilegrid , 0 , ( start_y + self -> tilegrid -> height_in_tiles + 1 ) % self -> tilegrid -> height_in_tiles ) ;
159
+ start_y = self -> cursor_y ;
123
160
}
124
161
}
125
162
return i - data ;
0 commit comments