🩹 Followup for lchar_t
This commit is contained in:
@@ -50,12 +50,12 @@ uint8_t read_byte(const uint8_t *byte) { return *byte; }
|
||||
* @ displays an axis name such as XYZUVW, or E for an extruder
|
||||
*/
|
||||
void DWIN_String::add(const char *tpl, const int8_t index, const char *cstr/*=nullptr*/, FSTR_P const fstr/*=nullptr*/) {
|
||||
lchar_t ch;
|
||||
lchar_t wc;
|
||||
|
||||
while (*tpl) {
|
||||
tpl = get_utf8_value_cb(tpl, read_byte, ch);
|
||||
if (ch > 255) ch |= 0x0080;
|
||||
const uint8_t ch = uint8_t(ch & 0x00FF);
|
||||
tpl = get_utf8_value_cb(tpl, read_byte, wc);
|
||||
if (wc > 255) wc |= 0x0080;
|
||||
const uint8_t ch = uint8_t(wc & 0x00FF);
|
||||
|
||||
if (ch == '=' || ch == '~' || ch == '*') {
|
||||
if (index >= 0) {
|
||||
@@ -80,32 +80,32 @@ void DWIN_String::add(const char *tpl, const int8_t index, const char *cstr/*=nu
|
||||
}
|
||||
|
||||
void DWIN_String::add(const char *cstr, uint8_t max_len/*=MAX_STRING_LENGTH*/) {
|
||||
lchar_t ch;
|
||||
lchar_t wc;
|
||||
while (*cstr && max_len) {
|
||||
cstr = get_utf8_value_cb(cstr, read_byte, ch);
|
||||
cstr = get_utf8_value_cb(cstr, read_byte, wc);
|
||||
/*
|
||||
if (ch > 255) ch |= 0x0080;
|
||||
uint8_t ch = uint8_t(ch & 0x00FF);
|
||||
if (wc > 255) wc |= 0x0080;
|
||||
const uint8_t ch = uint8_t(wc & 0x00FF);
|
||||
add_character(ch);
|
||||
*/
|
||||
add(ch);
|
||||
add(wc);
|
||||
max_len--;
|
||||
}
|
||||
eol();
|
||||
}
|
||||
|
||||
void DWIN_String::add(const lchar_t &ch) {
|
||||
void DWIN_String::add(const lchar_t &wc) {
|
||||
int ret;
|
||||
size_t idx = 0;
|
||||
dwin_charmap_t pinval;
|
||||
dwin_charmap_t *copy_address = nullptr;
|
||||
pinval.uchar = ch;
|
||||
pinval.uchar = wc;
|
||||
pinval.idx = -1;
|
||||
|
||||
// For 8-bit ASCII just print the single ch
|
||||
// For 8-bit ASCII just print the single character
|
||||
char str[] = { '?', 0 };
|
||||
if (ch < 255) {
|
||||
str[0] = (char)ch;
|
||||
if (wc < 255) {
|
||||
str[0] = (char)wc;
|
||||
}
|
||||
else {
|
||||
copy_address = nullptr;
|
||||
|
||||
@@ -69,10 +69,10 @@ class DWIN_String {
|
||||
/**
|
||||
* @brief Append a UTF-8 character
|
||||
*
|
||||
* @param ch The UTF-8 character
|
||||
* @param wc The UTF-8 character
|
||||
*/
|
||||
static void add(const lchar_t &ch);
|
||||
static void set(const lchar_t &ch) { set(); add(ch); }
|
||||
static void add(const lchar_t &wc);
|
||||
static void set(const lchar_t &wc) { set(); add(wc); }
|
||||
|
||||
/**
|
||||
* @brief Append / Set C-string
|
||||
|
||||
@@ -87,10 +87,10 @@ static int lcd_put_u8str_max_cb(const char * utf8_str, read_byte_cb_t cb_read_by
|
||||
const uint8_t *p = (uint8_t *)utf8_str;
|
||||
dwin_string.set();
|
||||
while (dwin_string.length < max_length) {
|
||||
lchar_t ch;
|
||||
p = get_utf8_value_cb(p, cb_read_byte, ch);
|
||||
if (!ch) break;
|
||||
dwin_string.add(ch);
|
||||
lchar_t wc;
|
||||
p = get_utf8_value_cb(p, cb_read_byte, wc);
|
||||
if (!wc) break;
|
||||
dwin_string.add(wc);
|
||||
}
|
||||
DWIN_Draw_String(dwin_font.solid, dwin_font.index, dwin_font.fg, dwin_font.bg, cursor.x, cursor.y, dwin_string.string());
|
||||
lcd_advance_cursor(dwin_string.length);
|
||||
|
||||
Reference in New Issue
Block a user