This commit is contained in:
cinap_lenrek 2020-01-19 19:21:10 +01:00
commit 09eac381e5
6 changed files with 41 additions and 19 deletions

View file

@ -112,7 +112,7 @@ void
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 @@ colclose(Column *c, Window *w, int dofree)
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 @@ colclose(Column *c, Window *w, int dofree)
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

View file

@ -546,6 +546,7 @@ char wdir[];
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) */

View file

@ -147,6 +147,8 @@ execute(Text *t, uint aq0, uint aq1, int external, Text *argt)
}
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;

View file

@ -19,10 +19,11 @@ void undo(Text*, Text*, Text*, int, int, Rune*, int);
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*);

View file

@ -367,12 +367,18 @@ savemouse(Window *w)
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

View file

@ -90,20 +90,23 @@ wininit(Window *w, Window *clone, Rectangle r)
}
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 @@ movetodel(Window *w)
{
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 @@ wintaglines(Window *w, Rectangle r)
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);