changeset: 70:f809cb86d832
tag: tip
user: pancake <pancake_AT_nopcode.org>
date: Fri Aug 27 20:32:23 2010 +0200
files: gi_x11.c text.c
description:
honor user-defined font in X11 backend
remove warnings
diff -r 3fdf91904efe -r f809cb86d832 gi_x11.c
--- a/gi_x11.c Fri Aug 27 20:01:44 2010 +0200
+++ b/gi_x11.c Fri Aug 27 20:32:23 2010 +0200
@@ -201,6 +201,7 @@
return ret;
}
+void
swk_gi_clear() {
Rect r = {0};
XGetWindowAttributes(dc->dpy, window, &wa);
@@ -218,7 +219,6 @@
/* -- 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 @@
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 -r 3fdf91904efe -r f809cb86d832 text.c
--- a/text.c Fri Aug 27 20:01:44 2010 +0200
+++ b/text.c Fri Aug 27 20:32:23 2010 +0200
@@ -95,9 +95,7 @@
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 @@
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 @@
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};
Received on Fri Aug 27 2010 - 20:35:44 CEST
This archive was generated by hypermail 2.2.0 : Fri Aug 27 2010 - 20:36:04 CEST