This commit is contained in:
Russ Cox 2011-10-12 13:19:04 -04:00
commit 210d461c87
4 changed files with 25 additions and 10 deletions

View file

@ -67,7 +67,7 @@ threadmain(int argc, char *argv[])
fontname = EARGF(usage()); fontname = EARGF(usage());
break; break;
case 's': case 's':
/* no-op */ scrolling = TRUE;
break; break;
case 'c': case 'c':
cooked = TRUE; cooked = TRUE;
@ -114,7 +114,7 @@ threadmain(int argc, char *argv[])
timerinit(); timerinit();
servedevtext(); servedevtext();
rcpid = rcstart(argc, argv, &rcfd, &sfd); rcpid = rcstart(argc, argv, &rcfd, &sfd);
w = new(screen, FALSE, rcpid, ".", nil, nil); w = new(screen, FALSE, scrolling, rcpid, ".", nil, nil);
threadcreate(keyboardthread, nil, STACK); threadcreate(keyboardthread, nil, STACK);
threadcreate(mousethread, nil, STACK); threadcreate(mousethread, nil, STACK);
@ -241,7 +241,7 @@ wpointto(Point pt)
} }
Window* Window*
new(Image *i, int hideit, int pid, char *dir, char *cmd, char **argv) new(Image *i, int hideit, int scrollit, int pid, char *dir, char *cmd, char **argv)
{ {
Window *w; Window *w;
Mousectl *mc; Mousectl *mc;
@ -258,7 +258,7 @@ new(Image *i, int hideit, int pid, char *dir, char *cmd, char **argv)
*mc = *mousectl; *mc = *mousectl;
/* mc->image = i; */ /* mc->image = i; */
mc->c = cm; mc->c = cm;
w = wmk(i, mc, ck, cctl); w = wmk(i, mc, ck, cctl, scrollit);
free(mc); /* wmk copies *mc */ free(mc); /* wmk copies *mc */
window = erealloc(window, ++nwindow*sizeof(Window*)); window = erealloc(window, ++nwindow*sizeof(Window*));
window[nwindow-1] = w; window[nwindow-1] = w;
@ -288,6 +288,7 @@ enum
Snarf, Snarf,
Plumb, Plumb,
Send, Send,
Scroll,
Cook Cook
}; };
@ -298,6 +299,7 @@ char *menu2str[] = {
"plumb", "plumb",
"send", "send",
"cook", "cook",
"scroll",
nil nil
}; };
@ -315,6 +317,10 @@ button2menu(Window *w)
if(w->deleted) if(w->deleted)
return; return;
incref(&w->ref); incref(&w->ref);
if(w->scrolling)
menu2str[Scroll] = "noscroll";
else
menu2str[Scroll] = "scroll";
if(cooked) if(cooked)
menu2str[Cook] = "nocook"; menu2str[Cook] = "nocook";
else else
@ -358,7 +364,11 @@ button2menu(Window *w)
wsetselect(w, w->nr, w->nr); wsetselect(w, w->nr, w->nr);
wshow(w, w->nr); wshow(w, w->nr);
break; break;
case Scroll:
if(w->scrolling ^= 1)
wshow(w, w->nr);
break;
case Cook: case Cook:
cooked ^= 1; cooked ^= 1;
break; break;

View file

@ -132,6 +132,7 @@ struct Window
Rectangle lastsr; Rectangle lastsr;
int topped; int topped;
int notefd; int notefd;
uchar scrolling;
Cursor cursor; Cursor cursor;
Cursor *cursorp; Cursor *cursorp;
uchar holding; uchar holding;
@ -149,7 +150,7 @@ int winborder(Window*, Point);
void winctl(void*); void winctl(void*);
void winshell(void*); void winshell(void*);
Window* wlookid(int); Window* wlookid(int);
Window* wmk(Image*, Mousectl*, Channel*, Channel*); Window* wmk(Image*, Mousectl*, Channel*, Channel*, int);
Window* wpointto(Point); Window* wpointto(Point);
Window* wtop(Point); Window* wtop(Point);
void wtopme(Window*); void wtopme(Window*);

View file

@ -6,7 +6,7 @@ int whide(Window*);
int wunhide(int); int wunhide(int);
void freescrtemps(void); void freescrtemps(void);
int parsewctl(char**, Rectangle, Rectangle*, int*, int*, int*, int*, char**, char*, char*); int parsewctl(char**, Rectangle, Rectangle*, int*, int*, int*, int*, char**, char*, char*);
Window *new(Image*, int, int, char*, char*, char**); Window *new(Image*, int, int, int, char*, char*, char**);
void riosetcursor(Cursor*, int); void riosetcursor(Cursor*, int);
int min(int, int); int min(int, int);
int max(int, int); int max(int, int);

View file

@ -17,7 +17,7 @@
enum enum
{ {
HiWater = 640000, /* max size of history */ HiWater = 64000000, /* max size of history */
LoWater = 400000, /* min size of history after max'ed */ LoWater = 400000, /* min size of history after max'ed */
MinWater = 20000 /* room to leave available when reallocating */ MinWater = 20000 /* room to leave available when reallocating */
}; };
@ -36,7 +36,7 @@ static Image *lightholdcol;
static Image *paleholdcol; static Image *paleholdcol;
Window* Window*
wmk(Image *i, Mousectl *mc, Channel *ck, Channel *cctl) wmk(Image *i, Mousectl *mc, Channel *ck, Channel *cctl, int scrolling)
{ {
Window *w; Window *w;
Rectangle r; Rectangle r;
@ -77,6 +77,7 @@ wmk(Image *i, Mousectl *mc, Channel *ck, Channel *cctl)
w->topped = ++topped; w->topped = ++topped;
w->id = ++id; w->id = ++id;
w->notefd = -1; w->notefd = -1;
w->scrolling = scrolling;
w->dir = estrdup(startdir); w->dir = estrdup(startdir);
w->label = estrdup("<unnamed>"); w->label = estrdup("<unnamed>");
r = insetrect(w->i->r, Selborder); r = insetrect(w->i->r, Selborder);
@ -247,6 +248,9 @@ winctl(void *arg)
alts[WMouseread].op = CHANSND; alts[WMouseread].op = CHANSND;
else else
alts[WMouseread].op = CHANNOP; alts[WMouseread].op = CHANNOP;
// if(!w->scrolling && !w->mouseopen && w->qh>w->org+w->f.nchars)
// alts[WCwrite].op = CHANNOP;
// else
alts[WCwrite].op = CHANSND; alts[WCwrite].op = CHANSND;
if(w->deleted || !w->wctlready) if(w->deleted || !w->wctlready)
alts[WWread].op = CHANNOP; alts[WWread].op = CHANNOP;
@ -365,7 +369,7 @@ winctl(void *arg)
w->qh = qh; w->qh = qh;
} }
nr = up - rp; nr = up - rp;
scrolling = w->org <= w->qh && w->qh <= w->org + w->f.nchars; scrolling = w->scrolling && w->org <= w->qh && w->qh <= w->org + w->f.nchars;
w->qh = winsert(w, rp, nr, w->qh)+nr; w->qh = winsert(w, rp, nr, w->qh)+nr;
if(scrolling) if(scrolling)
wshow(w, w->qh); wshow(w, w->qh);