diff options
author | Peter Canning <devnull@localhost> | 2008-07-20 03:14:55 -0400 |
---|---|---|
committer | Peter Canning <devnull@localhost> | 2008-07-20 03:14:55 -0400 |
commit | 611cf11c03d8ff854c716802ec627b115a4343fc (patch) | |
tree | f0d89f2b856c75ab469ae00b38cb18580948c587 /src/cmd/acme | |
parent | 69d1259cf9af6d288b34c4452db4c418e739f750 (diff) | |
download | plan9port-611cf11c03d8ff854c716802ec627b115a4343fc.tar.gz plan9port-611cf11c03d8ff854c716802ec627b115a4343fc.tar.bz2 plan9port-611cf11c03d8ff854c716802ec627b115a4343fc.zip |
acme: Dump and Load tag contents
Diffstat (limited to 'src/cmd/acme')
-rw-r--r-- | src/cmd/acme/rows.c | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c index 50990d78..32ffeab9 100644 --- a/src/cmd/acme/rows.c +++ b/src/cmd/acme/rows.c @@ -355,6 +355,21 @@ rowdump(Row *row, char *file) for(j=0; j<c->nw; j++) c->w[j]->body.file->dumpid = 0; } + m = min(RBUFSIZE, row->tag.file->b.nc); + bufread(&row->tag.file->b, 0, r, m); + n = 0; + while(n<m && r[n]!='\n') + n++; + Bprint(b, "w %.*S\n", n, r); + for(i=0; i<row->ncol; i++){ + c = row->col[i]; + m = min(RBUFSIZE, c->tag.file->b.nc); + bufread(&c->tag.file->b, 0, r, m); + n = 0; + while(n<m && r[n]!='\n') + n++; + Bprint(b, "c%11d %.*S\n", i, n, r); + } for(i=0; i<row->ncol; i++){ c = row->col[i]; for(j=0; j<c->nw; j++){ @@ -494,7 +509,7 @@ rowloadfonts(char *file) int rowload(Row *row, char *file, int initing) { - int i, j, line, y, nr, nfontr, n, ns, ndumped, dumpid, x, fd; + int i, j, line, y, nr, nfontr, n, ns, ndumped, dumpid, x, fd, done; double percent; Biobuf *b, *bout; char *buf, *l, *t, *fontname; @@ -573,10 +588,45 @@ rowload(Row *row, char *file, int initing) if(i >= row->ncol) rowadd(row, nil, x); } - for(;;){ + done = 0; + while(!done){ l = rdline(b, &line); if(l == nil) break; + switch(l[0]){ + case 'c': + l[Blinelen(b)-1] = 0; + i = atoi(l+1+0*12); + r = bytetorune(l+1*12, &nr); + ns = -1; + for(n=0; n<nr; n++){ + if(r[n] == '/') + ns = n; + if(r[n] == ' ') + break; + } + textdelete(&row->col[i]->tag, 0, row->col[i]->tag.file->b.nc, TRUE); + textinsert(&row->col[i]->tag, 0, r+n+1, nr-(n+1), TRUE); + break; + case 'w': + l[Blinelen(b)-1] = 0; + r = bytetorune(l+2, &nr); + ns = -1; + for(n=0; n<nr; n++){ + if(r[n] == '/') + ns = n; + if(r[n] == ' ') + break; + } + textdelete(&row->tag, 0, row->tag.file->b.nc, TRUE); + textinsert(&row->tag, 0, r, nr, TRUE); + break; + default: + done = 1; + break; + } + } + for(;;){ dumpid = 0; switch(l[0]){ case 'e': @@ -719,6 +769,9 @@ rowload(Row *row, char *file, int initing) q0 = q1 = 0; textshow(&w->body, q0, q1, 1); w->maxlines = min(w->body.fr.nlines, max(w->maxlines, w->body.fr.maxlines)); + l = rdline(b, &line); + if(l == nil) + break; } Bterm(b); fbuffree(buf); |