ref: 09eac381e58e74051ab7ddb1e96fc32671d3cada
parent: 16f11e4cd6a925d10aaef1416bbe2d8874618f74
parent: 47bae09b33f677b9e1f5b45190ec5216f5d988e0
author: cinap_lenrek <[email protected]>
date: Sun Jan 19 14:21:10 EST 2020
merge
--- a/sys/src/cmd/acme/cols.c
+++ b/sys/src/cmd/acme/cols.c
@@ -112,7 +112,7 @@
colclose(Column *c, Window *w, int dofree)
{
Rectangle r;
- int i;
+ int i, didmouse, up;
/* w is locked */
if(!c->safe)
@@ -126,7 +126,7 @@
w->tag.col = nil;
w->body.col = nil;
w->col = nil;
- restoremouse(w);
+ didmouse = restoremouse(w);
if(dofree){
windelete(w);
winclose(w);
@@ -138,17 +138,24 @@
draw(screen, r, display->white, nil, ZP);
return;
}
+ up = 0;
if(i == c->nw){ /* extend last window down */
w = c->w[i-1];
r.min.y = w->r.min.y;
r.max.y = c->r.max.y;
}else{ /* extend next window up */
+ up = 1;
w = c->w[i];
r.max.y = w->r.max.y;
}
draw(screen, r, textcols[BACK], nil, ZP);
- if(c->safe)
+ if(c->safe) {
+ if(!didmouse && up)
+ w->showdel = TRUE;
winresize(w, r, FALSE);
+ if(!didmouse && up)
+ movetodel(w);
+ }
}
void
--- 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/fns.h
+++ b/sys/src/cmd/acme/fns.h
@@ -19,10 +19,11 @@
char* getname(Text*, Text*, Rune*, int, int);
void scrsleep(uint);
void savemouse(Window*);
-void restoremouse(Window*);
+int restoremouse(Window*);
void clearmouse(void);
void allwindows(void(*)(Window*, void*), void*);
uint loadfile(int, uint, int*, int(*)(void*, uint, Rune*, int), void*);
+void movetodel(Window*);
Window* errorwin(Mntdir*, int);
Window* errorwinforwin(Window*);
--- a/sys/src/cmd/acme/util.c
+++ b/sys/src/cmd/acme/util.c
@@ -367,12 +367,18 @@
mousew = w;
}
-void
+int
restoremouse(Window *w)
{
- if(mousew!=nil && mousew==w)
+ int did;
+
+ did = 0;
+ if(mousew!=nil && mousew==w) {
moveto(mousectl, prevmouse);
+ did = 1;
+ }
mousew = nil;
+ return did;
}
void
--- 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);