From ac937caaec7921ff526b32594942ba16bf26159f Mon Sep 17 00:00:00 2001 From: Mouad Alami Date: Tue, 12 Sep 2023 15:42:32 +0100 Subject: added bidirectional patch --- dwm.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'dwm.c') diff --git a/dwm.c b/dwm.c index 8ab1c33..9ff14bd 100644 --- a/dwm.c +++ b/dwm.c @@ -21,6 +21,7 @@ * To understand everything else, start reading main(). */ #include +#include #include #include #include @@ -145,6 +146,7 @@ typedef struct { } Rule; /* function declarations */ +static void apply_fribidi(char *str); static void applyrules(Client *c); static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact); static void arrange(Monitor *m); @@ -250,6 +252,7 @@ static void zoom(const Arg *arg); static Client *prevzoom = NULL; static const char broken[] = "broken"; static char stext[256]; +static char fribidi_text[256]; static int statusw; static int statussig; static pid_t statuspid = -1; @@ -303,6 +306,21 @@ static unsigned int scratchtag = 1 << LENGTH(tags); struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; /* function implementations */ +void +apply_fribidi(char *str) +{ + FriBidiStrIndex len = strlen(str); + FriBidiChar logical[256]; + FriBidiChar visual[256]; + FriBidiParType base = FRIBIDI_PAR_ON; + FriBidiCharSet charset; + + charset = fribidi_parse_charset("UTF-8"); + len = fribidi_charset_to_unicode(charset, str, len, logical); + fribidi_log2vis(logical, len, &base, visual, NULL, NULL, NULL); + fribidi_unicode_to_charset(charset, visual, len, fribidi_text); +} + void applyrules(Client *c) { @@ -820,7 +838,8 @@ drawbar(Monitor *m) if ((w = m->ww - tw - x) > bh) { if (m->sel) { drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); - drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); + apply_fribidi(m->sel->name); + drw_text(drw, x, 0, w, bh, lrpad / 2, fribidi_text, 0); if (m->sel->isfloating) drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); } else { -- cgit v1.2.3