From rsc by way of quanstro: "from russ. if a window is deleted with Del in the tag, and a new window is moved in to replace it, then warp the mouse to Del. this facilliates the common case of deleting a bunch of windows at the same time. the theory is that the random pointer location in the newly moved window wouldn't be useful anyway." Reference: /n/sources/patch/applied/acme-warp Date: Mon Aug 12 09:29:33 CES 2013 Signed-off-by: sstallion@gmail.com --- /sys/src/cmd/acme/cols.c Mon Aug 12 09:29:05 2013 +++ /sys/src/cmd/acme/cols.c Mon Aug 12 09:29:02 2013 @@ -111,7 +111,7 @@ colclose(Column *c, Window *w, int dofree) { Rectangle r; - int i; + int i, didmouse, up; /* w is locked */ if(!c->safe) @@ -125,7 +125,7 @@ w->tag.col = nil; w->body.col = nil; w->col = nil; - restoremouse(w); + didmouse = restoremouse(w); if(dofree){ windelete(w); winclose(w); @@ -137,6 +137,7 @@ 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; @@ -144,10 +145,15 @@ }else{ /* extend next window up */ w = c->w[i]; r.max.y = w->r.max.y; + up = 1; } draw(screen, r, textcols[BACK], nil, ZP); - if(c->safe) + if(c->safe){ winresize(w, r, FALSE); + USED(up); + if(!didmouse) + movetodel(w); + } } void --- /sys/src/cmd/acme/fns.h Mon Aug 12 09:29:08 2013 +++ /sys/src/cmd/acme/fns.h Mon Aug 12 09:29:06 2013 @@ -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*); --- /sys/src/cmd/acme/util.c Mon Aug 12 09:29:12 2013 +++ /sys/src/cmd/acme/util.c Mon Aug 12 09:29:10 2013 @@ -366,12 +366,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 --- /sys/src/cmd/acme/wind.c Mon Aug 12 09:29:17 2013 +++ /sys/src/cmd/acme/wind.c Mon Aug 12 09:29:14 2013 @@ -84,6 +84,34 @@ } int +delrunepos(Window *w) +{ + int n; + Rune rune; + + for(n=0; ntag.file->nc; n++) { + bufread(w->tag.file, n, &rune, 1); + if(rune == ' ') + break; + } + n += 2; + if(n >= w->tag.file->nc) + return -1; + return n; +} + +void +movetodel(Window *w) +{ + int n; + + n = delrunepos(w); + if(n < 0) + return; + moveto(mousectl, addpt(frptofchar(&w->tag, n), Pt(4, w->tag.font->height-4))); +} + +int winresize(Window *w, Rectangle r, int safe) { Rectangle r1;