Add support for the color settings stack that XTerm copied from us without acknowledgement and decided to use incompatible escape codes for.

Completely in keeping with that project's past behavior.
See https://github.com/kovidgoyal/kitty/issues/879

XTerm announcement:
https://www.mail-archive.com/xorg@lists.x.org/msg06419.html
This commit is contained in:
Kovid Goyal
2020-12-21 21:39:05 +05:30
parent e97f1a4310
commit 5f8dee8384
10 changed files with 120 additions and 29 deletions

View File

@@ -20,7 +20,8 @@ SAVE_CURSOR = '\0337'
RESTORE_CURSOR = '\0338'
SAVE_PRIVATE_MODE_VALUES = '\033[?s'
RESTORE_PRIVATE_MODE_VALUES = '\033[?r'
SAVE_COLORS = '\033[#P'
RESTORE_COLORS = '\033[#Q'
MODES = dict(
LNM=(20, ''),
IRM=(4, ''),
@@ -270,7 +271,7 @@ def init_state(alternate_screen: bool = True) -> str:
reset_mode('FOCUS_TRACKING') + reset_mode('MOUSE_UTF8_MODE') +
reset_mode('MOUSE_SGR_MODE') + reset_mode('MOUSE_UTF8_MODE') +
set_mode('BRACKETED_PASTE') + set_mode('EXTENDED_KEYBOARD') +
'\033]30001\033\\' +
SAVE_COLORS +
'\033[*x' # reset DECSACE to default region select
)
if alternate_screen:
@@ -285,7 +286,7 @@ def reset_state(normal_screen: bool = True) -> str:
ans += reset_mode('ALTERNATE_SCREEN')
ans += RESTORE_PRIVATE_MODE_VALUES
ans += RESTORE_CURSOR
ans += '\033]30101\033\\'
ans += RESTORE_COLORS
return ans