📄 bw.c
字号:
if (bc == '\t') { long tcol = col + p->b->o.tab - col % p->b->o.tab; if (tcol > from && tcol <= to) c1 = INVERSE; else c1 = 0; } else if (col >= from && col < to) c1 = INVERSE; else c1 = 0; else if (byte >= from && byte < to) c1 = INVERSE; else c1 = 0; ++byte; if (bc == '\t') { ta = p->b->o.tab - col % p->b->o.tab; if (ta + col > scr) { ta -= scr - col; tach = ' '; goto dota; } if ((col += ta) == scr) { --amnt; goto loop; } } else if (bc == '\n') goto eobl; else { int wid = 1; if (p->b->o.charmap->type) { c = utf8_decode(&utf8_sm,bc); if (c>=0) /* Normal decoded character */ wid = joe_wcwidth(1,c); else if(c== -1) /* Character taken */ wid = -1; else if(c== -2) { /* Incomplete sequence (FIXME: do something better here) */ wid = 1; ungetit = c; ++amnt; --byte; } else if(c== -3) /* Control character 128-191, 254, 255 */ wid = 1; } else { wid = 1; } if(wid>0) { col += wid; if (col == scr) { --amnt; goto loop; } else if (col > scr) { ta = col - scr; tach = '<'; goto dota; } } else --idx; /* Get highlighting character again.. */ } } while (--amnt); if (bp == p->ptr + SEGSIZ) { if (pnext(p)) { bp = p->ptr; amnt = p->hdr->hole; goto lp; } } else { bp = p->ptr + p->hdr->ehole; amnt = SEGSIZ - p->hdr->ehole; goto lp; } goto eof; loop: /* Display next character */ if (amnt) do { if (ungetit== -1) bc = *bp++; else { bc = ungetit; ungetit = -1; } if(st.state!=-1) { atr = syn[idx++]; if (!(atr & BG_MASK)) atr |= BG_COLOR(bg_text); } if (p->b->o.crlf && bc == '\r') { ++byte; if (!--amnt) { ppl: if (bp == p->ptr + SEGSIZ) { if (pnext(p)) { bp = p->ptr; amnt = p->hdr->hole; } else goto nnl; } else { bp = p->ptr + p->hdr->ehole; amnt = SEGSIZ - p->hdr->ehole; if (!amnt) goto ppl; } } if (*bp == '\n') { ++bp; ++byte; ++amnt; goto eobl; } nnl: --byte; ++amnt; } if (square) if (bc == '\t') { long tcol = scr + x - ox + p->b->o.tab - (scr + x - ox) % p->b->o.tab; if (tcol > from && tcol <= to) c1 = INVERSE; else c1 = 0; } else if (scr + x - ox >= from && scr + x - ox < to) c1 = INVERSE; else c1 = 0; else if (byte >= from && byte < to) c1 = INVERSE; else c1 = 0; ++byte; if (bc == '\t') { ta = p->b->o.tab - ((x - ox + scr) % p->b->o.tab); tach = ' '; dota: do { outatr(bw->b->o.charmap, t, screen + x, attr + x, x, y, tach, c1|atr); if (ifhave) goto bye; if (++x == w) goto eosl; } while (--ta); } else if (bc == '\n') goto eobl; else { int wid = -1; int utf8_char; if (p->b->o.charmap->type) { /* UTF-8 */ utf8_char = utf8_decode(&utf8_sm,bc); if (utf8_char >= 0) { /* Normal decoded character */ wid = joe_wcwidth(1,utf8_char); } else if(utf8_char== -1) { /* Character taken */ wid = -1; } else if(utf8_char== -2) { /* Incomplete sequence (FIXME: do something better here) */ ungetit = bc; ++amnt; --byte; utf8_char = 'X'; wid = 1; } else if(utf8_char== -3) { /* Invalid UTF-8 start character 128-191, 254, 255 */ /* Show as control character */ wid = 1; utf8_char = 'X'; } } else { /* Regular */ utf8_char = bc; wid = 1; } if(wid>=0) { if (x+wid > w) { /* If character hits right most column, don't display it */ while (x < w) { outatr(bw->b->o.charmap, t, screen + x, attr + x, x, y, '>', c1|atr); x++; } } else { outatr(bw->b->o.charmap, t, screen + x, attr + x, x, y, utf8_char, c1|atr); x += wid; } } else --idx; if (ifhave) goto bye; if (x >= w) goto eosl; } } while (--amnt); if (bp == p->ptr + SEGSIZ) { if (pnext(p)) { bp = p->ptr; amnt = p->hdr->hole; goto loop; } } else { bp = p->ptr + p->hdr->ehole; amnt = SEGSIZ - p->hdr->ehole; goto loop; } goto eof; eobl: /* End of buffer line found. Erase to end of screen line */ ++p->line; eof: if (x != w) done = eraeol(t, x, y, BG_COLOR(bg_text)); else done = 0;/* Set p to bp/amnt */ bye: if (bp - p->ptr <= p->hdr->hole) p->ofst = bp - p->ptr; else p->ofst = bp - p->ptr - (p->hdr->ehole - p->hdr->hole); p->byte = byte; return done; eosl: if (bp - p->ptr <= p->hdr->hole) p->ofst = bp - p->ptr; else p->ofst = bp - p->ptr - (p->hdr->ehole - p->hdr->hole); p->byte = byte; pnextl(p); return 0;}/* Generate line into an array */#ifdef junkstatic int lgena(SCRN *t, int y, int *screen, int x, int w, P *p, long int scr, long int from, long int to) /* Screen line address */ /* Window */ /* Buffer pointer */ /* Starting column to display */ /* Range for marked block */{ int ox = x; int done = 1; long col = 0; long byte = p->byte; unsigned char *bp; /* Buffer pointer, 0 if not set */ int amnt; /* Amount left in this segment of the buffer */ int c, ta, c1; unsigned char bc;/* Initialize bp and amnt from p */ if (p->ofst >= p->hdr->hole) { bp = p->ptr + p->hdr->ehole + p->ofst - p->hdr->hole; amnt = SEGSIZ - p->hdr->ehole - (p->ofst - p->hdr->hole); } else { bp = p->ptr + p->ofst; amnt = p->hdr->hole - p->ofst; } if (col == scr) goto loop; lp: /* Display next character */ if (amnt) do { bc = *bp++; if (square) if (bc == '\t') { long tcol = col + p->b->o.tab - col % p->b->o.tab; if (tcol > from && tcol <= to) c1 = INVERSE; else c1 = 0; } else if (col >= from && col < to) c1 = INVERSE; else c1 = 0; else if (byte >= from && byte < to) c1 = INVERSE; else c1 = 0; ++byte; if (bc == '\t') { ta = p->b->o.tab - col % p->b->o.tab; if (ta + col > scr) { ta -= scr - col; goto dota; } if ((col += ta) == scr) { --amnt; goto loop; } } else if (bc == '\n') goto eobl; else if (++col == scr) { --amnt; goto loop; } } while (--amnt); if (bp == p->ptr + SEGSIZ) { if (pnext(p)) { bp = p->ptr; amnt = p->hdr->hole; goto lp; } } else { bp = p->ptr + p->hdr->ehole; amnt = SEGSIZ - p->hdr->ehole; goto lp; } goto eobl; loop: /* Display next character */ if (amnt) do { bc = *bp++; if (square) if (bc == '\t') { long tcol = scr + x - ox + p->b->o.tab - (scr + x - ox) % p->b->o.tab; if (tcol > from && tcol <= to) c1 = INVERSE; else c1 = 0; } else if (scr + x - ox >= from && scr + x - ox < to) c1 = INVERSE; else c1 = 0; else if (byte >= from && byte < to) c1 = INVERSE; else c1 = 0; ++byte; if (bc == '\t') { ta = p->b->o.tab - ((x - ox + scr) % p->b->o.tab); dota: do { screen[x] = ' ' + c1; if (++x == w) goto eosl; } while (--ta); } else if (bc == '\n') goto eobl; else { /* xlat(&c, &bc);*/ c ^= c1; screen[x] = c + bc; if (++x == w) goto eosl; } } while (--amnt); if (bp == p->ptr + SEGSIZ) { if (pnext(p)) { bp = p->ptr; amnt = p->hdr->hole; goto loop; } } else { bp = p->ptr + p->hdr->ehole; amnt = SEGSIZ - p->hdr->ehole; goto loop; } goto eof; eobl: /* End of buffer line found. Erase to end of screen line */ ++p->line; eof: while (x != w) screen[x++] = ' '; done = 0;/* Set p to bp/amnt */ if (bp - p->ptr <= p->hdr->hole) p->ofst = bp - p->ptr; else p->ofst = bp - p->ptr - (p->hdr->ehole - p->hdr->hole); p->byte = byte; return done; eosl: if (bp - p->ptr <= p->hdr->hole) p->ofst = bp - p->ptr; else p->ofst = bp - p->ptr - (p->hdr->ehole - p->hdr->hole); p->byte = byte; pnextl(p); return 0;}#endifstatic void gennum(BW *w, int *screen, int *attr, SCRN *t, int y, int *comp){ unsigned char buf[12]; int z; int lin = w->top->line + y - w->y; if (lin <= w->b->eof->line) joe_snprintf_1(buf, sizeof(buf), "%9ld ", w->top->line + y - w->y + 1); else { int x; for (x = 0; x != LINCOLS; ++x) buf[x] = ' '; buf[x] = 0; } for (z = 0; buf[z]; ++z) { outatr(w->b->o.charmap, t, screen + z, attr + z, z, y, buf[z], BG_COLOR(bg_text)); if (ifhave) return; comp[z] = buf[z]; }}void bwgenh(BW *w){ int *screen; int *attr; P *q = pdup(w->top, USTR "bwgenh"); int bot = w->h + w->y; int y; SCRN *t = w->t->t; int flg = 0; long from; long to; int dosquare = 0; from = to = 0; if (markv(0) && markk->b == w->b) if (square) { from = markb->xcol; to = markk->xcol; dosquare = 1; } else { from = markb->byte; to = markk->byte; } else if (marking && w == (BW *)maint->curwin->object && markb && markb->b == w->b && w->cursor->byte != markb->byte && !from) { if (square) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -