diff --git a/kitty/screen.c b/kitty/screen.c index c641c7b4f..0fa76ee05 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -157,7 +157,7 @@ screen_reset(Screen *self) { memset(self->main_key_encoding_flags, 0, sizeof(self->main_key_encoding_flags)); memset(self->alt_key_encoding_flags, 0, sizeof(self->alt_key_encoding_flags)); self->display_window_number = 0; - self->redraws_multiline_prompts = false; + self->prompt_redraw_settings.val = 0; self->last_graphic_char = 0; self->main_savepoint.is_valid = false; self->alt_savepoint.is_valid = false; @@ -284,6 +284,7 @@ index_selection(const Screen *self, Selections *selections, bool up) { static void prevent_current_prompt_from_rewrapping(Screen *self) { + if (!self->prompt_redraw_settings.redraws_prompts_at_all) return; int y = self->cursor->y; while (y >= 0) { linebuf_init_line(self->main_linebuf, y); @@ -293,7 +294,7 @@ prevent_current_prompt_from_rewrapping(Screen *self) { y--; } if (y < 0) return; - if (!self->redraws_multiline_prompts && self->cursor->y > (unsigned) y) return; // bash does not redraw multiline prompts + if (!self->prompt_redraw_settings.redraws_multiline_prompts && self->cursor->y > (unsigned) y) return; // bash does not redraw multiline prompts // we have identified a prompt at which the cursor is present, the shell // will redraw this prompt. However when doing so it gets confused if the // cursor vertical position relative to the first prompt line changes. This @@ -1917,10 +1918,15 @@ shell_prompt_marking(Screen *self, PyObject *data) { case 'A': { linebuf_mark_line_as_prompt_start(self->linebuf, self->cursor->y); size_t l = PyUnicode_GET_LENGTH(data); + self->prompt_redraw_settings.redraws_multiline_prompts = 1; + self->prompt_redraw_settings.redraws_prompts_at_all = 1; if (l > 8) { - DECREF_AFTER_FUNCTION PyObject *q = PyUnicode_FromString(";does_not_redraw_multiline_prompt"); - self->redraws_multiline_prompts = (!q || PyUnicode_Find(data, q, 1, PyUnicode_GET_LENGTH(data), 1) < 0); - } else self->redraws_multiline_prompts = true; + const char *buf = PyUnicode_AsUTF8(data); + if (buf) { + if (strstr(buf, ";does_not_redraw_multiline_prompt")) self->prompt_redraw_settings.redraws_multiline_prompts = 0; + if (strstr(buf, ";does_not_redraw_prompts")) self->prompt_redraw_settings.redraws_prompts_at_all = 0; + } + } } break; case 'C': linebuf_mark_line_as_output_start(self->linebuf, self->cursor->y); break; diff --git a/kitty/screen.h b/kitty/screen.h index b184dcb4e..7da632552 100644 --- a/kitty/screen.h +++ b/kitty/screen.h @@ -131,7 +131,13 @@ typedef struct { struct { monotonic_t start, duration; } ignore_bells; - bool redraws_multiline_prompts; + union { + struct { + unsigned int redraws_multiline_prompts: 1; + unsigned int redraws_prompts_at_all: 1; + }; + unsigned int val; + } prompt_redraw_settings; unsigned int display_window_number; } Screen; diff --git a/kitty/shell.py b/kitty/shell.py index e5151d476..4e6d6b907 100644 --- a/kitty/shell.py +++ b/kitty/shell.py @@ -172,13 +172,14 @@ def real_main(global_opts: RCOptions) -> None: print('The ID of the previously active window is: {}'.format(awid)) pre_prompt = set_window_title('The kitty shell') + set_cursor_shape('bar') - pre_prompt += '\x1b]133;A\x1b\\' + pre_prompt += '\x1b]133;A;does_not_redraw_prompts\x1b\\' while True: try: + print(end=pre_prompt) try: - scmdline = input(f'{pre_prompt}{kitty_face} ') + scmdline = input(f'{kitty_face} ') except UnicodeEncodeError: - scmdline = input('{pre_prompt}kitty> ') + scmdline = input('kitty> ') except EOFError: break except KeyboardInterrupt: