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

View file

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

View file

@ -6,7 +6,7 @@ int whide(Window*);
int wunhide(int);
void freescrtemps(void);
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);
int min(int, int);
int max(int, int);

View file

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