Simplify cursor positioning in input
Do some extra work by adding the portion before the cursor to the input window twice, but simplify the interaction with the split point. This fixes the awkward behaviour when moving the cursor across colour codes where the code would be partially interpreted up to the cursor.master
parent
0036e6e9f0
commit
573bc855a6
24
ui.c
24
ui.c
|
@ -791,6 +791,7 @@ static void inputUpdate(void) {
|
||||||
skip = buf;
|
skip = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int y, x;
|
||||||
wmove(input, 0, 0);
|
wmove(input, 0, 0);
|
||||||
if (window->time && window->id != Network) {
|
if (window->time && window->id != Network) {
|
||||||
whline(input, ' ', uiTime.width);
|
whline(input, ' ', uiTime.width);
|
||||||
|
@ -800,25 +801,24 @@ static void inputUpdate(void) {
|
||||||
waddstr(input, prefix);
|
waddstr(input, prefix);
|
||||||
waddstr(input, prompt);
|
waddstr(input, prompt);
|
||||||
waddstr(input, suffix);
|
waddstr(input, suffix);
|
||||||
|
|
||||||
int y, x;
|
|
||||||
const char *ptr = skip;
|
|
||||||
struct Style style = styleInput;
|
|
||||||
if (split && split < pos) {
|
|
||||||
ptr = inputStop(styleInput, &style, ptr, &buf[split]);
|
|
||||||
style = styleInput;
|
|
||||||
style.bg = Red;
|
|
||||||
}
|
|
||||||
ptr = inputStop(styleInput, &style, ptr, &buf[pos]);
|
|
||||||
getyx(input, y, x);
|
getyx(input, y, x);
|
||||||
if (split && split >= pos) {
|
|
||||||
|
int posx;
|
||||||
|
struct Style style = styleInput;
|
||||||
|
inputStop(styleInput, &style, skip, &buf[pos]);
|
||||||
|
getyx(input, y, posx);
|
||||||
|
wmove(input, y, x);
|
||||||
|
|
||||||
|
style = styleInput;
|
||||||
|
const char *ptr = skip;
|
||||||
|
if (split) {
|
||||||
ptr = inputStop(styleInput, &style, ptr, &buf[split]);
|
ptr = inputStop(styleInput, &style, ptr, &buf[split]);
|
||||||
style = styleInput;
|
style = styleInput;
|
||||||
style.bg = Red;
|
style.bg = Red;
|
||||||
}
|
}
|
||||||
inputAdd(styleInput, &style, ptr);
|
inputAdd(styleInput, &style, ptr);
|
||||||
wclrtoeol(input);
|
wclrtoeol(input);
|
||||||
wmove(input, y, x);
|
wmove(input, y, posx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiWindows(void) {
|
void uiWindows(void) {
|
||||||
|
|
Loading…
Reference in New Issue