Add \p[] sequence: \p[left/right;w;h;bord;val;valmax;bg;fg] OR x;y
This commit is contained in:
parent
73e013266b
commit
cf701a43b6
47
src/status.c
47
src/status.c
@ -90,9 +90,9 @@ void
|
|||||||
status_parse(struct status_ctx *ctx)
|
status_parse(struct status_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct status_seq *sq, *prev = NULL;
|
struct status_seq *sq, *prev = NULL;
|
||||||
int i, shift = 0;
|
int i, tmp, shift = 0;
|
||||||
char *dstr = xstrdup(ctx->status), *sauv = dstr;
|
char *dstr = xstrdup(ctx->status), *sauv = dstr;
|
||||||
char type, *p, *pp, *end, *arg[6] = { NULL };
|
char type, *p, *pp, *end, *arg[10] = { NULL };
|
||||||
|
|
||||||
for(; *dstr; ++dstr)
|
for(; *dstr; ++dstr)
|
||||||
{
|
{
|
||||||
@ -107,7 +107,7 @@ status_parse(struct status_ctx *ctx)
|
|||||||
while(*(end - 1) == '\\')
|
while(*(end - 1) == '\\')
|
||||||
end = strchr(end + 1, ']');
|
end = strchr(end + 1, ']');
|
||||||
|
|
||||||
if(!(strchr("sRi", *p)) || !end)
|
if(!(strchr("sRpi", *p)) || !end)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Then parse & list it */
|
/* Then parse & list it */
|
||||||
@ -144,6 +144,26 @@ status_parse(struct status_ctx *ctx)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Progress bar sequence: \p[left/right;w;h;bord;val;valmax;bg;fg] OR x;y
|
||||||
|
*/
|
||||||
|
case 'p':
|
||||||
|
i = parse_args(p + 2, ';', ']', 9, arg);
|
||||||
|
STATUS_CHECK_ARGS(i, 7, 8, dstr, end);
|
||||||
|
sq = status_new_seq(type, i, 7, arg, &shift);
|
||||||
|
|
||||||
|
sq->geo.w = ATOI(arg[1 + shift]);
|
||||||
|
sq->geo.h = ATOI(arg[2 + shift]);
|
||||||
|
|
||||||
|
sq->data[0] = ATOI(arg[3 + shift]); /* Border */
|
||||||
|
sq->data[1] = ((tmp = ATOI(arg[4 + shift])) ? tmp : 1); /* Value */
|
||||||
|
sq->data[2] = ATOI(arg[5 + shift]); /* Value Max */
|
||||||
|
|
||||||
|
sq->color = color_atoh(arg[6 + shift]);
|
||||||
|
sq->color2 = color_atoh(arg[7 + shift]);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Image sequence: \i[left/right;w;h;/path/img] OR \i[x;y;w;h;/path/img]
|
* Image sequence: \i[left/right;w;h;/path/img] OR \i[x;y;w;h;/path/img]
|
||||||
*/
|
*/
|
||||||
@ -200,6 +220,7 @@ status_apply_list(struct status_ctx *ctx)
|
|||||||
{
|
{
|
||||||
struct status_seq *sq;
|
struct status_seq *sq;
|
||||||
struct mousebind *m;
|
struct mousebind *m;
|
||||||
|
struct geo g;
|
||||||
int left = 0, right = 0, w, h;
|
int left = 0, right = 0, w, h;
|
||||||
|
|
||||||
SLIST_FOREACH(sq, &ctx->statushead, next)
|
SLIST_FOREACH(sq, &ctx->statushead, next)
|
||||||
@ -242,6 +263,26 @@ status_apply_list(struct status_ctx *ctx)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* Progress */
|
||||||
|
case 'p':
|
||||||
|
if(sq->align != NoAlign)
|
||||||
|
sq->geo.y = (ctx->barwin->geo.h >> 1) - (sq->geo.h >> 1);
|
||||||
|
|
||||||
|
STATUS_ALIGN(sq->align);
|
||||||
|
|
||||||
|
draw_rect(ctx->barwin->dr, &sq->geo, sq->color);
|
||||||
|
|
||||||
|
/* Progress bar geo */
|
||||||
|
g.x = sq->geo.x + sq->data[0];
|
||||||
|
g.y = sq->geo.y + sq->data[0];
|
||||||
|
g.w = sq->geo.w - sq->data[0] - sq->data[0];
|
||||||
|
g.w /= ((float)sq->data[2] / (float)sq->data[1]);
|
||||||
|
g.h = sq->geo.h - sq->data[0] - sq->data[0];
|
||||||
|
|
||||||
|
draw_rect(ctx->barwin->dr, &g, sq->color2);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
/* Image */
|
/* Image */
|
||||||
#ifdef HAVE_IMLIB2
|
#ifdef HAVE_IMLIB2
|
||||||
case 'i':
|
case 'i':
|
||||||
|
|||||||
@ -101,9 +101,10 @@ struct status_seq
|
|||||||
{
|
{
|
||||||
struct geo geo;
|
struct geo geo;
|
||||||
enum position align;
|
enum position align;
|
||||||
|
int data[4];
|
||||||
char type;
|
char type;
|
||||||
char *str;
|
char *str;
|
||||||
Color color;
|
Color color, color2;
|
||||||
SLIST_HEAD(, mousebind) mousebinds;
|
SLIST_HEAD(, mousebind) mousebinds;
|
||||||
SLIST_ENTRY(status_seq) next;
|
SLIST_ENTRY(status_seq) next;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user