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);
|
winsettag(w);
|
||||||
textscrdraw(&w->body);
|
textscrdraw(&w->body);
|
||||||
textsetselect(&w->tag, w->tag.file->nc, w->tag.file->nc);
|
textsetselect(&w->tag, w->tag.file->nc, w->tag.file->nc);
|
||||||
|
xfidlog(w, "new");
|
||||||
}
|
}
|
||||||
|
|
||||||
char *oknotes[] ={
|
char *oknotes[] ={
|
||||||
|
@ -487,6 +488,12 @@ mousethread(void *)
|
||||||
m = mousectl->Mouse;
|
m = mousectl->Mouse;
|
||||||
qlock(&row);
|
qlock(&row);
|
||||||
t = rowwhich(&row, m.xy);
|
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){
|
if(t!=mousetext && mousetext!=nil && mousetext->w!=nil){
|
||||||
winlock(mousetext->w, 'M');
|
winlock(mousetext->w, 'M');
|
||||||
mousetext->eq0 = ~0;
|
mousetext->eq0 = ~0;
|
||||||
|
@ -773,6 +780,7 @@ newwindowthread(void*)
|
||||||
recvp(cnewwindow);
|
recvp(cnewwindow);
|
||||||
w = makenewwindow(nil);
|
w = makenewwindow(nil);
|
||||||
winsettag(w);
|
winsettag(w);
|
||||||
|
xfidlog(w, "new");
|
||||||
sendp(cnewwindow, w);
|
sendp(cnewwindow, w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ enum
|
||||||
Qeditout,
|
Qeditout,
|
||||||
Qindex,
|
Qindex,
|
||||||
Qlabel,
|
Qlabel,
|
||||||
|
Qlog,
|
||||||
Qnew,
|
Qnew,
|
||||||
|
|
||||||
QWaddr,
|
QWaddr,
|
||||||
|
@ -396,6 +397,7 @@ struct Fid
|
||||||
Mntdir *mntdir;
|
Mntdir *mntdir;
|
||||||
int nrpart;
|
int nrpart;
|
||||||
uchar rpart[UTFmax];
|
uchar rpart[UTFmax];
|
||||||
|
vlong logoff; // for putlog
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -408,7 +410,6 @@ struct Xfid
|
||||||
Fid *f;
|
Fid *f;
|
||||||
uchar *buf;
|
uchar *buf;
|
||||||
int flushed;
|
int flushed;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void xfidctl(void *);
|
void xfidctl(void *);
|
||||||
|
@ -423,6 +424,10 @@ void xfideventwrite(Xfid*, Window*);
|
||||||
void xfidindexread(Xfid*);
|
void xfidindexread(Xfid*);
|
||||||
void xfidutfread(Xfid*, Text*, uint, int);
|
void xfidutfread(Xfid*, Text*, uint, int);
|
||||||
int xfidruneread(Xfid*, Text*, uint, uint);
|
int xfidruneread(Xfid*, Text*, uint, uint);
|
||||||
|
void xfidlogopen(Xfid*);
|
||||||
|
void xfidlogread(Xfid*);
|
||||||
|
void xfidlogflush(Xfid*);
|
||||||
|
void xfidlog(Window*, char*);
|
||||||
|
|
||||||
struct Reffont
|
struct Reffont
|
||||||
{
|
{
|
||||||
|
|
|
@ -297,10 +297,14 @@ void
|
||||||
newcol(Text *et, Text*, Text*, int, int, Rune*, int)
|
newcol(Text *et, Text*, Text*, int, int, Rune*, int)
|
||||||
{
|
{
|
||||||
Column *c;
|
Column *c;
|
||||||
|
Window *w;
|
||||||
|
|
||||||
c = rowadd(et->row, nil, -1);
|
c = rowadd(et->row, nil, -1);
|
||||||
if(c)
|
if(c) {
|
||||||
winsettag(coladd(c, nil, nil, -1));
|
w = coladd(c, nil, nil, -1);
|
||||||
|
winsettag(w);
|
||||||
|
xfidlog(w, "new");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -496,6 +500,7 @@ zeroxx(Text *et, Text *t, Text*, int, int, Rune*, int)
|
||||||
nw = coladd(t->w->col, nil, t->w, -1);
|
nw = coladd(t->w->col, nil, t->w, -1);
|
||||||
/* ugly: fix locks so w->unlock works */
|
/* ugly: fix locks so w->unlock works */
|
||||||
winlock1(nw, t->w->owner);
|
winlock1(nw, t->w->owner);
|
||||||
|
xfidlog(nw, "zerox");
|
||||||
}
|
}
|
||||||
if(locked)
|
if(locked)
|
||||||
winunlock(t->w);
|
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);
|
textsetselect(&u->w->tag, u->w->tag.file->nc, u->w->tag.file->nc);
|
||||||
textscrdraw(u);
|
textscrdraw(u);
|
||||||
}
|
}
|
||||||
|
xfidlog(w, "get");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -695,6 +701,7 @@ put(Text *et, Text*, Text *argt, int, int, Rune *arg, int narg)
|
||||||
}
|
}
|
||||||
namer = bytetorune(name, &nname);
|
namer = bytetorune(name, &nname);
|
||||||
putfile(f, 0, f->nc, namer, nname);
|
putfile(f, 0, f->nc, namer, nname);
|
||||||
|
xfidlog(w, "put");
|
||||||
free(name);
|
free(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ Dirtab dirtab[]=
|
||||||
{ "editout", QTFILE, Qeditout, 0200 },
|
{ "editout", QTFILE, Qeditout, 0200 },
|
||||||
{ "index", QTFILE, Qindex, 0400 },
|
{ "index", QTFILE, Qindex, 0400 },
|
||||||
{ "label", QTFILE, Qlabel, 0600 },
|
{ "label", QTFILE, Qlabel, 0600 },
|
||||||
|
{ "log", QTFILE, Qlog, 0400 },
|
||||||
{ "new", QTDIR, Qnew, 0500|DMDIR },
|
{ "new", QTDIR, Qnew, 0500|DMDIR },
|
||||||
{ nil, }
|
{ nil, }
|
||||||
};
|
};
|
||||||
|
|
|
@ -233,6 +233,7 @@ plumbshow(Plumbmsg *m)
|
||||||
winsettag(w);
|
winsettag(w);
|
||||||
textscrdraw(&w->body);
|
textscrdraw(&w->body);
|
||||||
textsetselect(&w->tag, w->tag.file->nc, w->tag.file->nc);
|
textsetselect(&w->tag, w->tag.file->nc, w->tag.file->nc);
|
||||||
|
xfidlog(w, "new");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -668,6 +669,7 @@ openfile(Text *t, Expand *e)
|
||||||
}else
|
}else
|
||||||
for(i=0; i < NINDENT; i++)
|
for(i=0; i < NINDENT; i++)
|
||||||
w->indent[i] = globalindent[i];
|
w->indent[i] = globalindent[i];
|
||||||
|
xfidlog(w, "new");
|
||||||
}
|
}
|
||||||
if(e->a1 == e->a0)
|
if(e->a1 == e->a0)
|
||||||
eval = FALSE;
|
eval = FALSE;
|
||||||
|
@ -697,6 +699,7 @@ new(Text *et, Text *t, Text *argt, int flag1, int flag2, Rune *arg, int narg)
|
||||||
int na, nf;
|
int na, nf;
|
||||||
Expand e;
|
Expand e;
|
||||||
Runestr rs;
|
Runestr rs;
|
||||||
|
Window *w;
|
||||||
|
|
||||||
getarg(argt, FALSE, TRUE, &a, &na);
|
getarg(argt, FALSE, TRUE, &a, &na);
|
||||||
if(a){
|
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++){
|
for(ndone=0; ; ndone++){
|
||||||
a = findbl(arg, narg, &na);
|
a = findbl(arg, narg, &na);
|
||||||
if(a == arg){
|
if(a == arg){
|
||||||
if(ndone==0 && et->col!=nil)
|
if(ndone==0 && et->col!=nil) {
|
||||||
winsettag(coladd(et->col, nil, nil, -1));
|
w = coladd(et->col, nil, nil, -1);
|
||||||
|
winsettag(w);
|
||||||
|
xfidlog(w, "new");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nf = narg-na;
|
nf = narg-na;
|
||||||
|
|
|
@ -15,6 +15,7 @@ OFILES=\
|
||||||
exec.$O\
|
exec.$O\
|
||||||
file.$O\
|
file.$O\
|
||||||
fsys.$O\
|
fsys.$O\
|
||||||
|
logf.$O\
|
||||||
look.$O\
|
look.$O\
|
||||||
regx.$O\
|
regx.$O\
|
||||||
rows.$O\
|
rows.$O\
|
||||||
|
|
|
@ -697,6 +697,7 @@ rowload(Row *row, char *file, int initing)
|
||||||
q0 = q1 = 0;
|
q0 = q1 = 0;
|
||||||
textshow(&w->body, q0, q1, 1);
|
textshow(&w->body, q0, q1, 1);
|
||||||
w->maxlines = min(w->body.nlines, max(w->maxlines, w->body.maxlines));
|
w->maxlines = min(w->body.nlines, max(w->maxlines, w->body.maxlines));
|
||||||
|
xfidlog(w, "new");
|
||||||
}
|
}
|
||||||
Bterm(b);
|
Bterm(b);
|
||||||
fbuffree(buf);
|
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 = coladd(row.col[row.ncol-1], nil, nil, -1);
|
||||||
w->filemenu = FALSE;
|
w->filemenu = FALSE;
|
||||||
winsetname(w, r, n);
|
winsetname(w, r, n);
|
||||||
|
xfidlog(w, "new");
|
||||||
}
|
}
|
||||||
free(r);
|
free(r);
|
||||||
for(i=nincl; --i>=0; ){
|
for(i=nincl; --i>=0; ){
|
||||||
|
|
|
@ -313,6 +313,7 @@ winclose(Window *w)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if(decref(w) == 0){
|
if(decref(w) == 0){
|
||||||
|
xfidlog(w, "del");
|
||||||
windirfree(w);
|
windirfree(w);
|
||||||
textclose(&w->tag);
|
textclose(&w->tag);
|
||||||
textclose(&w->body);
|
textclose(&w->body);
|
||||||
|
@ -633,7 +634,7 @@ Rescue:
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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. */
|
if(w->isscratch || w->isdir) /* don't whine if it's a guide file, error window, etc. */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -63,6 +63,8 @@ xfidflush(Xfid *x)
|
||||||
Column *c;
|
Column *c;
|
||||||
Xfid *wx;
|
Xfid *wx;
|
||||||
|
|
||||||
|
xfidlogflush(x);
|
||||||
|
|
||||||
/* search windows for matching tag */
|
/* search windows for matching tag */
|
||||||
qlock(&row);
|
qlock(&row);
|
||||||
for(j=0; j<row.ncol; j++){
|
for(j=0; j<row.ncol; j++){
|
||||||
|
@ -98,9 +100,9 @@ xfidopen(Xfid *x)
|
||||||
|
|
||||||
w = x->f->w;
|
w = x->f->w;
|
||||||
t = &w->body;
|
t = &w->body;
|
||||||
|
q = FILE(x->f->qid);
|
||||||
if(w){
|
if(w){
|
||||||
winlock(w, 'E');
|
winlock(w, 'E');
|
||||||
q = FILE(x->f->qid);
|
|
||||||
switch(q){
|
switch(q){
|
||||||
case QWaddr:
|
case QWaddr:
|
||||||
if(w->nopen[q]++ == 0){
|
if(w->nopen[q]++ == 0){
|
||||||
|
@ -179,6 +181,13 @@ xfidopen(Xfid *x)
|
||||||
}
|
}
|
||||||
winunlock(w);
|
winunlock(w);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
switch(q){
|
||||||
|
case Qlog:
|
||||||
|
xfidlogopen(x);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
fc.qid = x->f->qid;
|
fc.qid = x->f->qid;
|
||||||
fc.iounit = messagesize-IOHDRSZ;
|
fc.iounit = messagesize-IOHDRSZ;
|
||||||
x->f->open = TRUE;
|
x->f->open = TRUE;
|
||||||
|
@ -274,6 +283,9 @@ xfidread(Xfid *x)
|
||||||
case Qindex:
|
case Qindex:
|
||||||
xfidindexread(x);
|
xfidindexread(x);
|
||||||
return;
|
return;
|
||||||
|
case Qlog:
|
||||||
|
xfidlogread(x);
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
warning(nil, "unknown qid %d\n", q);
|
warning(nil, "unknown qid %d\n", q);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue