modify the tell function to respect spaces
This commit is contained in:
parent
fb07026639
commit
a41c25c0f5
|
@ -66,8 +66,8 @@ 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;
|
char *tok, *ntok, buf[8];
|
||||||
int i, color;
|
int i = 0, color = 0;
|
||||||
ssize_t command_len = a_strlen(command) + 1;
|
ssize_t command_len = a_strlen(command) + 1;
|
||||||
char* text = p_new(char, command_len);
|
char* text = p_new(char, command_len);
|
||||||
|
|
||||||
|
@ -75,29 +75,40 @@ textbox_tell(Widget *widget, char *command)
|
||||||
if (d->text)
|
if (d->text)
|
||||||
p_delete(&d->text);
|
p_delete(&d->text);
|
||||||
|
|
||||||
for(tok = strtok(command, " "), i = color = 0; tok; tok = strtok(NULL, " "), i++)
|
for(tok = command ; tok; tok = ntok, i++)
|
||||||
{
|
{
|
||||||
|
/* get next token */
|
||||||
|
ntok = strchr(tok + 1, ' ');
|
||||||
|
|
||||||
|
/* if not first time in the loop, drop the space and put it in the
|
||||||
|
* string */
|
||||||
|
if(i)
|
||||||
|
{
|
||||||
|
tok++;
|
||||||
|
a_strcat(text, command_len, " ");
|
||||||
|
}
|
||||||
|
|
||||||
if(*tok == '#' && i < 2)
|
if(*tok == '#' && i < 2)
|
||||||
{
|
{
|
||||||
|
if(ntok)
|
||||||
|
a_strncpy(buf, ssizeof(buf), tok, ntok - tok);
|
||||||
switch(i)
|
switch(i)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
d->fg = initxcolor(get_phys_screen(widget->statusbar->screen),
|
d->fg = initxcolor(get_phys_screen(widget->statusbar->screen),
|
||||||
tok);
|
buf);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
d->bg = initxcolor(get_phys_screen(widget->statusbar->screen),
|
d->bg = initxcolor(get_phys_screen(widget->statusbar->screen),
|
||||||
tok);
|
buf);
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
color++;
|
color++;
|
||||||
}
|
}
|
||||||
|
else if(ntok)
|
||||||
|
a_strncat(text, command_len, tok, ntok - tok);
|
||||||
else
|
else
|
||||||
{
|
|
||||||
if(i > color)
|
|
||||||
a_strcat(text, command_len, " ");
|
|
||||||
a_strcat(text, command_len, tok);
|
a_strcat(text, command_len, tok);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
d->text = a_strdup(text);
|
d->text = a_strdup(text);
|
||||||
|
|
Loading…
Reference in New Issue