Added a way to reset the bg/fg color.

This commit is contained in:
LemonBoy 2012-07-16 11:56:09 +02:00
parent fbaf85f480
commit fcf64daac8
2 changed files with 5 additions and 2 deletions

View File

@ -20,6 +20,7 @@ To draw a backslash just backslash escape it (\\\\).
```
f<0-9> Selects the text foreground color from the palette.
b<0-9> Selects the text background color from the palette.
To reset the bg/fg color just pass 'r' as color index.
l Aligns the text to the left.
c Aligns the text to the center.

6
bar.c
View File

@ -67,8 +67,10 @@ parse (char *text)
switch (*p++) {
case 0x0: return; /* EOL */
case 0xA: return; /* NL */
case 'f': if (isdigit (*p)) xcb_change_gc (c, gc, XCB_GC_FOREGROUND, (const uint32_t []){ pal[*p-'0'] }); p++; break;
case 'b': if (isdigit (*p)) xcb_change_gc (c, gc, XCB_GC_BACKGROUND, (const uint32_t []){ pal[*p-'0'] }); p++; break;
case 'f': if (*p == 'r') *p = '1'; if (isdigit (*p))
xcb_change_gc (c, gc, XCB_GC_FOREGROUND, (const uint32_t []){ pal[*p-'0'] }); p++; break;
case 'b': if (*p == 'r') *p = '0'; if (isdigit (*p))
xcb_change_gc (c, gc, XCB_GC_BACKGROUND, (const uint32_t []){ pal[*p-'0'] }); p++; break;
case 'l': align = 0; pos_x = 0; break;
case 'c': align = 1; pos_x = 0; break;
case 'r': align = 2; pos_x = 0; break;