shithub: acme

Download patch

ref: 93ce62ad568ce0c0b0506aadbc764f1cbf9fb232
parent: cee187b311103063517ed23457c70549b4cab244
author: glenda <glenda@cirno>
date: Sun Apr 6 05:44:56 EDT 2025

handle some global hotkeys outside texttype, simplify (and make work properly) alt+enter for a new win */
.

--- a/acme.c
+++ b/acme.c
@@ -367,6 +367,27 @@
 	}
 }
 
+/* some hotkeys are better handled outside texttype
+ * eg, don't apply to a particular window, or 
+ * interfere with control flow (ie del). */
+int
+globalmod(Rune r)
+{
+	switch(r){
+	case 0x04:
+		if(activewin)
+			del(&activewin->body, nil, nil, 0, 0, nil, 0);
+		return TRUE;
+	case '\n':
+		if(altdown){
+			run(nil, "win", nil, 0, TRUE, nil, 0, FALSE);
+		}
+		return TRUE;
+	}
+	
+	return FALSE;
+}
+
 void
 keyboardthread(void *)
 {
@@ -419,7 +440,10 @@
 				bp = s + 1;
 				chartorune(&r, bp);
 				
-				typetext = rowtype(&row, r, mouse->xy);
+				if(globalmod(r))
+					typetext = nil;
+				else
+					typetext = rowtype(&row, r, mouse->xy);
 				t = typetext;
 				if(t!=nil && t->col!=nil && !(r==Kdown || r==Kleft || r==Kright))
 					activecol = t->col;
--- a/fns.h
+++ b/fns.h
@@ -5,6 +5,7 @@
 #define	fbufalloc()	emalloc(BUFSIZE)
 #define	fbuffree(x)	free(x)
 
+void	del(Text*, Text*, Text*, int, int, Rune*, int);
 void	putall(Text*, Text*, Text*, int, int, Rune*, int);
 void	plumblook(Plumbmsg*m);
 void	plumbshow(Plumbmsg*m);
--- a/text.c
+++ b/text.c
@@ -922,12 +922,7 @@
 		}
 		break;
 	case '\n':
-		if(altdown){
-			/* TODO: Make this work even with no window selected */
-			Runestr dir = dirname(t, nil, 0);
-			run(nil, "win", dir.r, dir.nr, TRUE, nil, 0, FALSE);
-		}
-		else if(t->what == Body && t->w->indent[AUTOINDENT]){
+		if(t->what == Body && t->w->indent[AUTOINDENT]){
 			/* find beginning of previous line using backspace code */
 			nnb = textbswidth(t, 0x15); /* ^U case */
 			rp = runemalloc(nnb + 1);
--