24 draw(w->im, rectaddpt(Rect(0, 0, SCRBSIZ+1, h), w->inner.min), w->tab->cols[BORD], nil, ZP);
26 t1 = (w->toprune + w->fr.nchars) * h;
34 draw(w->im, rectaddpt(Rect(0, t0, SCRBSIZ, t1), w->inner.min), w->tab->cols[BACK], nil, ZP);
43 r = insetrect(w->inner, 1);
46 frinit(&w->fr, r, display->defaultfont, w->im, w->tab->cols);
47 frinsert(&w->fr, w->runes + w->toprune, w->runes + w->nrunes, 0);
51 cmdscroll(Win *w, int l)
58 for(r = w->toprune; r < w->nrunes && l != 0; r++)
59 if(w->runes[r] == '\n')
63 for(r = w->toprune; r > 0; r--)
64 if(w->runes[r] == '\n' && ++l == 0){
71 frdelete(&w->fr, 0, w->fr.nchars);
72 frinsert(&w->fr, w->runes + w->toprune, w->runes + w->nrunes, 0);
77 cmdclick(Win *w, Mousectl *mc)
79 if(mc->xy.x <= w->inner.min.x + SCRBSIZ){
87 cmdrmb(Win *w, Mousectl *mc)
89 if(mc->xy.x > w->inner.min.x + SCRBSIZ)
96 cmdinsert(Win *w, Rune *r, int nr, int rp)
101 for(nr = 0, s = r; *s++ != 0; nr++)
103 if(rp < 0 || rp > w->nrunes)
105 if(w->nrunes + nr > w->arunes){
106 w->runes = realloc(w->runes, w->arunes = w->arunes + (nr + RUNEBLK - 1) & ~(RUNEBLK - 1));
108 sysfatal("realloc: %r");
111 memmove(w->runes + rp, w->runes + rp + nr, (w->nrunes - rp) * sizeof(Rune));
112 memmove(w->runes + rp, r, nr * sizeof(Rune));
117 frinsert(&w->fr, w->runes + rp, w->runes + rp + nr, rp - w->toprune);
118 if(rp == w->nrunes - nr){
119 if(w->fr.lastlinefull)
127 cmddel(Win *w, int a, int b)
131 memmove(w->runes + a, w->runes + b, w->nrunes - b);
136 frdelete(&w->fr, a - w->toprune, b - w->toprune);
143 cmdkey(Win *w, Rune r)
145 static char buf[4096];
149 if(w->fr.p0 < w->fr.p1)
150 cmddel(w, w->toprune + w->fr.p0, w->toprune + w->fr.p1);
156 if(w->fr.p0 > 0 && w->toprune + w->fr.p0 != w->opoint)
157 cmddel(w, w->toprune + w->fr.p0 - 1, w->toprune + w->fr.p0);
160 cmdinsert(w, &r, 1, w->fr.p0 + w->toprune);
161 if(w->toprune + w->fr.p0 == w->nrunes){
162 q = w->runes + w->opoint;
164 while(q < w->runes + w->nrunes && p < buf + nelem(buf) + 1)
165 p += runetochar(p, q++);
167 w->opoint = w->nrunes;
178 cmdinsert(w, &r, 1, w->fr.p0 + w->toprune);
183 cmdprint(char *fmt, ...)
189 r = runevsmprint(fmt, va);
192 cmdw->opoint += cmdinsert(cmdw, r, -1, cmdw->opoint);
205 [HIGH] DPalegreygreen