diff options
author | Russ Cox <rsc@swtch.com> | 2008-03-07 13:20:00 -0500 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2008-03-07 13:20:00 -0500 |
commit | 57851b64122b4a9e6a2289b8b96a447f49f68bae (patch) | |
tree | 932d7f7a81138afaa343f854346e8ee43ae56103 /src/libframe | |
parent | 41636940514d72e2a941f55f28dc07685e74b3b4 (diff) | |
download | plan9port-57851b64122b4a9e6a2289b8b96a447f49f68bae.tar.gz plan9port-57851b64122b4a9e6a2289b8b96a447f49f68bae.tar.bz2 plan9port-57851b64122b4a9e6a2289b8b96a447f49f68bae.zip |
libframe: translucent font fixes from Plan 9
Diffstat (limited to 'src/libframe')
-rw-r--r-- | src/libframe/frdraw.c | 35 | ||||
-rw-r--r-- | src/libframe/frinsert.c | 2 |
2 files changed, 30 insertions, 7 deletions
diff --git a/src/libframe/frdraw.c b/src/libframe/frdraw.c index 5f0ae016..c1cace42 100644 --- a/src/libframe/frdraw.c +++ b/src/libframe/frdraw.c @@ -5,16 +5,15 @@ #include <frame.h> void -_frredraw(Frame *f, Point pt) +_frdrawtext(Frame *f, Point pt, Image *text, Image *back) { Frbox *b; int nb; - /* static int x; */ for(nb=0,b=f->box; nb<f->nbox; nb++, b++){ _frcklinewrap(f, &pt, b); if(!f->noredraw && b->nrune >= 0) - string(f->b, pt, f->cols[TEXT], ZP, f->font, (char *)b->ptr); + stringbg(f->b, pt, text, ZP, f->font, (char*)b->ptr, back, ZP); pt.x += b->wid; } } @@ -55,7 +54,7 @@ frdrawsel(Frame *f, Point pt, ulong p0, ulong p1, int issel) frdrawsel0(f, pt, p0, p1, back, text); } -void +Point frdrawsel0(Frame *f, Point pt, ulong p0, ulong p1, Image *back, Image *text) { Frbox *b; @@ -76,6 +75,7 @@ frdrawsel0(Frame *f, Point pt, ulong p0, ulong p1, Image *back, Image *text) if(p >= p0){ qt = pt; _frcklinewrap(f, &pt, b); + /* fill in the end of a wrapped line */ if(pt.y > qt.y) draw(f->b, Rect(qt.x, qt.y, f->r.max.x, pt.y), back, nil, qt); } @@ -99,7 +99,7 @@ frdrawsel0(Frame *f, Point pt, ulong p0, ulong p1, Image *back, Image *text) x = f->r.max.x; draw(f->b, Rect(pt.x, pt.y, x, pt.y+f->font->height), back, nil, pt); if(b->nrune >= 0) - stringn(f->b, pt, text, ZP, f->font, ptr, nr); + stringnbg(f->b, pt, text, ZP, f->font, ptr, nr, back, ZP); pt.x += w; Continue: b++; @@ -112,6 +112,29 @@ frdrawsel0(Frame *f, Point pt, ulong p0, ulong p1, Image *back, Image *text) if(pt.y > qt.y) draw(f->b, Rect(qt.x, qt.y, f->r.max.x, pt.y), back, nil, qt); } + return pt; +} + +void +frredraw(Frame *f) +{ + int ticked; + Point pt; + + if(f->p0 == f->p1){ + ticked = f->ticked; + if(ticked) + frtick(f, frptofchar(f, f->p0), 0); + frdrawsel0(f, frptofchar(f, 0), 0, f->nchars, f->cols[BACK], f->cols[TEXT]); + if(ticked) + frtick(f, frptofchar(f, f->p0), 1); + return; + } + + pt = frptofchar(f, 0); + pt = frdrawsel0(f, pt, 0, f->p0, f->cols[BACK], f->cols[TEXT]); + pt = frdrawsel0(f, pt, f->p0, f->p1, f->cols[HIGH], f->cols[HTEXT]); + pt = frdrawsel0(f, pt, f->p1, f->nchars, f->cols[BACK], f->cols[TEXT]); } void @@ -150,7 +173,7 @@ _frdraw(Frame *f, Point pt) if(b->nrune > 0){ n = _frcanfit(f, pt, b); if(n == 0) - drawerror(f->display, "_frcanfit==0"); + break; if(n != b->nrune){ _frsplitbox(f, nb, n); b = &f->box[nb]; diff --git a/src/libframe/frinsert.c b/src/libframe/frinsert.c index 8ca39fcf..ce9bfa0a 100644 --- a/src/libframe/frinsert.c +++ b/src/libframe/frinsert.c @@ -261,7 +261,7 @@ frinsert(Frame *f, Rune *sp, Rune *ep, ulong p0) else col = f->cols[BACK]; frselectpaint(f, ppt0, ppt1, col); - _frredraw(&frame, ppt0); + _frdrawtext(&frame, ppt0, f->cols[TEXT], col); _fraddbox(f, nn0, frame.nbox); for(n=0; n<frame.nbox; n++) f->box[nn0+n] = frame.box[n]; |