From 128690779269ff82b68df2306e4cbef8ec69bbd1 Mon Sep 17 00:00:00 2001 From: gotmor Date: Thu, 27 Dec 2007 11:11:20 +0000 Subject: vertical meters git-svn-id: http://dzen.googlecode.com/svn/trunk@180 f2baff5b-bf2c-0410-a398-912abdc3d8b2 --- gadgets/gdbar.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/gadgets/gdbar.c b/gadgets/gdbar.c index 89cd7ec..c04bf79 100644 --- a/gadgets/gdbar.c +++ b/gadgets/gdbar.c @@ -29,16 +29,17 @@ THE SOFTWARE. #include #include -#define MAXLEN 512 +#define MAXLEN 1024 -static void pbar (const char *, double, int, int, int, int); +static void pbar (const char *, double, int, int, int, int, int, int, int); +enum style { norm, outlined, vertical }; char *bg, *fg; - static void -pbar(const char* label, double perc, int maxc, int height, int pnl, int mode) { +pbar(const char* label, double perc, int maxc, int height, int segw, int segh, int segb, int pnl, int mode) { int i, rp; + int segs, segsa; double l; @@ -51,12 +52,26 @@ pbar(const char* label, double perc, int maxc, int height, int pnl, int mode) { else rp = (int)perc; - if(mode) + if(mode == outlined) printf("%s%3d%% ^ib(1)^fg(%s)^ro(%dx%d)^p(%d)^fg(%s)^r(%dx%d)^p(%d)^ib(0)^fg()%s", label ? label : "", rp, bg, (int)maxc, height, -1*(maxc-1), fg, (int)l, height-2, maxc-(int)l-1, pnl ? "\n" : ""); + else if(mode == vertical) { + segs = height / (segh + segb); + segsa = rp * segs / 100; + + printf("%s^ib(1)", label ? label : ""); + for(i=0; i < segs; i++) { + if(i