shithub: riscv

Download patch

ref: 47bae09b33f677b9e1f5b45190ec5216f5d988e0
parent: b099753597d2c3b3d150c686df5c16310168477e
author: Roberto E. Vargas Caballero <[email protected]>
date: Sun Jan 19 14:18:12 EST 2020

Apply http://www.9paste.net/qrstuv/patch/acme-movetodelmesg/

--- a/sys/src/cmd/acme/dat.h
+++ b/sys/src/cmd/acme/dat.h
@@ -546,6 +546,7 @@
 int			editing;
 int			messagesize;		/* negotiated in 9P version setup */
 int			globalindent[NINDENT];
+Rune		*delcmd;			/* what command deleted the window. eg, Del, Delete, Delmesg */
 
 Channel	*cplumb;		/* chan(Plumbmsg*) */
 Channel	*cwait;		/* chan(Waitmsg) */
--- a/sys/src/cmd/acme/exec.c
+++ b/sys/src/cmd/acme/exec.c
@@ -147,6 +147,8 @@
 	}
 	r = runemalloc(q1-q0);
 	bufread(t->file, q0, r, q1-q0);
+	free(delcmd);
+	delcmd = runesmprint("%.*S", q1-q0, r);
 	e = lookup(r, q1-q0);
 	if(!external && t->w!=nil && t->w->nopen[QWevent]>0){
 		f = 0;
--- a/sys/src/cmd/acme/wind.c
+++ b/sys/src/cmd/acme/wind.c
@@ -90,20 +90,23 @@
 }
 
 int
-delrunepos(Window *w)
+tagrunepos(Window *w, Rune *s)
 {
 	int n;
-	Rune rune;
-	
-	for(n=0; n<w->tag.file->nc; n++) {
-		bufread(w->tag.file, n, &rune, 1);
-		if(rune == ' ')
-			break;
-	}
-	n += 2;
-	if(n >= w->tag.file->nc)
+	Rune *r, *rr;
+
+	if(s == nil)
 		return -1;
-	return n;
+
+	n = w->tag.file->nc;
+	r = runemalloc(n+1);
+	bufread(w->tag.file, 0, r, n);
+	r[n] = L'\0';
+
+	rr = runestrstr(r, s);
+	if(rr == nil || rr == r)
+		return -1;
+	return rr - r;
 }
 
 void
@@ -111,7 +114,9 @@
 {
 	int n;
 	
-	n = delrunepos(w);
+	n = tagrunepos(w, delcmd);
+	free(delcmd);
+	delcmd = nil;
 	if(n < 0)
 		return;
 	moveto(mousectl, addpt(frptofchar(&w->tag, n), Pt(4, w->tag.font->height-4)));
@@ -138,7 +143,7 @@
 	
 	if(!w->tagexpand) {
 		/* use just as many lines as needed to show the Del */
-		n = delrunepos(w);
+		n = tagrunepos(w, delcmd);
 		if(n < 0)
 			return 1;
 		p = subpt(frptofchar(&w->tag, n), w->tag.r.min);