static void cdata(B *b, unsigned char *dat, int siz) { if (b->vt) { /* ANSI terminal emulator */ MACRO *m; do { cready(b, b->vt->vtcur->byte); m = vt_data(b->vt, &dat, &siz); cfollow(b, b->vt, b->vt->vtcur->byte); undomark(); if (m) { /* only do this if cursor is on window */ if ((maint->curwin->watom->what & TYPETW) && ((BW *)maint->curwin->object)->b == b) { exmacro(m, 1); edupd(1); } rmmacro(m); } } while (m); } else { /* Dumb terminal */ P *q = pdup(b->eof, USTR "cdata"); P *r = pdup(b->eof, USTR "cdata"); off_t byte = q->byte; unsigned char bf[1024]; int x, y; cready(b, byte); for (x = y = 0; x != siz; ++x) { if (dat[x] == 13 || dat[x] == 0) { ; } else if (dat[x] == 8 || dat[x] == 127) { if (y) { --y; } else { pset(q, r); prgetc(q); bdel(q, r); --byte; } } else if (dat[x] == 7) { ttputc(7); } else { bf[y++] = dat[x]; } } if (y) { binsm(r, bf, y); } prm(r); prm(q); cfollow(b, NULL, b->eof->byte); undomark(); } }
static void cdata(B *b, unsigned char *dat, int siz) { P *q = pdup(b->eof, USTR "cdata"); P *r = pdup(b->eof, USTR "cdata"); long byte = q->byte; unsigned char bf[1024]; int x, y; for (x = y = 0; x != siz; ++x) { if (dat[x] == 13 || dat[x] == 0) { ; } else if (dat[x] == 8 || dat[x] == 127) { if (y) { --y; } else { pset(q, r); prgetc(q); bdel(q, r); --byte; } } else if (dat[x] == 7) { ttputc(7); } else { bf[y++] = dat[x]; } } if (y) { binsm(r, bf, y); } prm(r); prm(q); cfollow(b,byte); undomark(); }