mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
add bigtags
This commit is contained in:
parent
20ae0b0fc2
commit
f8dea3c178
5 changed files with 96 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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++;
|
||||
|
|
|
@ -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;
|
||||
|
@ -142,6 +166,7 @@ if(0) fprint(2, "=> %R (%R)\n", w->tag.all, w->tag.fr.r);
|
|||
draw(screen, br, b, nil, b->r.min);
|
||||
}
|
||||
|
||||
|
||||
r1 = r;
|
||||
r1.min.y = y;
|
||||
if(1 || !safe || !eqrect(w->body.all, r1)){
|
||||
|
|
Loading…
Reference in a new issue