From 2d9004765dacb68faeafe7025fdf6f58925c4978 Mon Sep 17 00:00:00 2001 From: gotmor Date: Sun, 13 Jan 2008 00:18:24 +0000 Subject: added ^fn() command to dynamically switch fonts git-svn-id: http://dzen.googlecode.com/svn/trunk@198 f2baff5b-bf2c-0410-a398-912abdc3d8b2 --- draw.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'draw.c') diff --git a/draw.c b/draw.c index 9a83f10..2c1f83f 100644 --- a/draw.c +++ b/draw.c @@ -18,7 +18,7 @@ int otx; /* command types for the in-text parser */ -enum ctype {bg, fg, icon, rect, recto, circle, circleo, pos, abspos, titlewin, ibg, sa}; +enum ctype {bg, fg, icon, rect, recto, circle, circleo, pos, abspos, titlewin, ibg, fn, sa}; int get_tokval(const char* line, char **retdata); int get_token(const char* line, int * t, char **tval); @@ -194,6 +194,12 @@ get_token(const char *line, int * t, char **tval) { next_pos = get_tokval(line+off, &tokval); *t = circleo; } + /* ^fn(fontname) change font, type: fn */ + else if((*line == 'f') && (*(line+1) == 'n') && (*(line+2) == '(')) { + off = 3; + next_pos = get_tokval(line+off, &tokval); + *t = fn; + } /* ^sa(string) sensitive areas, type: sa */ else if((*line == 's') && (*(line+1) == 'a') && (*(line+2) == '(')) { off = 3; @@ -522,6 +528,12 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { lastfg = tval[0] ? (unsigned)getcolor(tval) : dzen.norm[ColFG]; XSetForeground(dzen.dpy, dzen.tgc, lastfg); break; + case fn: + if(tval[0]) + setfont(tval); + else + setfont(dzen.fnt); + break; /* case sa: if(tval[0]) { @@ -702,6 +714,13 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { lastfg = tval[0] ? (unsigned)getcolor(tval) : dzen.norm[ColFG]; XSetForeground(dzen.dpy, dzen.tgc, lastfg); break; + + case fn: + if(tval[0]) + setfont(tval); + else + setfont(dzen.fnt); + break; /* case sa: if(tval[0]) { -- cgit v1.2.3-54-g00ecf