mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-02 01:08:32 +00:00
Fix linenoise flickering on CTRL+L
This commit is contained in:
parent
701564de19
commit
4e7ce1538c
1 changed files with 13 additions and 5 deletions
18
third_party/linenoise/linenoise.c
vendored
18
third_party/linenoise/linenoise.c
vendored
|
@ -1090,7 +1090,8 @@ static int linenoiseMirror(struct linenoiseState *l, unsigned res[2]) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void linenoiseRefreshLineImpl(struct linenoiseState *l, int force) {
|
static void linenoiseRefreshLineImpl(struct linenoiseState *l, int force,
|
||||||
|
const char *prefix) {
|
||||||
char *hint;
|
char *hint;
|
||||||
char flipit;
|
char flipit;
|
||||||
char hasflip;
|
char hasflip;
|
||||||
|
@ -1184,6 +1185,10 @@ StartOver:
|
||||||
cx = -1;
|
cx = -1;
|
||||||
rows = 1;
|
rows = 1;
|
||||||
abInit(&ab);
|
abInit(&ab);
|
||||||
|
if (prefix) {
|
||||||
|
// to prevent flicker with ctrl+l
|
||||||
|
abAppends(&ab, prefix);
|
||||||
|
}
|
||||||
abAppendw(&ab, '\r'); /* start of line */
|
abAppendw(&ab, '\r'); /* start of line */
|
||||||
if (l->rows - l->oldpos - 1 > 0) {
|
if (l->rows - l->oldpos - 1 > 0) {
|
||||||
abAppends(&ab, "\e[");
|
abAppends(&ab, "\e[");
|
||||||
|
@ -1278,13 +1283,13 @@ StartOver:
|
||||||
|
|
||||||
void linenoiseRefreshLine(struct linenoiseState *l) {
|
void linenoiseRefreshLine(struct linenoiseState *l) {
|
||||||
--__strace;
|
--__strace;
|
||||||
linenoiseRefreshLineImpl(l, 0);
|
linenoiseRefreshLineImpl(l, 0, 0);
|
||||||
++__strace;
|
++__strace;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void linenoiseRefreshLineForce(struct linenoiseState *l) {
|
static void linenoiseRefreshLineForce(struct linenoiseState *l) {
|
||||||
--__strace;
|
--__strace;
|
||||||
linenoiseRefreshLineImpl(l, 1);
|
linenoiseRefreshLineImpl(l, 1, 0);
|
||||||
++__strace;
|
++__strace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1327,8 +1332,11 @@ static void linenoiseEditEof(struct linenoiseState *l) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void linenoiseEditRefresh(struct linenoiseState *l) {
|
static void linenoiseEditRefresh(struct linenoiseState *l) {
|
||||||
linenoiseClearScreen(l->ofd);
|
--__strace;
|
||||||
linenoiseRefreshLine(l);
|
linenoiseRefreshLineImpl(l, 1,
|
||||||
|
"\e[H" // move cursor to top left corner
|
||||||
|
"\e[2J"); // erase display
|
||||||
|
++__strace;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t ForwardWord(struct linenoiseState *l, size_t pos) {
|
static size_t ForwardWord(struct linenoiseState *l, size_t pos) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue