tacme: Dump and Load tag contents - plan9port - [fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port
Log
Files
Refs
README
LICENSE
---
commit 611cf11c03d8ff854c716802ec627b115a4343fc
parent 69d1259cf9af6d288b34c4452db4c418e739f750
Author: Peter Canning 
Date:   Sun, 20 Jul 2008 03:14:55 -0400

acme: Dump and Load tag contents

Diffstat:
  M src/cmd/acme/rows.c                 |      57 +++++++++++++++++++++++++++++--

1 file changed, 55 insertions(+), 2 deletions(-)
---
diff --git a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c
t@@ -355,6 +355,21 @@ rowdump(Row *row, char *file)
                 for(j=0; jnw; 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(nncol; i++){
+                c = row->col[i];
+                m = min(RBUFSIZE, c->tag.file->b.nc);
+                bufread(&c->tag.file->b, 0, r, m);
+                n = 0;
+                while(nncol; i++){
                 c = row->col[i];
                 for(j=0; jnw; j++){
t@@ -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;
t@@ -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; ncol[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; ntag, 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':
t@@ -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);