shithub: rio

Download patch

ref: 16fa1b770d30c19f55a6a87c453124eea53d7d8e
parent: 9424b0f9d5937d4c792961d60928c8000df001c7
author: glenda <glenda@cirno>
date: Sun Mar 23 16:30:41 EDT 2025

hitting enter anywhere in the line puts you at the end (unixy)

--- a/wind.c
+++ b/wind.c
@@ -1167,19 +1167,29 @@
 		}
 		return;
 	}
+	
+	if(r == '\n') {
+		/* qh: queue head - beginning of user input */
+		p0 = w->qh;
+		q0 = w->q0; 
+	
+		q1 = q0;
+		while(q1 > p0 && (w->r[q1-1] == ' ' || w->r[q1-1] == '\t'))
+			q1--;
+	
+		if(q1 > p0)
+			waddhistory(w, w->r + p0, q1 - p0);
+		
+		while(q0 < w->nr)
+			q0++;
+		wsetselect(w, q0, q0);
+		wshow(w, w->q0);
+	}
+	
 	/* otherwise ordinary character; just insert */
 	q0 = w->q0;
 	q0 = winsert(w, &r, 1, q0);
 	wshow(w, q0+1);
-	
-	if(r == '\n') {
-		p0 = q0;
-		while(p0 > 0 && w->r[p0-1] != '\n')
-			p0--;
-			
-		if(q0 > p0)
-			waddhistory(w, w->r + p0, q0 - p0);
-	}
 }
 
 static Window	*clickwin;