aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/acme/wind.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2012-09-23 22:01:56 -0400
committerRuss Cox <rsc@swtch.com>2012-09-23 22:01:56 -0400
commit37f8ed2410ad5cbd46eda00a77f8bf4950bcf544 (patch)
tree9b95f2c2cb48cc00cfeefb6fdceb228cd7daa2bf /src/cmd/acme/wind.c
parent9dbe4a0df903ee76bf72fcaff43dea5bb5bf3f75 (diff)
downloadplan9port-37f8ed2410ad5cbd46eda00a77f8bf4950bcf544.tar.gz
plan9port-37f8ed2410ad5cbd46eda00a77f8bf4950bcf544.tar.bz2
plan9port-37f8ed2410ad5cbd46eda00a77f8bf4950bcf544.zip
acme: mouse movement for Del
If the mouse was in the tag of the old window, it was most likely pointing at Del. If bringing up a new window from below and not moving the mouse somewhere else, adjust it so that it ends up pointing at Del in the replacement window's tag too. This makes it easy to Del a sequence of windows in a column, from top to bottom. http://www.youtube.com/watch?v=ET8w6RT6u5M R=r http://codereview.appspot.com/6558047
Diffstat (limited to 'src/cmd/acme/wind.c')
-rw-r--r--src/cmd/acme/wind.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c
index bfe4beca..378c3ccb 100644
--- a/src/cmd/acme/wind.c
+++ b/src/cmd/acme/wind.c
@@ -106,6 +106,34 @@ windrawbutton(Window *w)
draw(screen, br, b, nil, b->r.min);
}
+int
+delrunepos(Window *w)
+{
+ int n;
+ Rune rune;
+
+ for(n=0; n<w->tag.file->b.nc; n++) {
+ bufread(&w->tag.file->b, n, &rune, 1);
+ if(rune == ' ')
+ break;
+ }
+ n += 2;
+ if(n >= w->tag.file->b.nc)
+ return -1;
+ return n;
+}
+
+void
+movetodel(Window *w)
+{
+ int n;
+
+ n = delrunepos(w);
+ if(n < 0)
+ return;
+ moveto(mousectl, addpt(frptofchar(&w->tag.fr, n), Pt(4, w->tag.fr.font->height-4)));
+}
+
/*
* Compute number of tag lines required
* to display entire tag text.
@@ -115,14 +143,25 @@ wintaglines(Window *w, Rectangle r)
{
int n;
Rune rune;
+ Point p;
- if(!w->tagexpand)
+ if(!w->tagexpand && !w->showdel)
return 1;
+ w->showdel = FALSE;
w->tag.fr.noredraw = 1;
textresize(&w->tag, r, TRUE);
w->tag.fr.noredraw = 0;
w->tagsafe = FALSE;
+ if(!w->tagexpand) {
+ /* use just as many lines as needed to show the Del */
+ n = delrunepos(w);
+ if(n < 0)
+ return 1;
+ p = subpt(frptofchar(&w->tag.fr, n), w->tag.fr.r.min);
+ return 1 + p.y / w->tag.fr.font->height;
+ }
+
/* can't use more than we have */
if(w->tag.fr.nlines >= w->tag.fr.maxlines)
return w->tag.fr.maxlines;