swk

static widget kit
git clone git://git.suckless.org/swk
Log | Files | Refs | README | LICENSE

commit 59b5dc6b98525f6420838e80fbf52776d1c26184
parent 28b8e9f7f33c290ba6ef92617ecd32801fa0e3b7
Author: pancake <pancake@nopcode.org>
Date:   Fri, 27 Aug 2010 20:32:23 +0200

honor user-defined font in X11 backend
remove warnings
Diffstat:
gi_x11.c | 9+++++----
text.c | 9+++------
2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/gi_x11.c b/gi_x11.c @@ -201,6 +201,7 @@ swk_gi_event(SwkWindow *w, int dowait) { return ret; } +void swk_gi_clear() { Rect r = {0}; XGetWindowAttributes(dc->dpy, window, &wa); @@ -218,7 +219,6 @@ swk_gi_flip() { /* -- drawing primitives -- */ void swk_gi_line(int x1, int y1, int x2, int y2, int color) { - Rect r = { x1, y1, x2, y2 }; XSetForeground(dc->dpy, dc->gc, col[color]); XDrawLine(dc->dpy, dc->canvas, dc->gc, x1*fs, y1*fs, (x1+x2)*fs, (y1+y2)*fs); } @@ -263,9 +263,10 @@ swk_gi_text(Rect r, const char *text) { if(!text||!*text) return; XSetForeground(dc->dpy, dc->gc, col[ColorFG]); - if(dc->font.xfont) - XSetFont(dc->dpy, dc->gc, dc->font.xfont->fid); - XDrawString(dc->dpy, dc->canvas, dc->gc, 5+r.x*fs, ((1+r.y)*fs)-3, text, strlen (text)); + // TODO: use libdraw to get length of string and support utf8.. + // TODO: retrieve character width before rendering + XmbDrawString(dc->dpy, dc->canvas, dc->font.set, dc->gc, + 5+(r.x*fs), ((r.y+1)*fs-3), text, strlen(text)); } void diff --git a/text.c b/text.c @@ -95,9 +95,7 @@ text_get(Text *t, int from, int to) { if(to>t->len||to==-1) to = t->len; if (!t->text) - if (t->otext) - t->text = t->otext; - else t->text = ""; + t->text = strdup((t->otext)?t->otext:""); p = strdup (t->text+from); //if(to!=-1) p[to-from] = '\0'; return p; @@ -188,8 +186,7 @@ text_sel_mode(Text *t, int enable) { void swk_text(SwkEvent *e) { Text *t = (Text*)e->box->data; - int row, len, key; - char *ptr; + int row, key; text_init(e->box->data, e->box->text); text_sync(e->box->data); @@ -277,7 +274,7 @@ swk_text(SwkEvent *e) { else len += col+1; #endif #endif - Text* t = e->box->data; + //Text* t = e->box->data; text_sync(e->box->data); Rect r = { (e->box->r.x*3)+col, e->box->r.y+row, 1, 1};