From 375583259adf5e2401b97d0159a10f089760dd5f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 18 Feb 2025 20:21:07 +0530 Subject: [PATCH] Fix --hold always restoring cursor to block shape instead of respecting the value of cursor_shape --- docs/changelog.rst | 2 ++ kitty/vt-parser.c | 1 + kitty/window.py | 7 +++++++ tools/tui/run.go | 6 ++---- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 7d94510e8..9510db74d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -133,6 +133,8 @@ Detailed list of changes - Fix a regression in 0.39.0 that caused a crash on invalid Unicode with a large number of combining characters in a single cell (:iss:`8318`) +- Fix ``--hold`` always restoring cursor to block shape instead of respecting the value of :opt:`cursor_shape` (:disc:`8344`) + 0.39.1 [2025-02-01] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/vt-parser.c b/kitty/vt-parser.c index 1dfba77d7..8b968faf3 100644 --- a/kitty/vt-parser.c +++ b/kitty/vt-parser.c @@ -618,6 +618,7 @@ parse_kitty_dcs(PS *self, uint8_t *buf, size_t bufsz) { dispatch("ask|", handle_remote_askpass, 0) dispatch("clone|", handle_remote_clone, 0) dispatch("edit|", handle_remote_edit, 0) + dispatch("restore-cursor-appearance|", handle_restore_cursor_appearance, 0) return false; #undef dispatch diff --git a/kitty/window.py b/kitty/window.py index aa79c1f9f..2ddcc977e 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -1524,6 +1524,13 @@ class Window: text = process_remote_print(msg) print(text, end='', flush=True) + def handle_restore_cursor_appearance(self, msg: memoryview | None = None) -> None: + opts = get_options() + self.screen.cursor.blink = opts.cursor_blink_interval[0] != 0 + self.screen.cursor.shape = opts.cursor_shape + self.screen.cursor_visible = True + delattr(self.screen.color_profile, 'cursor_color') + def send_cmd_response(self, response: Any) -> None: self.screen.send_escape_code_to_child(ESC_DCS, '@kitty-cmd' + json.dumps(response)) diff --git a/tools/tui/run.go b/tools/tui/run.go index e05a1dbb4..659e094e4 100644 --- a/tools/tui/run.go +++ b/tools/tui/run.go @@ -222,10 +222,8 @@ func RunCommandRestoringTerminalToSaneStateAfter(cmd []string) { defer func() { _, _ = term.WriteString(strings.Join([]string{ loop.RESTORE_PRIVATE_MODE_VALUES, - "\x1b[=u", // reset kitty keyboard protocol to legacy - "\x1b[1 q", // blinking block cursor - loop.DECTCEM.EscapeCodeToSet(), // cursor visible - "\x1b]112\a", // reset cursor color + "\x1b[=u", // reset kitty keyboard protocol to legacy + "\x1bP@kitty-restore-cursor-appearance|\a", }, "")) _ = term.Tcsetattr(tty.TCSANOW, &state_before) term.Close()