about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2022-02-18 23:39:46 -0500
committerJune McEnroe <june@causal.agency>2022-02-18 23:39:46 -0500
commit573bc855a68766f38de2acb48bebc9d0adbf0a1f (patch)
tree18e2ffa24eba70eaf239987e242d21557b73fecb
parentFix M-f ordering (diff)
downloadcatgirl-573bc855a68766f38de2acb48bebc9d0adbf0a1f.tar.gz
catgirl-573bc855a68766f38de2acb48bebc9d0adbf0a1f.zip
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.
Diffstat (limited to '')
-rw-r--r--ui.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/ui.c b/ui.c
index 369ed75..3df0cd6 100644
--- a/ui.c
+++ b/ui.c
@@ -791,6 +791,7 @@ static void inputUpdate(void) {
 		skip = buf;
 	}
 
+	int y, x;
 	wmove(input, 0, 0);
 	if (window->time && window->id != Network) {
 		whline(input, ' ', uiTime.width);
@@ -800,25 +801,24 @@ static void inputUpdate(void) {
 	waddstr(input, prefix);
 	waddstr(input, prompt);
 	waddstr(input, suffix);
+	getyx(input, y, x);
 
-	int y, x;
-	const char *ptr = skip;
+	int posx;
 	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);
-	if (split && split >= pos) {
+	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]);
 		style = styleInput;
 		style.bg = Red;
 	}
 	inputAdd(styleInput, &style, ptr);
 	wclrtoeol(input);
-	wmove(input, y, x);
+	wmove(input, y, posx);
 }
 
 void uiWindows(void) {
June McEnroe 2019-09-12Only GET the final redirect locationJune McEnroe 2019-09-12Consume entire bodyJune McEnroe 2019-09-10Add title -v flagJune McEnroe 2019-09-10Use curl error bufferJune McEnroe 2019-09-10Set Accept-Encoding in titleJune McEnroe 2019-09-08Set title User-AgentJune McEnroe 2019-09-07Add -x flag to titleJune McEnroe 2019-09-07Ignore SIGPIPE in relayJune McEnroe 2019-09-07Add A Memory Called EmpireJune McEnroe 2019-09-05Handle lack of Content-TypeJune McEnroe 2019-09-05Use CURLINFO_CONTENT_TYPEJune McEnroe 2019-09-05Decode entities in titlesJune McEnroe 2019-09-05Print title as soon as it's availableJune McEnroe 2019-09-05Use CURL_PREFIX to set flagsJune McEnroe 2019-09-05Add titleJune McEnroe 2019-09-04Add Avorter n'est pas tuerJune McEnroe 2019-08-29Unset executable on shell scriptsJune McEnroe 2019-08-29Add long-missing setopt to bin.7June McEnroe 2019-08-29Add editJune McEnroe