diff options
| author | bakkeby <[email protected]> | 2020-05-26 20:53:53 +0200 |
|---|---|---|
| committer | bakkeby <[email protected]> | 2020-05-26 20:53:53 +0200 |
| commit | e79aec52c28af424adf4b31ff5d4504303c61383 (patch) | |
| tree | 6f83c7749de60b70082bed83ea3bce420d89533f /patch | |
| parent | fc8434abd1218fc33a4418bcde31cef10c12ede7 (diff) | |
| download | dwm-flexipatch-e79aec52c28af424adf4b31ff5d4504303c61383.tar.gz dwm-flexipatch-e79aec52c28af424adf4b31ff5d4504303c61383.zip | |
Adding status2d patch
Diffstat (limited to 'patch')
| -rw-r--r-- | patch/include.c | 3 | ||||
| -rw-r--r-- | patch/include.h | 3 | ||||
| -rw-r--r-- | patch/status2d.c | 128 | ||||
| -rw-r--r-- | patch/status2d.h | 1 | ||||
| -rw-r--r-- | patch/statuscmd.c | 4 |
5 files changed, 139 insertions, 0 deletions
diff --git a/patch/include.c b/patch/include.c index dc516fe..5113dc6 100644 --- a/patch/include.c +++ b/patch/include.c @@ -122,6 +122,9 @@ #if STACKER_PATCH #include "stacker.c" #endif +#if STATUS2D_PATCH && !STATUSCOLORS_PATCH +#include "status2d.c" +#endif #if STATUSCOLORS_PATCH #include "statuscolors.c" #endif diff --git a/patch/include.h b/patch/include.h index 5164236..bb0197d 100644 --- a/patch/include.h +++ b/patch/include.h @@ -125,6 +125,9 @@ #if STACKER_PATCH #include "stacker.h" #endif +#if STATUS2D_PATCH && !STATUSCOLORS_PATCH +#include "status2d.h" +#endif #if STATUSCMD_PATCH #include "statuscmd.h" #endif diff --git a/patch/status2d.c b/patch/status2d.c new file mode 100644 index 0000000..1ab9043 --- /dev/null +++ b/patch/status2d.c @@ -0,0 +1,128 @@ +int +drawstatusbar(Monitor *m, int bh, char* stext, int stw, int stp) +{ + int ret, i, w, x, len; + short isCode = 0; + char *text; + char *p; + + len = strlen(stext) + 1 ; + if (!(text = (char*) malloc(sizeof(char)*len))) + die("malloc"); + p = text; + memcpy(text, stext, len); + + /* compute width of the status text */ + w = stp * 2;; + i = -1; + while (text[++i]) { + if (text[i] == '^') { + if (!isCode) { + isCode = 1; + text[i] = '\0'; + w += TEXTW(text) - lrpad; + text[i] = '^'; + if (text[++i] == 'f') + w += atoi(text + ++i); + } else { + isCode = 0; + text = text + i + 1; + i = -1; + } + } + } + if (!isCode) + w += TEXTW(text) - lrpad; + else + isCode = 0; + text = p; + w += 2; /* 1px padding on both sides */ + x = m->ww - w - stw + stp; + ret = m->ww - w; + + drw_setscheme(drw, scheme[LENGTH(colors)]); + drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; + drw->scheme[ColBg] = scheme[SchemeNorm][ColBg]; + drw_rect(drw, x - stp - 1, 0, w, bh, 1, 1); + x++; + + /* process status text */ + i = -1; + while (text[++i]) { + if (text[i] == '^' && !isCode) { + isCode = 1; + + text[i] = '\0'; + w = TEXTW(text) - lrpad; + drw_text(drw, x, 0, w, bh, 0, text, 0); + + x += w; + + /* process code */ + while (text[++i] != '^') { + if (text[i] == 'c') { + char buf[8]; + if (i + 7 > len) { + i += 7; + break; + } + memcpy(buf, (char*)text+i+1, 7); + buf[7] = '\0'; + #if ALPHA_PATCH && STATUS2D_NO_ALPHA_PATCH + drw_clr_create(drw, &drw->scheme[ColFg], buf, 0xff); + #elif ALPHA_PATCH + drw_clr_create(drw, &drw->scheme[ColFg], buf, alphas[SchemeNorm][ColFg]); + #else + drw_clr_create(drw, &drw->scheme[ColFg], buf); + #endif // ALPHA_PATCH + i += 7; + } else if (text[i] == 'b') { + char buf[8]; + if (i + 7 > len) { + i += 7; + break; + } + memcpy(buf, (char*)text+i+1, 7); + buf[7] = '\0'; + #if ALPHA_PATCH && STATUS2D_NO_ALPHA_PATCH + drw_clr_create(drw, &drw->scheme[ColBg], buf, 0xff); + #elif ALPHA_PATCH + drw_clr_create(drw, &drw->scheme[ColBg], buf, alphas[SchemeNorm][ColBg]); + #else + drw_clr_create(drw, &drw->scheme[ColBg], buf); + #endif // ALPHA_PATCH + i += 7; + } else if (text[i] == 'd') { + drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; + drw->scheme[ColBg] = scheme[SchemeNorm][ColBg]; + } else if (text[i] == 'r') { + int rx = atoi(text + ++i); + while (text[++i] != ','); + int ry = atoi(text + ++i); + while (text[++i] != ','); + int rw = atoi(text + ++i); + while (text[++i] != ','); + int rh = atoi(text + ++i); + + drw_rect(drw, rx + x, ry, rw, rh, 1, 0); + } else if (text[i] == 'f') { + x += atoi(text + ++i); + } + } + + text = text + i + 1; + i=-1; + isCode = 0; + } + } + + if (!isCode) { + w = TEXTW(text) - lrpad; + drw_text(drw, x, 0, w, bh, 0, text, 0); + } + + drw_setscheme(drw, scheme[SchemeNorm]); + free(p); + + return ret; +}
\ No newline at end of file diff --git a/patch/status2d.h b/patch/status2d.h new file mode 100644 index 0000000..af9c0ed --- /dev/null +++ b/patch/status2d.h @@ -0,0 +1 @@ +static int drawstatusbar(Monitor *m, int bh, char* text, int stw, int stp);
\ No newline at end of file diff --git a/patch/statuscmd.c b/patch/statuscmd.c index bddd529..ddb0c87 100644 --- a/patch/statuscmd.c +++ b/patch/statuscmd.c @@ -1,4 +1,8 @@ +#if STATUS2D_PATCH +static char rawstext[1024]; +#else static char rawstext[256]; +#endif // STATUS2D_PATCH #if !DWMBLOCKS_PATCH static const char statusexport[] = "export BUTTON=-;"; static int statuscmdn; |
