diff options
-rw-r--r-- | README | 83 | ||||
-rw-r--r-- | README.dzen | 61 | ||||
-rw-r--r-- | bitmaps/battery.xbm | 4 | ||||
-rw-r--r-- | bitmaps/volume.xbm | 6 | ||||
-rw-r--r-- | config.mk | 2 | ||||
-rw-r--r-- | draw.c | 68 |
6 files changed, 158 insertions, 66 deletions
@@ -1,5 +1,5 @@ ================================== - dzen, (c) 2007 by Robert Manea + dzen, (c) 2007 by Robert Manea ================================== A general purpose messaging, notification and menu program @@ -9,7 +9,7 @@ The "gadgets" subdirectory contains some tools that you can use in combination with dzen. Script archive with a collection of interesting ideas: - http://gotmor.googlepages.com/dzenscriptarchive +^fg(lightblue) http://gotmor.googlepages.com/dzenscriptarchive @@ -26,6 +26,8 @@ Features * menu functionality + * in-text formating language + * flexible event/action mechanism * hideable, collapsable @@ -77,10 +79,10 @@ dzen accepts a couple of options: -tw title window width -sa alignment of slave window, see "-ta" -l lines, see (1) - -e events and actions, see (2) - -m menu mode, see (3) + -e events and actions, ^fg(green)see (2) + -m menu mode, ^fg(green)see (3) -u update contents of title and - slave window simultaneously, see (4) + slave window simultaneously, ^fg(green)see (4) -p persist EOF (optional timeout in seconds) -x x position -y y position @@ -88,12 +90,12 @@ dzen accepts a couple of options: -xs number of Xinerama screen -v version information - For dynamic color support see (5). + see (5) for the in-text formating language. Window layout ------------- +------------- Dzen's window layout is as follows: @@ -146,8 +148,8 @@ A4: Sure, see "(4) Simultaneous updates". Q5: Can i chnage color of my input at runtime? -A5: Yes, you can change both background and foreground colors. - See "(5) Dynamic color support" +A5: Yes, you can change both background and foreground colors and + much more See "(5) In-Text formating language" Q6: Can I use dzen as a menu? @@ -156,11 +158,6 @@ A6: Yes, both vertical and horizontal menus are supported. See "(3) Menu" for further details. -Q7; What is the expected format to the '-fn' option? - -A7: Run 'xfontsel' or 'xlsfonts'. These should come with your X - distribution by default. - Termination: @@ -204,7 +201,7 @@ and down if the content exceeds the window height (default action). (2) Option '-e': Events and actions ----------------------------------- +----------------------------------- dzen allows the user to associate actions to events. @@ -222,7 +219,7 @@ An example: button1=exec:xterm:firefox; on Button1 event (Button1 press on the mouse) execute xterm and firefox. - (Note: xterm and firefox are options to the exec action) + Note: xterm and firefox are options to the exec action entertitle=uncollapse,unhide; on entertitle (mouse pointer enters the title window) uncollapse @@ -374,32 +371,60 @@ of lines to the slave window as defined by the parameter to '-l'. -(5) Dynamic color support: --------------------------- +(5) In-text formating language: +------------------------------- -This feature allows to dynamically (at runtime) set foreground and -background colors for dzen's input (colored text) working in all -modes (title only, slave window and menu mode). +This feature allows to dynamically (at runtime) format the text dzen +displays. -Syntax: +Currently the following commands are supported: -Foreground color: ^fg(color) -Background color: ^bg(color) + ^fg(color) set foreground color + ^bg(color) set background color + ^i(path) draw icon specified by path + ^r(WIDTHxHEIGHT) draw a rectangle with the dimensions + WIDTH and HEIGHT These commands can appear anywhere and in any combination in dzen's -input. The color can be specified either as symbolic name (e.g. red, +input. + +The color can be specified either as symbolic name (e.g. red, darkgreen, etc.) or as #rrggbb hex-value (e.g. #ffffaa). -Doubling the '^' character removes the special meaning from it. +Icons must be in the XBM format, see the "bitmaps" directory for some +sample icons. With the standard "bitmap" application you can easily draw +your own icons, though there are lots floating around on your harddisk +or on the web. + +Rectangles will be truncated to the maximum possible size if you specify +a size bigger than dzen's window. + +Doubling the '^^' character removes the special meaning from it. + Some examples: - ^fg(red)I'm red text ^fg(blue)I am blue + Input: + ^fg(red)I'm red text ^fg(blue)I am blue + + + Input: + ^bg(#ffaaaa)The ^fg(yellow)text to ^bg(blue)^fg(orange)colorize + + + Input: + ^fg(grey70)Some text containing ^^ characters + + + Input for icons: + ^i(bitmaps/envelope.xbm) I am an envelope ^fg(yellow)and ^i(bitmaps/battery.xbm) I'm a baterry. + + + Input for rectangles: + 6x4 rectangle ^r(6x4) ^fg(red)12x8 ^r(12x8) ^fg(yellow)and finally 100x15 ^r(100x15) - ^bg(#ffaaaa)The ^fg(yellow)text to ^bg(blue)^fg(orange)colorize - ^fg(grey70)Some text containing ^^ characters diff --git a/README.dzen b/README.dzen index 8d279e2..bc002c4 100644 --- a/README.dzen +++ b/README.dzen @@ -26,6 +26,8 @@ Script archive with a collection of interesting ideas: * menu functionality + * in-text formating language + * flexible event/action mechanism * hideable, collapsable @@ -88,7 +90,7 @@ dzen accepts a couple of options: -xs number of Xinerama screen -v version information - For dynamic color support ^fg(green)see (5). + ^fg(green)see (5)^fg(#5FBF77) for the in-text formating language. @@ -146,8 +148,8 @@ A4: Sure, see "(4) Simultaneous updates". Q5: Can i chnage color of my input at runtime? -A5: Yes, you can change both background and foreground colors. - See "(5) Dynamic color support" +A5: Yes, you can change both background and foreground colors and + much more See "(5) In-Text formating language" Q6: Can I use dzen as a menu? @@ -369,25 +371,38 @@ of lines to the slave window as defined by the parameter to '-l'. -^fg(green)(5) Dynamic color support: -^fg(green)-------------------------- +^fg(green)(5) In-text formating language: +^fg(green)------------------------------- -This feature allows to dynamically (at runtime) set foreground and -background colors for dzen's input (colored text) working in all -modes (title only, slave window and menu mode). +This feature allows to dynamically (at runtime) format the text dzen +displays. -Syntax: +Currently the following commands are supported: -Foreground color: ^^fg(color) -Background color: ^^bg(color) + ^^fg(color) set foreground color + ^^bg(color) set background color + ^^i(path) draw icon specified by path + ^^r(WIDTHxHEIGHT) draw a rectangle with the dimensions + WIDTH and HEIGHT These commands can appear anywhere and in any combination in dzen's -input. The color can be specified either as symbolic name (e.g. red, +input. + +The color can be specified either as symbolic name (e.g. red, darkgreen, etc.) or as #rrggbb hex-value (e.g. #ffffaa). +Icons must be in the XBM format, see the "bitmaps" directory for some +sample icons. With the standard "bitmap" application you can easily draw +your own icons, though there are lots floating around on your harddisk +or on the web. + +Rectangles will be truncated to the maximum possible size if you specify +a size bigger than dzen's window. + Doubling the '^^' character removes the special meaning from it. + Some examples: Input: @@ -397,19 +412,33 @@ Some examples: ^fg(red)I'm red text ^fg(blue)I am blue - Input: + Input: ^^bg(#ffaaaa)The ^^fg(yellow)text to ^^bg(blue)^^fg(orange)colorize - Resulting in: + Resulting in: ^bg(#ffaaaa)The ^fg(yellow)text to ^bg(blue)^fg(orange)colorize - Input: + Input: ^^fg(grey70)Some text containing ^^^^ characters - Resulting in: + Resulting in: ^fg(grey70)Some text containing ^^ characters + Input for icons: + ^^i(bitmaps/envelope.xbm) I am an envelope ^^fg(yellow)and ^^i(bitmaps/battery.xbm) I'm a baterry. + + Resulting in: + ^i(bitmaps/envelope.xbm) I am an envelope ^fg(yellow)and ^i(bitmaps/battery.xbm) I'm a baterry. + + Input for rectangles: + 6x4 rectangle ^^r(6x4) ^^fg(red)12x8 ^^r(12x8) ^^fg(yellow)and finally 100x15 ^^r(100x15) + + Resulting in: + 6x4 rectangle ^r(6x4) ^fg(red)12x8 ^r(12x8) ^fg(yellow)and finally 100x15 ^r(100x15) + + + ^fg(green)Examples: diff --git a/bitmaps/battery.xbm b/bitmaps/battery.xbm index 745c389..ca37847 100644 --- a/bitmaps/battery.xbm +++ b/bitmaps/battery.xbm @@ -1,6 +1,6 @@ #define battery_width 16 #define battery_height 16 static unsigned char battery_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x1f, - 0xfc, 0x11, 0xfc, 0x71, 0xfc, 0x71, 0xfc, 0x71, 0xfc, 0x11, 0xfc, 0x1f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x1f, 0xfc, 0x11, + 0xfc, 0x71, 0xfc, 0x71, 0xfc, 0x71, 0xfc, 0x11, 0xfc, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/bitmaps/volume.xbm b/bitmaps/volume.xbm index b4ee0ec..5ab8281 100644 --- a/bitmaps/volume.xbm +++ b/bitmaps/volume.xbm @@ -1,6 +1,6 @@ #define volume_width 16 #define volume_height 16 static unsigned char volume_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x1b, 0x60, 0x1b, - 0x60, 0x1b, 0x6c, 0x1b, 0x6c, 0x1b, 0x6c, 0x1b, 0x60, 0x1b, 0x60, 0x1b, - 0x00, 0x1b, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x1b, 0x60, 0x1b, 0x60, 0x1b, + 0x6c, 0x1b, 0x6c, 0x1b, 0x6c, 0x1b, 0x60, 0x1b, 0x60, 0x1b, 0x00, 0x1b, + 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; @@ -1,5 +1,5 @@ # dzen version -VERSION = 0.6.1 +VERSION = 0.7.0 # Customize below to fit your system @@ -10,7 +10,7 @@ #include <string.h> /* command types for the in text parser */ -enum ctype {bg, fg, icon}; +enum ctype {bg, fg, icon, rect}; int get_tokval(const char* line, char **retdata); int get_token(const char* line, int * t, char **tval); @@ -145,6 +145,12 @@ get_token(const char *line, int * t, char **tval) { next_pos = get_tokval(line+off, &tokval); *t = icon; } + /* ^r(widthxheight) */ + if((*line == 'r') && (*(line+1) == '(')) { + off = 2; + next_pos = get_tokval(line+off, &tokval); + *t = rect; + } *tval = tokval; return next_pos+off; @@ -166,9 +172,25 @@ set_opts(int type, char * value, int reverse) { } } +static void +get_rect_vals(char *s, int *w, int *h) { + int i; + char buf[128]; + + *w = 0; *h = 0; + + for(i=0; (s[i] != 'x') && i<128; i++) { + buf[i] = s[i]; + } + buf[++i] = '\0'; + *w = atoi(buf); + *h = atoi(s+i); +} + char * parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { unsigned int bm_w, bm_h, bm_xh, bm_yh; + int rectw, recth; int i, next_pos=0, j=0, px=0, py=0, xorig, h=0, tw, ow; char lbuf[MAX_LINE_LEN], *rbuf = NULL; int t=-1; @@ -189,8 +211,8 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { } /* parse line and render text */ else { - h = dzen.font.ascent + dzen.font.descent; - py = dzen.font.ascent + (dzen.line_height - h) / 2;; + h = dzen.font.height; + py = dzen.font.ascent + (dzen.line_height - h) / 2; xorig = 0; if(lnr != -1) { @@ -248,16 +270,25 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { else { if(t != -1 && tval){ if(t == icon) { - if((XReadBitmapFile(dzen.dpy, pm, tval, &bm_w, - &bm_h, &bm, &bm_xh, &bm_yh) == BitmapSuccess) - && ((h/2 + px + bm_w) < dzen.w)) { - XCopyPlane(dzen.dpy, bm, pm, dzen.tgc, - 0, 0, bm_w, bm_h, px, - dzen.line_height > bm_h ? (dzen.line_height - bm_h)/2 : 0, 1); - XFreePixmap(dzen.dpy, bm); - px += bm_w; + if(t == icon) { + if(XReadBitmapFile(dzen.dpy, pm, tval, &bm_w, + &bm_h, &bm, &bm_xh, &bm_yh) == BitmapSuccess + && (h/2 + px + bm_w < dzen.w)) { + XCopyPlane(dzen.dpy, bm, pm, dzen.tgc, + 0, 0, bm_w, bm_h, px, + dzen.line_height >= bm_h ? (dzen.line_height - bm_h)/2 : 0, 1); + XFreePixmap(dzen.dpy, bm); + px += bm_w; + } } } + else if(t == rect) { + get_rect_vals(tval, &rectw, &recth); + rectw = rectw+px > dzen.w ? dzen.w-px : rectw; + recth = recth > dzen.line_height ? dzen.line_height : recth; + XFillRectangle(dzen.dpy, pm, dzen.tgc, px, (dzen.line_height - recth)/2, rectw, recth); + px += rectw; + } else set_opts(t, tval, reverse); } @@ -280,9 +311,9 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { if(dzen.font.set) XmbDrawImageString(dzen.dpy, pm, dzen.font.set, - dzen.tgc, px, py, lbuf, tw); + dzen.tgc, px, py, lbuf, strlen(lbuf)); else - XDrawImageString(dzen.dpy, pm, dzen.tgc, px, py, lbuf, tw); + XDrawImageString(dzen.dpy, pm, dzen.tgc, px, py, lbuf, strlen(lbuf)); px += tw; } @@ -315,6 +346,13 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { px += bm_w; } } + else if(t == rect) { + get_rect_vals(tval, &rectw, &recth); + rectw = rectw+px > dzen.w ? dzen.w-px : rectw; + recth = recth > dzen.line_height ? dzen.line_height : recth; + XFillRectangle(dzen.dpy, pm, dzen.tgc, px, (dzen.line_height - recth)/2, rectw, recth); + px += rectw; + } else set_opts(t, tval, reverse); } @@ -337,9 +375,9 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { if(dzen.font.set) XmbDrawImageString(dzen.dpy, pm, dzen.font.set, - dzen.tgc, px, py, lbuf, tw); + dzen.tgc, px, py, lbuf, strlen(lbuf)); else - XDrawImageString(dzen.dpy, pm, dzen.tgc, px, py, lbuf, tw); + XDrawImageString(dzen.dpy, pm, dzen.tgc, px, py, lbuf, strlen(lbuf)); px += tw; |