Today's changes.

More changes.
This commit is contained in:
rsc 2004-03-25 23:03:57 +00:00
parent cb27443abf
commit 8ad517944e
73 changed files with 2865 additions and 1293 deletions

View file

@ -161,7 +161,8 @@ threadmain(int argc, char *argv[])
cerr = chancreate(sizeof(char*), 0);
cedit = chancreate(sizeof(int), 0);
cexit = chancreate(sizeof(int), 0);
if(cwait==nil || ccommand==nil || ckill==nil || cxfidalloc==nil || cxfidfree==nil || cerr==nil || cexit==nil){
cwarn = chancreate(sizeof(void*), 1);
if(cwait==nil || ccommand==nil || ckill==nil || cxfidalloc==nil || cxfidfree==nil || cerr==nil || cexit==nil || cwarn==nil){
fprint(2, "acme: can't create initial channels: %r\n");
exits("channels");
}
@ -251,7 +252,7 @@ readfile(Column *c, char *s)
w = coladd(c, nil, nil, -1);
cvttorunes(s, strlen(s), rb, &nb, &nr, nil);
rs = cleanrname((Runestr){rb, nr});
rs = cleanrname(runestr(rb, nr));
winsetname(w, rs.r, rs.nr);
textload(&w->body, 0, s, 1);
w->body.file->mod = FALSE;
@ -403,7 +404,6 @@ keyboardthread(void *v)
winlock(t->w, 'K');
wincommit(t->w, t);
winunlock(t->w);
flushwarnings(1);
flushimage(display, 1);
}
alts[KTimer].c = nil;
@ -430,7 +430,6 @@ keyboardthread(void *v)
}
if(nbrecv(keyboardctl->c, &r) > 0)
goto casekeyboard;
flushwarnings(1);
flushimage(display, 1);
break;
}
@ -447,7 +446,7 @@ mousethread(void *v)
Plumbmsg *pm;
Mouse m;
char *act;
enum { MResize, MMouse, MPlumb, NMALT };
enum { MResize, MMouse, MPlumb, MWarnings, NMALT };
static Alt alts[NMALT+1];
USED(v);
@ -461,11 +460,18 @@ mousethread(void *v)
alts[MPlumb].c = cplumb;
alts[MPlumb].v = ±
alts[MPlumb].op = CHANRCV;
alts[MWarnings].c = cwarn;
alts[MWarnings].v = nil;
alts[MWarnings].op = CHANRCV;
if(cplumb == nil)
alts[MPlumb].op = CHANNOP;
alts[NMALT].op = CHANEND;
for(;;){
qlock(&row.lk);
flushwarnings();
qunlock(&row.lk);
flushimage(display, 1);
switch(alt(alts)){
case MResize:
if(getwindow(display, Refnone) < 0)
@ -473,8 +479,6 @@ mousethread(void *v)
draw(screen, screen->r, display->white, nil, ZP);
scrlresize();
rowresize(&row, screen->clipr);
flushwarnings(1);
flushimage(display, 1);
break;
case MPlumb:
if(strcmp(pm->type, "text") == 0){
@ -484,10 +488,10 @@ mousethread(void *v)
else if(strcmp(act, "showdata")==0)
plumbshow(pm);
}
flushwarnings(1);
flushimage(display, 1);
plumbfree(pm);
break;
case MWarnings:
break;
case MMouse:
/*
* Make a copy so decisions are consistent; mousectl changes
@ -570,8 +574,6 @@ mousethread(void *v)
goto Continue;
}
Continue:
flushwarnings(0);
flushimage(display, 1);
qunlock(&row.lk);
break;
}

View file

@ -543,5 +543,6 @@ Channel *mouseexit1; /* chan(int) */
Channel *cexit; /* chan(int) */
Channel *cerr; /* chan(char*) */
Channel *cedit; /* chan(int) */
Channel *cwarn; /* chan(void*)[1] (really chan(unit)[1]) */
#define STACK 32768

View file

@ -268,7 +268,7 @@ D_cmd(Text *t, Cmd *cp)
runemove(n, dir.r, dir.nr);
n[dir.nr] = '/';
runemove(n+dir.nr+1, r, nn);
rs = cleanrname((Runestr){n, dir.nr+1+nn});
rs = cleanrname(runestr(n, dir.nr+1+nn));
}
w = lookfile(rs.r, rs.nr);
if(w == nil){

View file

@ -25,6 +25,7 @@ void fontx(Text*, Text*, Text*, int, int, Rune*, int);
void get(Text*, Text*, Text*, int, int, Rune*, int);
void id(Text*, Text*, Text*, int, int, Rune*, int);
void incl(Text*, Text*, Text*, int, int, Rune*, int);
void indent(Text*, Text*, Text*, int, int, Rune*, int);
void xkill(Text*, Text*, Text*, int, int, Rune*, int);
void local(Text*, Text*, Text*, int, int, Rune*, int);
void look(Text*, Text*, Text*, int, int, Rune*, int);
@ -58,6 +59,7 @@ static Rune LFont[] = { 'F', 'o', 'n', 't', 0 };
static Rune LGet[] = { 'G', 'e', 't', 0 };
static Rune LID[] = { 'I', 'D', 0 };
static Rune LIncl[] = { 'I', 'n', 'c', 'l', 0 };
static Rune LIndent[] = { 'I', 'n', 'd', 'e', 'n', 't', 0 };
static Rune LKill[] = { 'K', 'i', 'l', 'l', 0 };
static Rune LLoad[] = { 'L', 'o', 'a', 'd', 0 };
static Rune LLocal[] = { 'L', 'o', 'c', 'a', 'l', 0 };
@ -87,6 +89,7 @@ Exectab exectab[] = {
{ LGet, get, FALSE, TRUE, XXX },
{ LID, id, FALSE, XXX, XXX },
{ LIncl, incl, FALSE, XXX, XXX },
{ LIndent, indent, FALSE, XXX, XXX },
{ LKill, xkill, FALSE, XXX, XXX },
{ LLoad, dump, FALSE, FALSE, XXX },
{ LLocal, local, FALSE, XXX, XXX },
@ -1443,7 +1446,6 @@ runproc(void *argvp)
goto Fail;
Hard:
/*
* ugly: set path = (. $cputype /bin)
* should honor $path if unusual.

View file

@ -69,6 +69,7 @@ Rune* bytetorune(char*, int*);
void fsysinit(void);
Mntdir* fsysmount(Rune*, int, Rune**, int);
void fsysdelid(Mntdir*);
void fsysincid(Mntdir*);
Xfid* respond(Xfid*, Fcall*, char*);
int rxcompile(Rune*);
int rgetc(void*, uint);
@ -86,9 +87,11 @@ int expand(Text*, uint, uint, Expand*);
Rune* skipbl(Rune*, int, int*);
Rune* findbl(Rune*, int, int*);
char* edittext(Window*, int, Rune*, int);
void flushwarnings(int);
void flushwarnings(void);
void startplumbing(void);
Runestr runestr(Rune*, uint);
#define runemalloc(a) (Rune*)emalloc((a)*sizeof(Rune))
#define runerealloc(a, b) (Rune*)erealloc((a), (b)*sizeof(Rune))
#define runemove(a, b, c) memmove((a), (b), (c)*sizeof(Rune))

View file

@ -37,22 +37,25 @@ static Xfid* fsysremove(Xfid*, Fid*);
static Xfid* fsysstat(Xfid*, Fid*);
static Xfid* fsyswstat(Xfid*, Fid*);
Xfid* (*fcall[Tmax])(Xfid*, Fid*) =
Xfid* (*fcall[Tmax])(Xfid*, Fid*);
static void
initfcall(void)
{
[Tflush] = fsysflush,
[Tversion] = fsysversion,
[Tauth] = fsysauth,
[Tattach] = fsysattach,
[Twalk] = fsyswalk,
[Topen] = fsysopen,
[Tcreate] = fsyscreate,
[Tread] = fsysread,
[Twrite] = fsyswrite,
[Tclunk] = fsysclunk,
[Tremove]= fsysremove,
[Tstat] = fsysstat,
[Twstat] = fsyswstat,
};
fcall[Tflush] = fsysflush;
fcall[Tversion] = fsysversion;
fcall[Tauth] = fsysauth;
fcall[Tattach] = fsysattach;
fcall[Twalk] = fsyswalk;
fcall[Topen] = fsysopen;
fcall[Tcreate] = fsyscreate;
fcall[Tread] = fsysread;
fcall[Twrite] = fsyswrite;
fcall[Tclunk] = fsysclunk;
fcall[Tremove]= fsysremove;
fcall[Tstat] = fsysstat;
fcall[Twstat] = fsyswstat;
}
char Eperm[] = "permission denied";
char Eexist[] = "file does not exist";
@ -113,6 +116,7 @@ fsysinit(void)
int p[2];
char *u;
initfcall();
if(pipe(p) < 0)
error("can't create pipe");
if(post9pservice(p[0], "acme") < 0)
@ -186,6 +190,14 @@ fsysaddid(Rune *dir, int ndir, Rune **incl, int nincl)
return m;
}
void
fsysincid(Mntdir *m)
{
qlock(&mnt.lk);
m->ref++;
qunlock(&mnt.lk);
}
void
fsysdelid(Mntdir *idm)
{
@ -331,7 +343,7 @@ fsysattach(Xfid *x, Fid *f)
m->ref++;
break;
}
if(m == nil){
if(m == nil && x->fcall.aname[0]){
snprint(buf, sizeof buf, "unknown id '%s' in attach", x->fcall.aname);
sendp(cerr, estrdup(buf));
}

View file

@ -259,7 +259,7 @@ plumbshow(Plumbmsg *m)
}
cvttorunes(name, strlen(name), rb, &nb, &nr, nil);
free(p);
rs = cleanrname((Runestr){rb, nr});
rs = cleanrname(runestr(rb, nr));
winsetname(w, rs.r, rs.nr);
r = runemalloc(m->ndata);
cvttorunes(m->data, m->ndata, r, &nb, &nr, nil);
@ -385,13 +385,13 @@ includefile(Rune *dir, Rune *file, int nfile)
n = access(a, 0);
free(a);
if(n < 0)
return (Runestr){nil, 0};
return runestr(nil, 0);
r = runemalloc(m+1+nfile);
runemove(r, dir, m);
runemove(r+m, Lslash, 1);
runemove(r+m+1, file, nfile);
free(file);
return cleanrname((Runestr){r, m+1+nfile});
return cleanrname(runestr(r, m+1+nfile));
}
static Rune *objdir;
@ -442,7 +442,7 @@ includename(Text *t, Rune *r, int n)
return file;
Rescue:
return (Runestr){r, n};
return runestr(r, n);
}
Runestr
@ -475,11 +475,11 @@ dirname(Text *t, Rune *r, int n)
goto Rescue;
runemove(b+slash+1, r, n);
free(r);
return cleanrname((Runestr){b, slash+1+n});
return cleanrname(runestr(b, slash+1+n));
Rescue:
free(b);
tmp = (Runestr){r, n};
tmp = runestr(r, n);
if(r)
return cleanrname(tmp);
return tmp;

View file

@ -578,7 +578,7 @@ textcomplete(Text *t)
path[i] = textreadc(t, q++);
/* is path rooted? if not, we need to make it relative to window path */
if(npath>0 && path[0]=='/')
dir = (Runestr){path, npath};
dir = runestr(path, npath);
else{
dir = dirname(t, nil, 0);
if(dir.nr + 1 + npath > nelem(tmp)){

View file

@ -14,6 +14,16 @@
static Point prevmouse;
static Window *mousew;
Runestr
runestr(Rune *r, uint n)
{
Runestr rs;
rs.r = r;
rs.nr = n;
return rs;
}
void
cvttorunes(char *p, int n, Rune *r, int *nb, int *nr, int *nulls)
{
@ -133,12 +143,17 @@ addwarningtext(Mntdir *md, Rune *r, int nr)
}
warn = emalloc(sizeof(Warning));
warn->next = warnings;
warn->md = md;
if(md)
fsysincid(md);
warnings = warn;
bufinsert(&warn->buf, 0, r, nr);
nbsendp(cwarn, 0);
}
/* called while row is locked */
void
flushwarnings(int dolock)
flushwarnings(void)
{
Warning *warn, *next;
Window *w;
@ -146,8 +161,6 @@ flushwarnings(int dolock)
int owner, nr, q0, n;
Rune *r;
if(dolock)
qlock(&row.lk);
if(row.ncol == 0){ /* really early error */
rowinit(&row, screen->clipr);
rowadd(&row, nil, -1);
@ -189,11 +202,11 @@ flushwarnings(int dolock)
winunlock(w);
bufclose(&warn->buf);
next = warn->next;
if(warn->md)
fsysdelid(warn->md);
free(warn);
}
warnings = nil;
if(dolock)
qunlock(&row.lk);
}
void

View file

@ -543,7 +543,6 @@ xfidwrite(Xfid *x)
}
if(w)
winunlock(w);
flushwarnings(1);
}
void
@ -814,7 +813,6 @@ xfideventwrite(Xfid *x, Window *w)
qunlock(&row.lk);
goto Rescue;
}
flushwarnings(0);
qunlock(&row.lk);
}
@ -1032,7 +1030,6 @@ xfidindexread(Xfid *x)
b[n++] = '\n';
}
}
flushwarnings(0);
qunlock(&row.lk);
off = x->fcall.offset;
cnt = x->fcall.count;