LCDproc development and user support list

Text archives Help


[Lcdproc] [RFC] string widget: Allow multibyte characters


Chronological Thread 
  • From: harald at ccbib.org (Harald Geyer)
  • Subject: [Lcdproc] [RFC] string widget: Allow multibyte characters
  • Date: Tue, 01 Dec 2015 18:31:57 +0100

Currently render_string() truncates the text after n bytes, where n is
the number of characters from the start of the rendering position to
the
right margin. Since the API already requires drivers to take care of
proper truncating, this is not necessary.

Signed-off-by: Harald Geyer <harald at ccbib.org>
---
What do you think of the following change? Of course this is only a
start, but
before I put work into this, I want check if there is consensus that
this is
the right direction ...


server/render.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/server/render.c b/server/render.c
index 78119b4..92b5326 100644
--- a/server/render.c
+++ b/server/render.c
@@ -310,9 +310,6 @@ render_string(Widget *w, int left, int top, int
right, int b
ottom, int fy)

if ((w != NULL) && (w->text != NULL) &&
(w->x > 0) && (w->y > 0) && (w->y > fy) && (w->y <= bottom
- top)) {
- int length;
- char str[BUFSIZE];
-
/*
* FIXME: Could be a bug here? w->x is recalculated (On
first
* call only? Is it preserved between calls?) and first
@@ -320,10 +317,7 @@ render_string(Widget *w, int left, int top, int
right, int bottom, int fy)
* strings totally off-screen. Is this on purpose? (M.
Dolze)
*/
w->x = min(w->x, right - left);
- length = min(right - left - w->x + 1, sizeof(str)-1);
- strncpy(str, w->text, length);
- str[length] = '\0';
- drivers_string(w->x + left, w->y + top, str);
+ drivers_string(w->x + left, w->y + top, w->text);
}
return 0;
}


--
If you want to support my work:
see http://friends.ccbib.org/harald/supporting/
or donate via bitcoin to 1FUtd8T9jRN1rFz63vZz7s2fDtB6d6A7aS



  • [Lcdproc] [RFC] string widget: Allow multibyte characters, Harald Geyer, 12/01/2015

Archive powered by MHonArc 2.6.18.

Top of page