mirror of
https://github.com/janet-lang/janet
synced 2025-12-11 19:18:07 +00:00
shell: Prevent buggy moving zero column behavior
According to https://unix.stackexchange.com/a/559331, moving zero column is implemented inconsistently between different terminal emulators. In order to fix this inconsistency, we avoid using this escape sequence entirely. Signed-off-by: Tw <tw19881113@gmail.com> Change-Id: I73d4252f8472c769f0cf98b6bbdf2b3d6a6a6964
This commit is contained in:
@@ -379,10 +379,12 @@ static void refresh(void) {
|
|||||||
janet_buffer_push_cstring(&b, gbl_prompt);
|
janet_buffer_push_cstring(&b, gbl_prompt);
|
||||||
janet_buffer_push_bytes(&b, (uint8_t *) _buf, _len);
|
janet_buffer_push_bytes(&b, (uint8_t *) _buf, _len);
|
||||||
/* Erase to right */
|
/* Erase to right */
|
||||||
janet_buffer_push_cstring(&b, "\x1b[0K");
|
janet_buffer_push_cstring(&b, "\x1b[0K\r");
|
||||||
/* Move cursor to original position. */
|
/* Move cursor to original position. */
|
||||||
snprintf(seq, 64, "\r\x1b[%dC", (int)(_pos + gbl_plen));
|
if (_pos + gbl_plen) {
|
||||||
janet_buffer_push_cstring(&b, seq);
|
snprintf(seq, 64, "\x1b[%dC", (int)(_pos + gbl_plen));
|
||||||
|
janet_buffer_push_cstring(&b, seq);
|
||||||
|
}
|
||||||
if (write_console((char *) b.data, b.count) == -1) {
|
if (write_console((char *) b.data, b.count) == -1) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user