shithub: rio

Download patch

ref: bf83ddaa4e469d1093830536ecb985b7ac0a6148
parent: b46f16f38d2d94063f90331238d6104c612bbcb2
author: glenda <glenda@cirno>
date: Sun Mar 23 15:53:29 EDT 2025

added ctrl left/right word by word navigation

--- a/dat.h
+++ b/dat.h
@@ -351,4 +351,5 @@
 int		snarfversion;	/* updated each time it is written */
 int		messagesize;		/* negotiated in 9P version setup */
 int		shiftdown;
+int		ctrldown;
 int		debug;
--- a/rio.c
+++ b/rio.c
@@ -371,8 +371,10 @@
 	for(;;){
 		switch(alt(alts)){
 		case Akbd:
-			if(*s == 'k' || *s == 'K')
+			if(*s == 'k' || *s == 'K'){
 				shiftdown = utfrune(s+1, Kshift) != nil;
+				ctrldown = utfrune(s+1, Kctl) != nil;
+			}
 			if(totap == nil)
 				goto Bypass;
 			if(input != nil && input != cur){	/* context change */
--- a/wind.c
+++ b/wind.c
@@ -1046,7 +1046,15 @@
 			wsetorigin(w, q0, TRUE);
 			return;
 		case Kleft:
-			if(w->q0 > 0){
+			if(ctrldown){  /* Word-by-word movement using ctrl key */
+				q0 = w->q0;
+				while(q0 > 0 && !isalnum(w->r[q0-1]))
+					q0--;
+				while(q0 > 0 && isalnum(w->r[q0-1]))
+					q0--;
+				wsetselect(w, q0, q0);
+				wshow(w, q0);
+			}else if(w->q0 > 0){
 				q0 = w->q0-1;
 				wsetselect(w, q0, q0);
 				wshow(w, q0);
@@ -1053,7 +1061,15 @@
 			}
 			return;
 		case Kright:
-			if(w->q1 < w->nr){
+			if(ctrldown){
+				q0 = w->q0;
+				while(q0 < w->nr && !isalnum(w->r[q0]))
+					q0++;
+				while(q0 < w->nr && isalnum(w->r[q0]))
+					q0++;
+				wsetselect(w, q0, q0);
+				wshow(w, q0);
+			}else if(w->q1 < w->nr){
 				q1 = w->q1+1;
 				wsetselect(w, q1, q1);
 				wshow(w, q1);
@@ -1517,7 +1533,6 @@
 		return 0;
 	if(i < 0) {
 		fprint(2, "rio: negative ref count in wclose\n");
-		i = 0;
 	}
 	
 	already_closing = w;