textscreen: Make UTF8 the rule, not the exception.
Rename TXT_DrawString() to TXT_DrawCodePageString() and rename TXT_DrawUTF8String() to TXT_DrawString(). It's better to just assume everything is UTF8 and deal with the exceptions, as this is less likely to cause bugs. There is only a small handful of places where we want to draw a specific character from the native code page.
This commit is contained in:
parent
148e9e53aa
commit
7ad4a11afa
16 changed files with 28 additions and 26 deletions
|
|
@ -459,7 +459,7 @@ static void TXT_JoystickAxisDrawer(TXT_UNCAST_ARG(joystick_axis))
|
|||
TXT_SetWidgetBG(joystick_axis);
|
||||
TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);
|
||||
|
||||
TXT_DrawUTF8String(buf);
|
||||
TXT_DrawString(buf);
|
||||
|
||||
for (i = TXT_UTF8_Strlen(buf); i < joystick_axis->widget.w; ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ static void TXT_JoystickInputDrawer(TXT_UNCAST_ARG(joystick_input))
|
|||
TXT_SetWidgetBG(joystick_input);
|
||||
TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);
|
||||
|
||||
TXT_DrawUTF8String(buf);
|
||||
TXT_DrawString(buf);
|
||||
|
||||
for (i = TXT_UTF8_Strlen(buf); i < JOYSTICK_INPUT_WIDTH; ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ static void TXT_KeyInputDrawer(TXT_UNCAST_ARG(key_input))
|
|||
TXT_SetWidgetBG(key_input);
|
||||
TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);
|
||||
|
||||
TXT_DrawUTF8String(buf);
|
||||
TXT_DrawString(buf);
|
||||
|
||||
for (i = TXT_UTF8_Strlen(buf); i < KEY_INPUT_WIDTH; ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ static void TXT_MouseInputDrawer(TXT_UNCAST_ARG(mouse_input))
|
|||
TXT_SetWidgetBG(mouse_input);
|
||||
TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);
|
||||
|
||||
TXT_DrawUTF8String(buf);
|
||||
TXT_DrawString(buf);
|
||||
|
||||
for (i = TXT_UTF8_Strlen(buf); i < MOUSE_INPUT_WIDTH; ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ static void TXT_ButtonDrawer(TXT_UNCAST_ARG(button))
|
|||
|
||||
TXT_SetWidgetBG(button);
|
||||
|
||||
TXT_DrawUTF8String(button->label);
|
||||
TXT_DrawString(button->label);
|
||||
|
||||
for (i = TXT_UTF8_Strlen(button->label); i < w; ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ static void TXT_CheckBoxDrawer(TXT_UNCAST_ARG(checkbox))
|
|||
|
||||
if ((*checkbox->variable != 0) ^ checkbox->inverted)
|
||||
{
|
||||
TXT_DrawString("\x07");
|
||||
TXT_DrawCodePageString("\x07");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -64,7 +64,7 @@ static void TXT_CheckBoxDrawer(TXT_UNCAST_ARG(checkbox))
|
|||
|
||||
TXT_RestoreColors(&colors);
|
||||
TXT_SetWidgetBG(checkbox);
|
||||
TXT_DrawUTF8String(checkbox->label);
|
||||
TXT_DrawString(checkbox->label);
|
||||
|
||||
for (i = TXT_UTF8_Strlen(checkbox->label); i < w-4; ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ static void TXT_DropdownListDrawer(TXT_UNCAST_ARG(list))
|
|||
|
||||
// Draw the string and fill to the end with spaces
|
||||
|
||||
TXT_DrawUTF8String(str);
|
||||
TXT_DrawString(str);
|
||||
|
||||
for (i = TXT_UTF8_Strlen(str); i < list->widget.w; ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -595,7 +595,7 @@ static void TXT_FileSelectDrawer(TXT_UNCAST_ARG(fileselect))
|
|||
fileselect->inputbox->widget.h = fileselect->widget.h;
|
||||
|
||||
// Triple bar symbol gives a distinguishing look to the file selector.
|
||||
TXT_DrawString("\xf0 ");
|
||||
TXT_DrawCodePageString("\xf0 ");
|
||||
TXT_BGColor(TXT_COLOR_BLACK, 0);
|
||||
TXT_DrawWidget(fileselect->inputbox);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ void TXT_DrawDesktopBackground(const char *title)
|
|||
TXT_BGColor(TXT_COLOR_GREY, 0);
|
||||
|
||||
TXT_DrawString(" ");
|
||||
TXT_DrawUTF8String(title);
|
||||
TXT_DrawString(title);
|
||||
}
|
||||
|
||||
void TXT_DrawShadow(int x, int y, int w, int h)
|
||||
|
|
@ -168,7 +168,7 @@ void TXT_DrawWindowFrame(const char *title, int x, int y, int w, int h)
|
|||
}
|
||||
|
||||
TXT_GotoXY(x + (w - TXT_UTF8_Strlen(title)) / 2, y + 1);
|
||||
TXT_DrawUTF8String(title);
|
||||
TXT_DrawString(title);
|
||||
}
|
||||
|
||||
// Draw the window's shadow.
|
||||
|
|
@ -224,7 +224,9 @@ void TXT_DrawSeparator(int x, int y, int w)
|
|||
TXT_RestoreColors(&colors);
|
||||
}
|
||||
|
||||
void TXT_DrawString(const char *s)
|
||||
// Alternative to TXT_DrawString() where the argument is a "code page
|
||||
// string" - characters are in native code page format and not UTF-8.
|
||||
void TXT_DrawCodePageString(const char *s)
|
||||
{
|
||||
int x, y;
|
||||
int x1;
|
||||
|
|
@ -278,7 +280,7 @@ static void PutUnicodeChar(unsigned int c)
|
|||
}
|
||||
}
|
||||
|
||||
void TXT_DrawUTF8String(const char *s)
|
||||
void TXT_DrawString(const char *s)
|
||||
{
|
||||
int x, y;
|
||||
int x1;
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@
|
|||
void TXT_DrawDesktopBackground(const char *title);
|
||||
void TXT_DrawWindowFrame(const char *title, int x, int y, int w, int h);
|
||||
void TXT_DrawSeparator(int x, int y, int w);
|
||||
void TXT_DrawCodePageString(const char *s);
|
||||
void TXT_DrawString(const char *s);
|
||||
void TXT_DrawUTF8String(const char *s);
|
||||
int TXT_CanDrawCharacter(unsigned int c);
|
||||
|
||||
void TXT_DrawHorizScrollbar(int x, int y, int w, int cursor, int range);
|
||||
|
|
|
|||
|
|
@ -147,15 +147,15 @@ static void TXT_InputBoxDrawer(TXT_UNCAST_ARG(inputbox))
|
|||
|
||||
if (TXT_UTF8_Strlen(inputbox->buffer) > w - 1)
|
||||
{
|
||||
TXT_DrawString("\xae");
|
||||
TXT_DrawUTF8String(
|
||||
TXT_DrawCodePageString("\xae");
|
||||
TXT_DrawString(
|
||||
TXT_UTF8_SkipChars(inputbox->buffer,
|
||||
TXT_UTF8_Strlen(inputbox->buffer) - w + 2));
|
||||
chars = w - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
TXT_DrawUTF8String(inputbox->buffer);
|
||||
TXT_DrawString(inputbox->buffer);
|
||||
chars = TXT_UTF8_Strlen(inputbox->buffer);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ static void TXT_LabelDrawer(TXT_UNCAST_ARG(label))
|
|||
|
||||
// The string itself
|
||||
|
||||
TXT_DrawUTF8String(label->lines[y]);
|
||||
TXT_DrawString(label->lines[y]);
|
||||
x += sw;
|
||||
|
||||
// Gap at the end
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ static void TXT_RadioButtonDrawer(TXT_UNCAST_ARG(radiobutton))
|
|||
|
||||
if (*radiobutton->variable == radiobutton->value)
|
||||
{
|
||||
TXT_DrawString("\x07");
|
||||
TXT_DrawCodePageString("\x07");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -65,7 +65,7 @@ static void TXT_RadioButtonDrawer(TXT_UNCAST_ARG(radiobutton))
|
|||
TXT_RestoreColors(&colors);
|
||||
TXT_SetWidgetBG(radiobutton);
|
||||
|
||||
TXT_DrawUTF8String(radiobutton->label);
|
||||
TXT_DrawString(radiobutton->label);
|
||||
|
||||
for (i=TXT_UTF8_Strlen(radiobutton->label); i < w-5; ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ static void TXT_SeparatorDrawer(TXT_UNCAST_ARG(separator))
|
|||
|
||||
TXT_FGColor(TXT_COLOR_BRIGHT_GREEN);
|
||||
TXT_DrawString(" ");
|
||||
TXT_DrawUTF8String(separator->label);
|
||||
TXT_DrawString(separator->label);
|
||||
TXT_DrawString(" ");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ static void TXT_SpinControlDrawer(TXT_UNCAST_ARG(spincontrol))
|
|||
TXT_SaveColors(&colors);
|
||||
|
||||
TXT_FGColor(TXT_COLOR_BRIGHT_CYAN);
|
||||
TXT_DrawString("\x1b ");
|
||||
TXT_DrawCodePageString("\x1b ");
|
||||
|
||||
TXT_RestoreColors(&colors);
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ static void TXT_SpinControlDrawer(TXT_UNCAST_ARG(spincontrol))
|
|||
++i;
|
||||
}
|
||||
|
||||
TXT_DrawUTF8String(spincontrol->buffer);
|
||||
TXT_DrawString(spincontrol->buffer);
|
||||
i += bw;
|
||||
|
||||
while (i < spincontrol->widget.w - 4)
|
||||
|
|
@ -194,7 +194,7 @@ static void TXT_SpinControlDrawer(TXT_UNCAST_ARG(spincontrol))
|
|||
|
||||
TXT_RestoreColors(&colors);
|
||||
TXT_FGColor(TXT_COLOR_BRIGHT_CYAN);
|
||||
TXT_DrawString(" \x1a");
|
||||
TXT_DrawCodePageString(" \x1a");
|
||||
}
|
||||
|
||||
static void TXT_SpinControlDestructor(TXT_UNCAST_ARG(spincontrol))
|
||||
|
|
|
|||
|
|
@ -54,12 +54,12 @@ static void TXT_WindowActionDrawer(TXT_UNCAST_ARG(action))
|
|||
|
||||
TXT_DrawString(" ");
|
||||
TXT_FGColor(TXT_COLOR_BRIGHT_GREEN);
|
||||
TXT_DrawUTF8String(buf);
|
||||
TXT_DrawString(buf);
|
||||
TXT_FGColor(TXT_COLOR_BRIGHT_CYAN);
|
||||
TXT_DrawString("=");
|
||||
|
||||
TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);
|
||||
TXT_DrawUTF8String(action->label);
|
||||
TXT_DrawString(action->label);
|
||||
TXT_DrawString(" ");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue