diff --git a/kitty/data-types.h b/kitty/data-types.h index 307460f72..eb80e5104 100644 --- a/kitty/data-types.h +++ b/kitty/data-types.h @@ -296,6 +296,7 @@ void linebuf_set_attribute(LineBuf *, unsigned int , unsigned int ); void screen_restore_cursor(Screen *); void screen_save_cursor(Screen *); void screen_cursor_position(Screen*, unsigned int, unsigned int); +void screen_cursor_back(Screen *self, unsigned int count/*=1*/, int move_direction/*=-1*/); void screen_erase_in_display(Screen *, unsigned int, bool); void screen_draw(Screen *screen, uint8_t *buf, unsigned int buflen); void screen_ensure_bounds(Screen *self, bool use_margins); diff --git a/kitty/screen.c b/kitty/screen.c index a7665e9f4..65e259929 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -170,19 +170,30 @@ void screen_draw(Screen *self, uint8_t *buf, unsigned int buflen) { // }}} void screen_backspace(Screen UNUSED *self, uint8_t UNUSED ch) { - // TODO: Implement this + screen_cursor_back(self, 1, -1); } void screen_tab(Screen UNUSED *self, uint8_t UNUSED ch) { - // TODO: Implement this + // Move to the next tab space, or the end of the screen if there aren't anymore left. + unsigned int found = 0; + for (unsigned int i = self->cursor->x + 1; i < self->columns; i++) { + if (self->tabstops[i]) { found = i; break; } + } + if (!found) found = self->columns - 1; + if (found != (unsigned int)self->cursor->x) { + self->cursor->x = found; + tracker_cursor_changed(self->change_tracker); + } } void screen_shift_out(Screen UNUSED *self, uint8_t UNUSED ch) { - // TODO: Implement this + self->current_charset = 1; + self->utf8_state = 0; } void screen_shift_in(Screen UNUSED *self, uint8_t UNUSED ch) { - // TODO: Implement this + self->current_charset = 0; + self->utf8_state = 0; } // Graphics {{{