shithub: orca

Download patch

ref: 0decdf5c1bb865f6f22ac6688af96301329d09f8
parent: 66d3b7346eedfa77fa0ece2ac8ad0c5924b6e545
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu Feb 13 15:19:10 EST 2020

plan9: uppercase/lowercase shortcuts

--- a/plan9.c
+++ b/plan9.c
@@ -50,7 +50,7 @@
 static char filename[256];
 static Channel *cchan;
 static Field copyfield;
-static int altdown, slide;
+static int altdown, ctldown, slide;
 static long framedev; /* frame deviation >= 1µs */
 
 static char *menu3i[] = {
@@ -425,6 +425,18 @@
 }
 
 static void
+selmap(int (*f)(int))
+{
+	int x, y;
+
+	for (y = cury; y < cury+selh && y < field.height; y++) {
+		for (x = curx; x < curx+selw && x < field.width; x++) {
+			field.buffer[x + field.width*y] = f(field.buffer[x + field.width*y]);
+		}
+	}
+}
+
+static void
 screensize(int *w, int *h)
 {
 	*w = (Dx(screen->r) - 2*Txtoff) / charw;
@@ -605,6 +617,9 @@
 			case Kalt:
 				altdown = key.down;
 				break;
+			case Kctl:
+				ctldown = key.down;
+				break;
 			}
 			break;
 
@@ -644,6 +659,10 @@
 				}
 				break;
 			case 0x0c: /* C-l */
+				if (shiftdown) {
+					selmap(tolower);
+					break;
+				}
 			case Kright:
 				if (shiftdown)
 					selw++;
@@ -719,6 +738,10 @@
 			case '`':
 			case '~':
 				slide = !slide;
+				break;
+			case Knack: /* C-u */
+				if (shiftdown)
+					selmap(toupper);
 				break;
 			case ' ':
 				if (insert) {