tell textbox widget colors
usage is simple: ,---- | echo "<screen> widget_tell <mytextbox> #[fg_color] #[bg_color] <text>" | awesome-client | e.g. | echo "0 widget_tell t normal behaviour" | awesome-client | echo "0 widget_tell t #ff0000 red text on default background" | awesome-client | echo "0 widget_tell t #ffffff #ff0000 white text on red background" | awesome-client | ... `---- the fg and bg colors are optional. if not given, the last state is used.
This commit is contained in:
parent
44e6edf4d1
commit
079569e6b4
|
@ -66,10 +66,42 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
static void
|
static void
|
||||||
textbox_tell(Widget *widget, char *command)
|
textbox_tell(Widget *widget, char *command)
|
||||||
{
|
{
|
||||||
|
char *tok;
|
||||||
|
int i, color;
|
||||||
|
ssize_t command_len = a_strlen(command) + 1;
|
||||||
|
char* text = p_new(char, command_len);
|
||||||
|
|
||||||
Data *d = widget->data;
|
Data *d = widget->data;
|
||||||
if (d->text)
|
if (d->text)
|
||||||
p_delete(&d->text);
|
p_delete(&d->text);
|
||||||
d->text = a_strdup(command);
|
|
||||||
|
for(tok = strtok(command, " "), i = color = 0; tok; tok = strtok(NULL, " "), i++)
|
||||||
|
{
|
||||||
|
if(*tok == '#' && i < 2)
|
||||||
|
{
|
||||||
|
switch(i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
d->fg = initxcolor(get_phys_screen(widget->statusbar->screen),
|
||||||
|
tok);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
d->bg = initxcolor(get_phys_screen(widget->statusbar->screen),
|
||||||
|
tok);
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
color++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(i > color)
|
||||||
|
a_strcat(text, command_len, " ");
|
||||||
|
a_strcat(text, command_len, tok);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
d->text = a_strdup(text);
|
||||||
|
p_delete(&text);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget *
|
Widget *
|
||||||
|
|
Loading…
Reference in New Issue