23 draw(w->im, rectaddpt(Rect(0, 0, SCRBSIZ+1, h), w->inner.min), w->tab->cols[BORD], nil, ZP);
25 t1 = (w->toprune + w->fr.nchars) * h;
33 draw(w->im, rectaddpt(Rect(0, t0, SCRBSIZ, t1), w->inner.min), w->tab->cols[BACK], nil, ZP);
42 r = insetrect(w->inner, 1);
45 frinit(&w->fr, r, display->defaultfont, w->im, w->tab->cols);
46 frinsert(&w->fr, w->runes + w->toprune, w->runes + w->nrunes, 0);
50 cmdscroll(Win *w, int l)
57 for(r = w->toprune; r < w->nrunes && l != 0; r++)
58 if(w->runes[r] == '\n')
60 frdelete(&w->fr, 0, r - w->toprune);
63 for(r = w->toprune; r > 0; r--)
64 if(w->runes[r] == '\n' && --l == 0)
66 frinsert(&w->fr, w->runes + r, w->runes + w->toprune, 0);
73 cmdclick(Win *w, Mousectl *mc)
75 if(mc->xy.x <= w->inner.min.x + SCRBSIZ){
83 cmdrmb(Win *w, Mousectl *mc)
85 if(mc->xy.x > w->inner.min.x + SCRBSIZ)
92 cmdinsert(Win *w, Rune *r, int nr, int rp)
97 for(nr = 0, s = r; *s++ != 0; nr++)
99 if(rp < 0 || rp > w->nrunes)
101 if(w->nrunes + nr > w->arunes){
102 w->runes = realloc(w->runes, w->arunes = w->arunes + (nr + RUNEBLK - 1) & ~(RUNEBLK - 1));
104 sysfatal("realloc: %r");
107 memmove(w->runes + rp, w->runes + rp + nr, (w->nrunes - rp) * sizeof(Rune));
108 memmove(w->runes + rp, r, nr * sizeof(Rune));
113 frinsert(&w->fr, w->runes + rp, w->runes + rp + nr, rp - w->toprune);
114 if(rp == w->nrunes - nr){
115 if(w->fr.lastlinefull)
122 cmddel(Win *w, int a, int b)
126 memmove(w->runes + a, w->runes + b, w->nrunes - b);
131 frdelete(&w->fr, a - w->toprune, b - w->toprune);
138 cmdkey(Win *w, Rune r)
140 static char buf[4096];
144 if(w->fr.p0 < w->fr.p1)
145 cmddel(w, w->toprune + w->fr.p0, w->toprune + w->fr.p1);
152 cmddel(w, w->toprune + w->fr.p0 - 1, w->toprune + w->fr.p0);
155 cmdinsert(w, &r, 1, w->fr.p0 + w->toprune);
156 if(w->toprune + w->fr.p0 == w->nrunes){
157 q = w->runes + w->toprune + w->fr.p0 - 1;
159 while(*--q != 0xa && q > w->runes)
163 while(q < w->runes + w->nrunes && p < buf + nelem(buf) + 1 && *q != 0xa)
164 p += runetochar(p, q++);
170 cmdinsert(w, &r, 1, w->fr.p0 + w->toprune);
175 cmdprint(char *fmt, ...)
181 r = runevsmprint(fmt, va);
184 cmdinsert(cmdw, r, -1, -1);
197 [HIGH] DPalegreygreen