summaryrefslogtreecommitdiff
path: root/textscreen/txt_label.c
diff options
context:
space:
mode:
authorSimon Howard2012-02-03 21:10:36 +0000
committerSimon Howard2012-02-03 21:10:36 +0000
commit85b5a7487d5b44b94e6d2fc74c997ec69e352b1a (patch)
tree2d5c58da8f23deb97b08f1c8e3ed8017197aa7cd /textscreen/txt_label.c
parentd745a6409c84a9ffb85e5d2029132642435c5879 (diff)
downloadchocolate-doom-85b5a7487d5b44b94e6d2fc74c997ec69e352b1a.tar.gz
chocolate-doom-85b5a7487d5b44b94e6d2fc74c997ec69e352b1a.tar.bz2
chocolate-doom-85b5a7487d5b44b94e6d2fc74c997ec69e352b1a.zip
Upgrade the input box and label widgets to use UTF-8 strings.
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2491
Diffstat (limited to 'textscreen/txt_label.c')
-rw-r--r--textscreen/txt_label.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/textscreen/txt_label.c b/textscreen/txt_label.c
index a2afc13b..c4238bf3 100644
--- a/textscreen/txt_label.c
+++ b/textscreen/txt_label.c
@@ -26,6 +26,7 @@
#include "txt_gui.h"
#include "txt_io.h"
#include "txt_main.h"
+#include "txt_utf8.h"
#include "txt_window.h"
static void TXT_LabelSizeCalc(TXT_UNCAST_ARG(label))
@@ -68,7 +69,7 @@ static void TXT_LabelDrawer(TXT_UNCAST_ARG(label))
align_indent = label->w - strlen(label->lines[y]);
break;
}
-
+
// Draw this line
TXT_GotoXY(origin_x, origin_y + y);
@@ -82,8 +83,8 @@ static void TXT_LabelDrawer(TXT_UNCAST_ARG(label))
// The string itself
- TXT_DrawString(label->lines[y]);
- x += strlen(label->lines[y]);
+ TXT_DrawUTF8String(label->lines[y]);
+ x += TXT_UTF8_Strlen(label->lines[y]);
// Gap at the end
@@ -123,7 +124,7 @@ void TXT_SetLabel(txt_label_t *label, char *value)
free(label->label);
free(label->lines);
- // Set the new value
+ // Set the new value
label->label = strdup(value);
@@ -144,7 +145,7 @@ void TXT_SetLabel(txt_label_t *label, char *value)
label->lines = malloc(sizeof(char *) * label->h);
label->lines[0] = label->label;
y = 1;
-
+
for (p = label->label; *p != '\0'; ++p)
{
if (*p == '\n')
@@ -159,8 +160,12 @@ void TXT_SetLabel(txt_label_t *label, char *value)
for (y=0; y<label->h; ++y)
{
- if (strlen(label->lines[y]) > label->w)
- label->w = strlen(label->lines[y]);
+ unsigned int line_len;
+
+ line_len = TXT_UTF8_Strlen(label->lines[y]);
+
+ if (line_len > label->w)
+ label->w = line_len;
}
}