use TEXTWM for pango

This commit is contained in:
speedie 2023-03-02 18:25:28 +01:00
parent d5ae45424d
commit 38b568b997
3 changed files with 12 additions and 10 deletions

View file

@ -128,9 +128,9 @@ drawmenu(void)
int rarrowWidth = 0; int rarrowWidth = 0;
int itemWidth = 0; int itemWidth = 0;
if (!hidemode) modeWidth = TEXTW(modetext); if (!hidemode) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext);
if (!hidelarrow) larrowWidth = TEXTW(leftarrow); if (!hidelarrow) larrowWidth = pango_leftarrow ? TEXTWM(leftarrow) : TEXTW(leftarrow);
if (!hiderarrow) rarrowWidth = TEXTW(rightarrow); if (!hiderarrow) rarrowWidth = pango_rightarrow ? TEXTWM(rightarrow) : TEXTW(rightarrow);
if (prompt && *prompt) { if (prompt && *prompt) {
if (colorprompt) { if (colorprompt) {
@ -154,6 +154,7 @@ drawmenu(void)
} else if (!passwd && !hideprompt) { } else if (!passwd && !hideprompt) {
apply_fribidi(text); apply_fribidi(text);
drw_text(drw, x, 0, w, bh, lrpad / 2, isrtl ? fribidi_text : text, 0, pango_input ? True : False); drw_text(drw, x, 0, w, bh, lrpad / 2, isrtl ? fribidi_text : text, 0, pango_input ? True : False);
curpos = TEXTW(text) - TEXTW(&text[cursor]); curpos = TEXTW(text) - TEXTW(&text[cursor]);
} }
@ -193,9 +194,9 @@ drawmenu(void)
x += inputw; x += inputw;
w = larrowWidth; w = larrowWidth;
itemWidth = TEXTWM(item->text); itemWidth = pango_item ? TEXTWM(item->text) : TEXTW(item->text);
if (curr->left) { if (curr->left && !hidelarrow) {
drw_setscheme(drw, scheme[SchemeLArrow]); drw_setscheme(drw, scheme[SchemeLArrow]);
drw_text(drw, x, 0, w, bh, lrpad / 2, leftarrow, 0, pango_leftarrow ? True : False); drw_text(drw, x, 0, w, bh, lrpad / 2, leftarrow, 0, pango_leftarrow ? True : False);
} }
@ -205,7 +206,7 @@ drawmenu(void)
for (item = curr; item != next; item = item->right) for (item = curr; item != next; item = item->right)
x = drawitem(item, x, 0, MIN(itemWidth, mw - x - rarrowWidth - numberWidth - modeWidth)); x = drawitem(item, x, 0, MIN(itemWidth, mw - x - rarrowWidth - numberWidth - modeWidth));
if (next) { if (next && !hiderarrow) {
w = rarrowWidth; w = rarrowWidth;
drw_setscheme(drw, scheme[SchemeRArrow]); drw_setscheme(drw, scheme[SchemeRArrow]);

View file

@ -137,6 +137,7 @@ static char col_sgrcolor13[] = "#ff00ff"; /* SGR color #13 */
static char col_sgrcolor14[] = "#00ffff"; /* SGR color #14 */ static char col_sgrcolor14[] = "#00ffff"; /* SGR color #14 */
static char col_sgrcolor15[] = "#ffffff"; /* SGR color #15 */ 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 = 1; /* Enable support for pango markup for the items */
static int pango_highlight = 1; /* Enable support for pango markup for the highlighting */ 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_prompt = 1; /* Enable support for pango markup for the prompt */

View file

@ -286,10 +286,10 @@ calcoffsets(void)
int larrowWidth = 0; int larrowWidth = 0;
int rarrowWidth = 0; int rarrowWidth = 0;
if (!hidematchcount) numberWidth = TEXTW(numbers); if (!hidematchcount) numberWidth = pango_numbers ? TEXTWM(numbers) : TEXTW(numbers);
if (!hidemode) modeWidth = TEXTW(modetext); if (!hidemode) modeWidth = pango_mode ? TEXTWM(modetext) : TEXTW(modetext);
if (!hidelarrow) larrowWidth = TEXTW(leftarrow); if (!hidelarrow) larrowWidth = pango_leftarrow ? TEXTWM(leftarrow) : TEXTW(leftarrow);
if (!hiderarrow) rarrowWidth = TEXTW(rightarrow); if (!hiderarrow) rarrowWidth = pango_rightarrow ? TEXTWM(rightarrow) : TEXTW(rightarrow);
n = mw - (promptw + inputw + larrowWidth + rarrowWidth + modeWidth + numberWidth); n = mw - (promptw + inputw + larrowWidth + rarrowWidth + modeWidth + numberWidth);
} }