acme: import event log from plan9port (thanks fshahriar)
Based off the following 3 commits: 4a3fb87264f8bc03fc62f00ef335056f30d18023 45f8ba54143323f08a21343633764caa59aa3ea3 fdf6ef333705c844bcf3ccf2f93b2773f1a6aa41 Reading /mnt/acme/log reports a log of window create, put, focus, and delete events, as they happen. It blocks until the next event is available. Example log output: 8 new /Users/rsc/foo.go 8 put /Users/rsc/foo.go 8 del /Users/rsc/foo.go This lets acme-aware programs react to file writes, for example compiling code, running a test, or updating an import block.
This commit is contained in:
parent
e46000f076
commit
d2be4787c6
10 changed files with 50 additions and 7 deletions
|
@ -258,6 +258,7 @@ readfile(Column *c, char *s)
|
|||
winsettag(w);
|
||||
textscrdraw(&w->body);
|
||||
textsetselect(&w->tag, w->tag.file->nc, w->tag.file->nc);
|
||||
xfidlog(w, "new");
|
||||
}
|
||||
|
||||
char *oknotes[] ={
|
||||
|
@ -487,6 +488,12 @@ mousethread(void *)
|
|||
m = mousectl->Mouse;
|
||||
qlock(&row);
|
||||
t = rowwhich(&row, m.xy);
|
||||
|
||||
if((t!=mousetext && t!=nil && t->w!=nil) &&
|
||||
(mousetext==nil || mousetext->w==nil || t->w->id!=mousetext->w->id)) {
|
||||
xfidlog(t->w, "focus");
|
||||
}
|
||||
|
||||
if(t!=mousetext && mousetext!=nil && mousetext->w!=nil){
|
||||
winlock(mousetext->w, 'M');
|
||||
mousetext->eq0 = ~0;
|
||||
|
@ -773,6 +780,7 @@ newwindowthread(void*)
|
|||
recvp(cnewwindow);
|
||||
w = makenewwindow(nil);
|
||||
winsettag(w);
|
||||
xfidlog(w, "new");
|
||||
sendp(cnewwindow, w);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ enum
|
|||
Qeditout,
|
||||
Qindex,
|
||||
Qlabel,
|
||||
Qlog,
|
||||
Qnew,
|
||||
|
||||
QWaddr,
|
||||
|
@ -396,6 +397,7 @@ struct Fid
|
|||
Mntdir *mntdir;
|
||||
int nrpart;
|
||||
uchar rpart[UTFmax];
|
||||
vlong logoff; // for putlog
|
||||
};
|
||||
|
||||
|
||||
|
@ -408,7 +410,6 @@ struct Xfid
|
|||
Fid *f;
|
||||
uchar *buf;
|
||||
int flushed;
|
||||
|
||||
};
|
||||
|
||||
void xfidctl(void *);
|
||||
|
@ -423,6 +424,10 @@ void xfideventwrite(Xfid*, Window*);
|
|||
void xfidindexread(Xfid*);
|
||||
void xfidutfread(Xfid*, Text*, uint, int);
|
||||
int xfidruneread(Xfid*, Text*, uint, uint);
|
||||
void xfidlogopen(Xfid*);
|
||||
void xfidlogread(Xfid*);
|
||||
void xfidlogflush(Xfid*);
|
||||
void xfidlog(Window*, char*);
|
||||
|
||||
struct Reffont
|
||||
{
|
||||
|
|
|
@ -297,10 +297,14 @@ void
|
|||
newcol(Text *et, Text*, Text*, int, int, Rune*, int)
|
||||
{
|
||||
Column *c;
|
||||
Window *w;
|
||||
|
||||
c = rowadd(et->row, nil, -1);
|
||||
if(c)
|
||||
winsettag(coladd(c, nil, nil, -1));
|
||||
if(c) {
|
||||
w = coladd(c, nil, nil, -1);
|
||||
winsettag(w);
|
||||
xfidlog(w, "new");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -496,6 +500,7 @@ zeroxx(Text *et, Text *t, Text*, int, int, Rune*, int)
|
|||
nw = coladd(t->w->col, nil, t->w, -1);
|
||||
/* ugly: fix locks so w->unlock works */
|
||||
winlock1(nw, t->w->owner);
|
||||
xfidlog(nw, "zerox");
|
||||
}
|
||||
if(locked)
|
||||
winunlock(t->w);
|
||||
|
@ -559,6 +564,7 @@ get(Text *et, Text *t, Text *argt, int flag1, int, Rune *arg, int narg)
|
|||
textsetselect(&u->w->tag, u->w->tag.file->nc, u->w->tag.file->nc);
|
||||
textscrdraw(u);
|
||||
}
|
||||
xfidlog(w, "get");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -695,6 +701,7 @@ put(Text *et, Text*, Text *argt, int, int, Rune *arg, int narg)
|
|||
}
|
||||
namer = bytetorune(name, &nname);
|
||||
putfile(f, 0, f->nc, namer, nname);
|
||||
xfidlog(w, "put");
|
||||
free(name);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@ Dirtab dirtab[]=
|
|||
{ "editout", QTFILE, Qeditout, 0200 },
|
||||
{ "index", QTFILE, Qindex, 0400 },
|
||||
{ "label", QTFILE, Qlabel, 0600 },
|
||||
{ "log", QTFILE, Qlog, 0400 },
|
||||
{ "new", QTDIR, Qnew, 0500|DMDIR },
|
||||
{ nil, }
|
||||
};
|
||||
|
|
|
@ -233,6 +233,7 @@ plumbshow(Plumbmsg *m)
|
|||
winsettag(w);
|
||||
textscrdraw(&w->body);
|
||||
textsetselect(&w->tag, w->tag.file->nc, w->tag.file->nc);
|
||||
xfidlog(w, "new");
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -668,6 +669,7 @@ openfile(Text *t, Expand *e)
|
|||
}else
|
||||
for(i=0; i < NINDENT; i++)
|
||||
w->indent[i] = globalindent[i];
|
||||
xfidlog(w, "new");
|
||||
}
|
||||
if(e->a1 == e->a0)
|
||||
eval = FALSE;
|
||||
|
@ -697,6 +699,7 @@ new(Text *et, Text *t, Text *argt, int flag1, int flag2, Rune *arg, int narg)
|
|||
int na, nf;
|
||||
Expand e;
|
||||
Runestr rs;
|
||||
Window *w;
|
||||
|
||||
getarg(argt, FALSE, TRUE, &a, &na);
|
||||
if(a){
|
||||
|
@ -708,8 +711,11 @@ new(Text *et, Text *t, Text *argt, int flag1, int flag2, Rune *arg, int narg)
|
|||
for(ndone=0; ; ndone++){
|
||||
a = findbl(arg, narg, &na);
|
||||
if(a == arg){
|
||||
if(ndone==0 && et->col!=nil)
|
||||
winsettag(coladd(et->col, nil, nil, -1));
|
||||
if(ndone==0 && et->col!=nil) {
|
||||
w = coladd(et->col, nil, nil, -1);
|
||||
winsettag(w);
|
||||
xfidlog(w, "new");
|
||||
}
|
||||
break;
|
||||
}
|
||||
nf = narg-na;
|
||||
|
|
|
@ -15,6 +15,7 @@ OFILES=\
|
|||
exec.$O\
|
||||
file.$O\
|
||||
fsys.$O\
|
||||
logf.$O\
|
||||
look.$O\
|
||||
regx.$O\
|
||||
rows.$O\
|
||||
|
|
|
@ -697,6 +697,7 @@ rowload(Row *row, char *file, int initing)
|
|||
q0 = q1 = 0;
|
||||
textshow(&w->body, q0, q1, 1);
|
||||
w->maxlines = min(w->body.nlines, max(w->maxlines, w->body.maxlines));
|
||||
xfidlog(w, "new");
|
||||
}
|
||||
Bterm(b);
|
||||
fbuffree(buf);
|
||||
|
|
|
@ -77,6 +77,7 @@ errorwin1(Rune *dir, int ndir, Rune **incl, int nincl)
|
|||
w = coladd(row.col[row.ncol-1], nil, nil, -1);
|
||||
w->filemenu = FALSE;
|
||||
winsetname(w, r, n);
|
||||
xfidlog(w, "new");
|
||||
}
|
||||
free(r);
|
||||
for(i=nincl; --i>=0; ){
|
||||
|
|
|
@ -313,6 +313,7 @@ winclose(Window *w)
|
|||
int i;
|
||||
|
||||
if(decref(w) == 0){
|
||||
xfidlog(w, "del");
|
||||
windirfree(w);
|
||||
textclose(&w->tag);
|
||||
textclose(&w->body);
|
||||
|
@ -633,7 +634,7 @@ Rescue:
|
|||
}
|
||||
|
||||
int
|
||||
winclean(Window *w, int conservative) /* as it stands, conservative is always TRUE */
|
||||
winclean(Window *w, int conservative)
|
||||
{
|
||||
if(w->isscratch || w->isdir) /* don't whine if it's a guide file, error window, etc. */
|
||||
return TRUE;
|
||||
|
|
|
@ -63,6 +63,8 @@ xfidflush(Xfid *x)
|
|||
Column *c;
|
||||
Xfid *wx;
|
||||
|
||||
xfidlogflush(x);
|
||||
|
||||
/* search windows for matching tag */
|
||||
qlock(&row);
|
||||
for(j=0; j<row.ncol; j++){
|
||||
|
@ -98,9 +100,9 @@ xfidopen(Xfid *x)
|
|||
|
||||
w = x->f->w;
|
||||
t = &w->body;
|
||||
q = FILE(x->f->qid);
|
||||
if(w){
|
||||
winlock(w, 'E');
|
||||
q = FILE(x->f->qid);
|
||||
switch(q){
|
||||
case QWaddr:
|
||||
if(w->nopen[q]++ == 0){
|
||||
|
@ -179,6 +181,13 @@ xfidopen(Xfid *x)
|
|||
}
|
||||
winunlock(w);
|
||||
}
|
||||
else{
|
||||
switch(q){
|
||||
case Qlog:
|
||||
xfidlogopen(x);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fc.qid = x->f->qid;
|
||||
fc.iounit = messagesize-IOHDRSZ;
|
||||
x->f->open = TRUE;
|
||||
|
@ -274,6 +283,9 @@ xfidread(Xfid *x)
|
|||
case Qindex:
|
||||
xfidindexread(x);
|
||||
return;
|
||||
case Qlog:
|
||||
xfidlogread(x);
|
||||
return;
|
||||
default:
|
||||
warning(nil, "unknown qid %d\n", q);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue