mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-06-01 17:42:25 +00:00
- use a wide string for the console input buffer.
Since this needs to do cursor positioning calculations it's the one spot in the entire engine where UTF-8 would simply be to messy, especially when having to deal with double wide characters.
This commit is contained in:
parent
0884057ae1
commit
eb4eb1ac00
10 changed files with 116 additions and 94 deletions
|
@ -38,6 +38,7 @@
|
|||
#include <wctype.h>
|
||||
|
||||
#include "v_text.h"
|
||||
#include "utf8.h"
|
||||
|
||||
|
||||
#include "v_video.h"
|
||||
|
@ -248,10 +249,14 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawChar)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void DFrameBuffer::DrawTextCommon(FFont *font, int normalcolor, double x, double y, const char *string, DrawParms &parms)
|
||||
// This is only needed as a dummy. The code using wide strings does not need color control.
|
||||
EColorRange V_ParseFontColor(const char32_t *&color_value, int normalcolor, int boldcolor) { return CR_UNTRANSLATED; }
|
||||
|
||||
template<class chartype>
|
||||
void DFrameBuffer::DrawTextCommon(FFont *font, int normalcolor, double x, double y, const chartype *string, DrawParms &parms)
|
||||
{
|
||||
int w;
|
||||
const uint8_t *ch;
|
||||
const chartype *ch;
|
||||
int c;
|
||||
double cx;
|
||||
double cy;
|
||||
|
@ -274,13 +279,13 @@ void DFrameBuffer::DrawTextCommon(FFont *font, int normalcolor, double x, double
|
|||
|
||||
kerning = font->GetDefaultKerning();
|
||||
|
||||
ch = (const uint8_t *)string;
|
||||
ch = string;
|
||||
cx = x;
|
||||
cy = y;
|
||||
|
||||
|
||||
auto currentcolor = normalcolor;
|
||||
while ((const char *)ch - string < parms.maxstrlen)
|
||||
while (ch - string < parms.maxstrlen)
|
||||
{
|
||||
c = GetCharFromString(ch);
|
||||
if (!c)
|
||||
|
@ -327,6 +332,24 @@ void DFrameBuffer::DrawText(FFont *font, int normalcolor, double x, double y, co
|
|||
Va_List tags;
|
||||
DrawParms parms;
|
||||
|
||||
if (font == NULL || string == NULL)
|
||||
return;
|
||||
|
||||
va_start(tags.list, tag_first);
|
||||
bool res = ParseDrawTextureTags(nullptr, 0, 0, tag_first, tags, &parms, true);
|
||||
va_end(tags.list);
|
||||
if (!res)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DrawTextCommon(font, normalcolor, x, y, (const uint8_t*)string, parms);
|
||||
}
|
||||
|
||||
void DFrameBuffer::DrawText(FFont *font, int normalcolor, double x, double y, const char32_t *string, int tag_first, ...)
|
||||
{
|
||||
Va_List tags;
|
||||
DrawParms parms;
|
||||
|
||||
if (font == NULL || string == NULL)
|
||||
return;
|
||||
|
||||
|
@ -353,7 +376,7 @@ void DFrameBuffer::DrawText(FFont *font, int normalcolor, double x, double y, co
|
|||
{
|
||||
return;
|
||||
}
|
||||
DrawTextCommon(font, normalcolor, x, y, string, parms);
|
||||
DrawTextCommon(font, normalcolor, x, y, (const uint8_t*)string, parms);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Screen, DrawText)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue