aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd/acme/acme.c6
-rw-r--r--src/cmd/acme/cols.c3
-rw-r--r--src/cmd/acme/rows.c11
-rw-r--r--src/cmd/acme/text.c53
-rw-r--r--src/cmd/acme/wind.c25
5 files changed, 96 insertions, 2 deletions
diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c
index 913fadc3..6df7374f 100644
--- a/src/cmd/acme/acme.c
+++ b/src/cmd/acme/acme.c
@@ -591,7 +591,11 @@ mousethread(void *v)
goto Continue;
}
/* scroll buttons, wheels, etc. */
- if(t->what==Body && w != nil && (m.buttons & (8|16))){
+/*
+ * TAG used to require t->what==Body but now allow
+ * scroll wheel in tag too.
+ */
+ if(w != nil && (m.buttons & (8|16))){
if(m.buttons & 8)
but = Kscrolloneup;
else
diff --git a/src/cmd/acme/cols.c b/src/cmd/acme/cols.c
index 487931ec..66883499 100644
--- a/src/cmd/acme/cols.c
+++ b/src/cmd/acme/cols.c
@@ -467,6 +467,9 @@ coldragwin(Column *c, Window *w, int but)
error("can't find window");
Found:
+/* TAG - force recompute tag size (if in auto-expand mode) on mouse op. */
+ w->taglines = 1;
+/* END TAG */
p = mouse->xy;
if(abs(p.x-op.x)<5 && abs(p.y-op.y)<5){
colgrow(c, w, but);
diff --git a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c
index 1808bc4a..fc03c93c 100644
--- a/src/cmd/acme/rows.c
+++ b/src/cmd/acme/rows.c
@@ -282,6 +282,17 @@ rowtype(Row *row, Rune r, Point p)
else{
winlock(w, 'K');
wintype(w, t, r);
+/*
+ * TAG If we typed in the tag, might need to make it
+ * bigger to show text. \n causes tag to expand.
+ */
+ if(t->what == Tag){
+ t->w->tagsafe = FALSE;
+ if(r == '\n')
+ t->w->tagexpand = TRUE;
+ winresize(w, w->r, TRUE, TRUE);
+ }
+/* END TAG */
winunlock(w);
}
}
diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c
index a2ba0265..adde0dd7 100644
--- a/src/cmd/acme/text.c
+++ b/src/cmd/acme/text.c
@@ -646,11 +646,21 @@ texttype(Text *t, Rune r)
uint q0, q1;
int nnb, nb, n, i;
int nr;
+ Point p;
Rune *rp;
Text *u;
- if(t->what!=Body && r=='\n')
+/*
+ * TAG
+ * Used to disallow \n in tag here.
+ * Also if typing in tag, mark that resize might be necessary.
+ */
+ if(t->what!=Body && t->what!=Tag && r=='\n')
return;
+ if(t->what == Tag)
+ t->w->tagsafe = FALSE;
+/* END TAG */
+
nr = 1;
rp = &r;
switch(r){
@@ -667,9 +677,17 @@ texttype(Text *t, Rune r)
}
return;
case Kdown:
+/* TAG */
+ if(t->what == Tag)
+ goto Tagdown;
+/* END TAG */
n = t->fr.maxlines/3;
goto case_Down;
case Kscrollonedown:
+/* TAG */
+ if(t->what == Tag)
+ goto Tagdown;
+/* END TAG */
n = mousescrollsize(t->fr.maxlines);
if(n <= 0)
n = 1;
@@ -681,9 +699,17 @@ texttype(Text *t, Rune r)
textsetorigin(t, q0, TRUE);
return;
case Kup:
+/* TAG */
+ if(t->what == Tag)
+ goto Tagup;
+/* END TAG */
n = t->fr.maxlines/3;
goto case_Up;
case Kscrolloneup:
+/* TAG */
+ if(t->what == Tag)
+ goto Tagup;
+/* END TAG */
n = mousescrollsize(t->fr.maxlines);
goto case_Up;
case Kpgup:
@@ -715,6 +741,31 @@ texttype(Text *t, Rune r)
q0++;
textshow(t, q0, q0, TRUE);
return;
+/* TAG policy here */
+ Tagdown:
+ /* expand tag to show all text */
+ if(!t->w->tagexpand){
+ t->w->tagexpand = TRUE;
+ winresize(t->w, t->w->r, FALSE, TRUE);
+ }
+ return;
+
+ Tagup:
+ /* shrink tag to single line */
+ if(t->w->tagexpand){
+ t->w->tagexpand = FALSE;
+ t->w->taglines = 1;
+ /* move mouse to stay in tag */
+ p = mouse->xy;
+ if(ptinrect(p, t->w->tag.all)
+ && !ptinrect(p, t->w->tagtop)){
+ p.y = t->w->tagtop.min.y + Dy(t->w->tagtop)/2;
+ moveto(mousectl, p);
+ }
+ winresize(t->w, t->w->r, FALSE, TRUE);
+ }
+ return;
+/* END TAG */
}
if(t->what == Body){
seq++;
diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c
index 4fb03ef9..05384601 100644
--- a/src/cmd/acme/wind.c
+++ b/src/cmd/acme/wind.c
@@ -100,17 +100,28 @@ wintaglines(Window *w, Rectangle r)
int n;
Rune rune;
+/* TAG policy here */
+
if(!w->tagexpand)
return 1;
w->tag.fr.noredraw = 1;
textresize(&w->tag, r, TRUE);
w->tag.fr.noredraw = 0;
+
+ /* can't use more than we have */
if(w->tag.fr.nlines >= w->tag.fr.maxlines)
return w->tag.fr.maxlines;
+
+ /* if tag ends with \n, include empty line at end for typing */
n = w->tag.fr.nlines;
bufread(&w->tag.file->b, w->tag.file->b.nc-1, &rune, 1);
if(rune == '\n')
n++;
+
+ /* cannot magically shrink tag - would lose focus */
+ if(n < w->taglines)
+ n = w->taglines;
+
return n;
}
@@ -125,6 +136,19 @@ if(0) fprint(2, "winresize %d %R safe=%d keep=%d h=%d\n", w->id, r, safe, keepex
w->tagtop = r;
w->tagtop.max.y = r.min.y+font->height;
+/*
+ * TAG If necessary, recompute the number of lines that should
+ * be in the tag.
+ */
+ r1 = r;
+ r1.max.y = min(r.max.y, r1.min.y + w->taglines*font->height);
+ y = r1.max.y;
+ if(1 || !safe || !w->tagsafe || !eqrect(w->tag.all, r1)){
+ w->taglines = wintaglines(w, r);
+ w->tagsafe = TRUE;
+ }
+/* END TAG */
+
r1 = r;
r1.max.y = min(r.max.y, r1.min.y + w->taglines*font->height);
y = r1.max.y;
@@ -141,6 +165,7 @@ if(0) fprint(2, "=> %R (%R)\n", w->tag.all, w->tag.fr.r);
br.max.y = br.min.y + Dy(b->r);
draw(screen, br, b, nil, b->r.min);
}
+
r1 = r;
r1.min.y = y;