[wiki] [sites] [dwm][patch][bidi] Added restricted version of bidi || mortezadadgar
commit 6a0f40912b37860fc65029def8b5273b19ef8e11
Author: mortezadadgar <mortezadadgar97_AT_gmail.com>
Date: Fri May 12 17:49:23 2023 +0330
[dwm][patch][bidi] Added restricted version of bidi
diff --git a/dwm.suckless.org/patches/bidi/dwm-bidi-restricted-20230512-e81f17d.diff b/dwm.suckless.org/patches/bidi/dwm-bidi-restricted-20230512-e81f17d.diff
new file mode 100644
index 00000000..096241af
--- /dev/null
+++ b/dwm.suckless.org/patches/bidi/dwm-bidi-restricted-20230512-e81f17d.diff
_AT_@ -0,0 +1,103 @@
+From f22071dcfa3cd01d4fee25ea6fe3441780a11387 Mon Sep 17 00:00:00 2001
+From: mortezadadgar <mortezadadgar97_AT_gmail.com>
+Date: Thu, 11 May 2023 16:24:49 +0330
+Subject: [PATCH]: Added restricted version of support for RTL
+ languages
+
+Only applied fribi where is needed the title
+also improved the code quality based on suckless guidelines.
+---
+ config.mk | 8 ++++++--
+ dwm.c | 21 ++++++++++++++++++++-
+ 2 files changed, 26 insertions(+), 3 deletions(-)
+
+diff --git a/config.mk b/config.mk
+index 681e059..1dd9bb5 100644
+--- a/config.mk
++++ b/config.mk
+_AT_@ -10,6 +10,8 @@ MANPREFIX = ${PREFIX}/share/man
+ X11INC = /usr/X11R6/include
+ X11LIB = /usr/X11R6/lib
+
++BDINC = /usr/include/fribidi
++
+ # Xinerama, comment if you don't want it
+ XINERAMALIBS = -lXinerama
+ XINERAMAFLAGS = -DXINERAMA
+_AT_@ -21,9 +23,11 @@ FREETYPEINC = /usr/include/freetype2
+ #FREETYPEINC = ${X11INC}/freetype2
+ #MANPREFIX = ${PREFIX}/man
+
++BDLIBS = -lfribidi
++
+ # includes and libs
+-INCS = -I${X11INC} -I${FREETYPEINC}
+-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
++INCS = -I${X11INC} -I${FREETYPEINC} -I$(BDINC)
++LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} $(BDLIBS)
+
+ # flags
+ CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
+diff --git a/dwm.c b/dwm.c
+index 2f4cad9..5df8bdb 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -21,6 +21,7 @@
+ * To understand everything else, start reading main().
+ */
+ #include <errno.h>
++#include <fribidi.h>
+ #include <locale.h>
+ #include <signal.h>
+ #include <stdarg.h>
+_AT_@ -168,6 +169,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);
+_AT_@ -267,6 +269,7 @@ static void zoom(const Arg *arg);
+ /* variables */
+ static const char broken[] = "broken";
+ static char stext[256];
++static char fribidi_text[256];
+ static int screen;
+ static int sw, sh; /* X display screen geometry width, height */
+ static int bh; /* bar height */
+_AT_@ -312,6 +315,21 @@ struct Pertag {
+ 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)
+ {
+_AT_@ -808,7 +826,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 {
+--
+2.39.3
+
diff --git a/dwm.suckless.org/patches/bidi/index.md b/dwm.suckless.org/patches/bidi/index.md
index d22ac161..03858b00 100644
--- a/dwm.suckless.org/patches/bidi/index.md
+++ b/dwm.suckless.org/patches/bidi/index.md
_AT_@ -17,6 +17,7 @@ with dwm-bidi:
Download
--------
+* [dwm-bidi-restricted-20230512-e81f17d.diff](dwm-bidi-restricted-20230512-e81f17d.diff)
* [dwm-bidi-20220309-0386419.diff](dwm-bidi-20220309-0386419.diff)
* [dwm-bidi-20220219-302953a.diff](dwm-bidi-20220219-302953a.diff) (old)
Received on Fri May 12 2023 - 16:20:07 CEST
This archive was generated by hypermail 2.3.0
: Fri May 12 2023 - 16:24:49 CEST