This is an automated email generated because a ref change occurred in the
git repository for project wmaker-crm.git.
The branch, master has been updated
via fa49b7c0032f83a40f52ddc4de6b6b9a4eb76533 (commit)
via 6dbc6c95ab05f51844210a1a8bdc2901bfb8d917 (commit)
from 4babc0e422a23496da7f8c818428214277925a26 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit fa49b7c0032f83a40f52ddc4de6b6b9a4eb76533
Author: David Maciejak <
david.m...@gmail.com>
Date: Sat, 4 Apr 2026 14:30:05 -0400
URL: <
https://repo.or.cz/wmaker-crm.git/fa49b7c0032f83a4>
WINGs: avoid splitting UTF-8 characters when wrapping text
This patch is to split UTF-8 word by characters and not bytes.
Issue reported at
https://github.com/window-maker/wmaker/issues/65
---
WINGs/wmisc.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/WINGs/wmisc.c b/WINGs/wmisc.c
index ba4c8a6a6240..e14ad176f4e5 100644
--- a/WINGs/wmisc.c
+++ b/WINGs/wmisc.c
@@ -122,11 +122,14 @@ static int fitText(const char *text, WMFont * font, int width, int wrap)
word1 = word2;
}
- for (i = word1; i < word2; i++) {
- w = WMWidthOfString(font, text, i);
- if (w > width) {
+ /* Advance character by character (not byte by byte) */
+ i = word1;
+ while (i < word2) {
+ int next_i = i + oneUTF8CharForward(text + i, word2 - i);
+ w = WMWidthOfString(font, text, next_i);
+ if (w > width)
break;
- }
+ i = next_i;
}
/* keep words complete if possible */
commit 6dbc6c95ab05f51844210a1a8bdc2901bfb8d917
Author: David Maciejak <
david.m...@gmail.com>
Date: Sat, 4 Apr 2026 14:27:12 -0400
URL: <
https://repo.or.cz/wmaker-crm.git/6dbc6c95ab05f518>
WINGs: make UTF-8 functions global
This patch is moving the existing UTF-8 functions from wtextfield.c
to
WINGsP.h.in to be available to all modules.
---
WINGs/WINGs/
WINGsP.h.in | 31 +++++++++++++++++++++++++++++++
WINGs/wtextfield.c | 29 -----------------------------
2 files changed, 31 insertions(+), 29 deletions(-)
diff --git a/WINGs/WINGs/
WINGsP.h.in b/WINGs/WINGs/
WINGsP.h.in
index 2c36b269d1be..02d288f3811b 100644
--- a/WINGs/WINGs/
WINGsP.h.in
+++ b/WINGs/WINGs/
WINGsP.h.in
@@ -686,6 +686,37 @@ void W_BroadcastMessage(W_View *targetParent, XEvent *event);
void W_DispatchMessage(W_View *target, XEvent *event);
+/* ---[ UTF-8 helpers ]--------------------------------------------------- */
+
+static inline int oneUTF8CharBackward(const char *str, int len)
+{
+ const unsigned char *ustr = (const unsigned char *)str;
+ int pos = 0;
+
+ while (len-- > 0 && ustr[--pos] >= 0x80 && ustr[pos] <= 0xbf) ;
+ return pos;
+}
+
+static inline int oneUTF8CharForward(const char *str, int len)
+{
+ const unsigned char *ustr = (const unsigned char *)str;
+ int pos = 0;
+
+ while (len-- > 0 && ustr[++pos] >= 0x80 && ustr[pos] <= 0xbf) ;
+ return pos;
+}
+
+// find the beginning of the UTF8 char pointed by str
+static inline int seekUTF8CharStart(const char *str, int len)
+{
+ const unsigned char *ustr = (const unsigned char *)str;
+ int pos = 0;
+
+ while (len-- > 0 && ustr[pos] >= 0x80 && ustr[pos] <= 0xbf)
+ --pos;
+ return pos;
+}
+
#ifdef __cplusplus
}
diff --git a/WINGs/wtextfield.c b/WINGs/wtextfield.c
index 52b577e5d1bf..4d25a3e5b1fa 100644
--- a/WINGs/wtextfield.c
+++ b/WINGs/wtextfield.c
@@ -122,35 +122,6 @@ static WMSelectionProcs selectionHandler = {
#define TEXT_WIDTH2(tPtr, start, end) (WMWidthOfString((tPtr)->font, \
&((tPtr)->text[(start)]), (end) - (start)))
-static inline int oneUTF8CharBackward(const char *str, int len)
-{
- const unsigned char *ustr = (const unsigned char *)str;
- int pos = 0;
-
- while (len-- > 0 && ustr[--pos] >= 0x80 && ustr[pos] <= 0xbf) ;
- return pos;
-}
-
-static inline int oneUTF8CharForward(const char *str, int len)
-{
- const unsigned char *ustr = (const unsigned char *)str;
- int pos = 0;
-
- while (len-- > 0 && ustr[++pos] >= 0x80 && ustr[pos] <= 0xbf) ;
- return pos;
-}
-
-// find the beginning of the UTF8 char pointed by str
-static inline int seekUTF8CharStart(const char *str, int len)
-{
- const unsigned char *ustr = (const unsigned char *)str;
- int pos = 0;
-
- while (len-- > 0 && ustr[pos] >= 0x80 && ustr[pos] <= 0xbf)
- --pos;
- return pos;
-}
-
static void normalizeRange(TextField * tPtr, WMRange * range)
{
if (range->position < 0 && range->count < 0)
-----------------------------------------------------------------------
Summary of changes:
WINGs/WINGs/
WINGsP.h.in | 31 +++++++++++++++++++++++++++++++
WINGs/wmisc.c | 11 +++++++----
WINGs/wtextfield.c | 29 -----------------------------
3 files changed, 38 insertions(+), 33 deletions(-)
repo.or.cz automatic notification. Contact project admin
crm...@gmail.com
if you want to unsubscribe, or site admin
ad...@repo.or.cz if you receive
no reply.
--
wmaker-crm.git ("The Window Maker window manager")