apply pango markup to colored text
This commit is contained in:
parent
8d458870d9
commit
73a9622c8e
23
libs/draw.c
23
libs/draw.c
|
@ -37,6 +37,7 @@ drawitem(struct item *item, int x, int y, int w)
|
|||
int fg = 7;
|
||||
int bg = 0;
|
||||
int bgfg = 0;
|
||||
int ignore = 0;
|
||||
int ib = 0;
|
||||
|
||||
if (item == sel) {
|
||||
|
@ -56,10 +57,8 @@ drawitem(struct item *item, int x, int y, int w)
|
|||
if (item->text[rd + alen + 2] == 'm') { /* character is 'm' which is the last character in the sequence */
|
||||
buffer[wr] = '\0'; /* clear out character */
|
||||
|
||||
/* draw text */
|
||||
rw = TEXTWM(buffer) - lrpad;
|
||||
apply_fribidi(buffer);
|
||||
drw_text(drw, x, y, rw + lp, bh, lp, isrtl ? fribidi_text : buffer, 0, pango_item ? True : False);
|
||||
rw = pango_item ? TEXTWM(buffer) : TEXTW(buffer) - lrpad;
|
||||
drw_text(drw, x, y, rw + lp, bh, lp, buffer, 0, pango_item ? True : False);
|
||||
|
||||
x += rw + lp;
|
||||
ib = 1;
|
||||
|
@ -70,6 +69,22 @@ drawitem(struct item *item, int x, int y, int w)
|
|||
/* parse hex colors in scm */
|
||||
while (*ep != 'm') {
|
||||
unsigned v = strtoul(ep + 1, &ep, 10);
|
||||
if (ignore)
|
||||
continue;
|
||||
if (bgfg) {
|
||||
if (bgfg < 4 && v == 5) {
|
||||
bgfg <<= 1;
|
||||
continue;
|
||||
}
|
||||
if (bgfg == 4)
|
||||
scm[0] = textclrs[fg = v];
|
||||
else if (bgfg == 6)
|
||||
scm[1] = textclrs[bg = v];
|
||||
ignore = 1;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (v == 1) {
|
||||
fg |= 8;
|
||||
scm[0] = textclrs[fg];
|
||||
|
|
|
@ -136,7 +136,7 @@ static char col_sgrcolor14[] = "#00ffff"; /* SGR color #14 */
|
|||
static char col_sgrcolor15[] = "#ffffff"; /* SGR color #15 */
|
||||
|
||||
/* Pango options */
|
||||
static int pango_item = 1; /* Enable support for pango markup for the items */
|
||||
static int pango_item = 0; /* Enable support for pango markup for the items */
|
||||
static int pango_highlight = 1; /* Enable support for pango markup for the highlighting */
|
||||
static int pango_prompt = 1; /* Enable support for pango markup for the prompt */
|
||||
static int pango_input = 1; /* Enable support for pango markup for user input */
|
||||
|
|
Loading…
Reference in a new issue