Add support for legacy DECSET codes 47, 1047 and 1048

Fixes #2871
This commit is contained in:
Kovid Goyal 2020-07-22 09:00:51 +05:30
parent dc4762a69a
commit 1af426bf84
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 21 additions and 9 deletions

View File

@ -56,6 +56,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- Have the :opt:`confirm_os_window_close` option also apply when closing tabs
with multiple windows (:iss:`2857`)
- Add support for legacy DECSET codes 47, 1047 and 1048 (:pull:`2871`)
0.18.1 [2020-06-23]
--------------------

View File

@ -67,7 +67,12 @@
#define MOUSE_SGR_MODE (1006 << 5)
#define MOUSE_URXVT_MODE (1015 << 5)
// Save cursor (DECSC)
#define SAVE_CURSOR (1048 << 5)
// Alternate screen buffer
#define TOGGLE_ALT_SCREEN_1 (47 << 5)
#define TOGGLE_ALT_SCREEN_2 (1047 << 5)
#define ALTERNATE_SCREEN (1049 << 5)
// Bracketed paste mode

View File

@ -137,7 +137,7 @@ static inline Line* range_line_(Screen *self, int y);
void
screen_reset(Screen *self) {
if (self->linebuf == self->alt_linebuf) screen_toggle_screen_buffer(self);
if (self->linebuf == self->alt_linebuf) screen_toggle_screen_buffer(self, true, true);
if (self->overlay_line.is_active) deactivate_overlay_line(self);
linebuf_clear(self->linebuf, BLANK_CHAR);
historybuf_clear(self->historybuf);
@ -641,12 +641,12 @@ screen_handle_graphics_command(Screen *self, const GraphicsCommand *cmd, const u
void
screen_toggle_screen_buffer(Screen *self) {
screen_toggle_screen_buffer(Screen *self, bool save_cursor, bool clear_alt_screen) {
bool to_alt = self->linebuf == self->main_linebuf;
grman_clear(self->alt_grman, true, self->cell_size); // always clear the alt buffer graphics to free up resources, since it has to be cleared when switching back to it anyway
if (to_alt) {
linebuf_clear(self->alt_linebuf, BLANK_CHAR);
screen_save_cursor(self);
if (clear_alt_screen) linebuf_clear(self->alt_linebuf, BLANK_CHAR);
if (save_cursor) screen_save_cursor(self);
self->linebuf = self->alt_linebuf;
self->tabstops = self->alt_tabstops;
self->grman = self->alt_grman;
@ -655,7 +655,7 @@ screen_toggle_screen_buffer(Screen *self) {
} else {
self->linebuf = self->main_linebuf;
self->tabstops = self->main_tabstops;
screen_restore_cursor(self);
if (save_cursor) screen_restore_cursor(self);
self->grman = self->main_grman;
}
screen_history_scroll(self, SCROLL_FULL, false);
@ -727,9 +727,14 @@ set_mode_from_const(Screen *self, unsigned int mode, bool val) {
case CONTROL_CURSOR_BLINK:
self->cursor->blink = val;
break;
case SAVE_CURSOR:
screen_save_cursor(self);
break;
case TOGGLE_ALT_SCREEN_1:
case TOGGLE_ALT_SCREEN_2:
case ALTERNATE_SCREEN:
if (val && self->linebuf == self->main_linebuf) screen_toggle_screen_buffer(self);
else if (!val && self->linebuf != self->main_linebuf) screen_toggle_screen_buffer(self);
if (val && self->linebuf == self->main_linebuf) screen_toggle_screen_buffer(self, mode == ALTERNATE_SCREEN, mode == ALTERNATE_SCREEN);
else if (!val && self->linebuf != self->main_linebuf) screen_toggle_screen_buffer(self, mode == ALTERNATE_SCREEN, mode == ALTERNATE_SCREEN);
break;
default:
private = mode >= 1 << 5;
@ -2394,7 +2399,7 @@ is_main_linebuf(Screen *self, PyObject *a UNUSED) {
static PyObject*
toggle_alt_screen(Screen *self, PyObject *a UNUSED) {
screen_toggle_screen_buffer(self);
screen_toggle_screen_buffer(self, true, true);
Py_RETURN_NONE;
}

View File

@ -138,7 +138,7 @@ void screen_erase_in_line(Screen *, unsigned int, bool);
void screen_erase_in_display(Screen *, unsigned int, bool);
void screen_draw(Screen *screen, uint32_t codepoint);
void screen_ensure_bounds(Screen *self, bool use_margins, bool cursor_was_within_margins);
void screen_toggle_screen_buffer(Screen *self);
void screen_toggle_screen_buffer(Screen *self, bool, bool);
void screen_normal_keypad_mode(Screen *self);
void screen_alternate_keypad_mode(Screen *self);
void screen_change_default_color(Screen *self, unsigned int which, uint32_t col);