mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-04 08:30:51 +00:00
renders
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@242 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -28,6 +28,17 @@ MWDECL int MwUTF8ToUTF32(const char* input, int* output);
|
|||||||
*/
|
*/
|
||||||
MWDECL int MwUTF8Length(const char* input);
|
MWDECL int MwUTF8Length(const char* input);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* %brief Copies UTF-8 string to other string
|
||||||
|
* %brief src Source
|
||||||
|
* %brief srcskip Length to be skipped
|
||||||
|
* %brief dst Destination
|
||||||
|
* %brief dstskip Length to be skipped
|
||||||
|
* %brief len Length
|
||||||
|
* %return Copied length in bytes
|
||||||
|
*/
|
||||||
|
MWDECL int MwUTF8Copy(const char* src, int srcskip, char* dst, int dstskip, int len);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -372,7 +372,12 @@ void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int
|
|||||||
sx -= strlen(text) * FontWidth * FontScale;
|
sx -= strlen(text) * FontWidth * FontScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; text[i] != 0; i++) {
|
while(text[i] != 0) {
|
||||||
|
int out;
|
||||||
|
i += MwUTF8ToUTF32(text, &out);
|
||||||
|
|
||||||
|
if(out >= 0x80) out = 0;
|
||||||
|
|
||||||
for(y = 0; y < FontHeight; y++) {
|
for(y = 0; y < FontHeight; y++) {
|
||||||
for(x = 0; x < FontWidth; x++) {
|
for(x = 0; x < FontWidth; x++) {
|
||||||
r.x = sx + x * FontScale;
|
r.x = sx + x * FontScale;
|
||||||
@@ -380,7 +385,7 @@ void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int
|
|||||||
r.width = FontScale;
|
r.width = FontScale;
|
||||||
r.height = FontScale;
|
r.height = FontScale;
|
||||||
|
|
||||||
if((bold ? MwBoldFontData : MwFontData)[(unsigned char)text[i]].data[y] & (1 << ((FontWidth - 1) - x))) {
|
if((bold ? MwBoldFontData : MwFontData)[out].data[y] & (1 << ((FontWidth - 1) - x))) {
|
||||||
MwDrawRect(handle, &r, color);
|
MwDrawRect(handle, &r, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,3 +74,23 @@ int MwUTF8Length(const char* input) {
|
|||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MwUTF8Copy(const char* src, int srcskip, char* dst, int dstskip, int len){
|
||||||
|
int i;
|
||||||
|
int out;
|
||||||
|
int total = 0;
|
||||||
|
for(i = 0; i < srcskip; i++) src += MwUTF8ToUTF32(src, &out);
|
||||||
|
for(i = 0; i < dstskip; i++) dst += MwUTF8ToUTF32(dst, &out);
|
||||||
|
for(i = 0; i < len; i++){
|
||||||
|
int len = MwUTF8ToUTF32(src, &out);
|
||||||
|
|
||||||
|
memcpy(dst, src, len);
|
||||||
|
|
||||||
|
src += len;
|
||||||
|
dst += len;
|
||||||
|
total += len;
|
||||||
|
}
|
||||||
|
dst[total] = 0;
|
||||||
|
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ static int create(MwWidget handle) {
|
|||||||
|
|
||||||
MwSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
|
|
||||||
MwSetText(handle, MwNtext, "こんにちは、世界");
|
MwSetText(handle, MwNtext, "こんにちは、世界 Hello, World");
|
||||||
MwLLSetCursor(handle->lowlevel, &MwCursorText, &MwCursorTextMask);
|
MwLLSetCursor(handle->lowlevel, &MwCursorText, &MwCursorTextMask);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -111,12 +111,11 @@ static void key(MwWidget handle, int code) {
|
|||||||
if(t->cursor == (int)strlen(str)) return;
|
if(t->cursor == (int)strlen(str)) return;
|
||||||
t->cursor++;
|
t->cursor++;
|
||||||
} else {
|
} else {
|
||||||
int i, incr = 0;
|
int incr = 0;
|
||||||
out = malloc(strlen(str) + 1 + 1);
|
out = malloc(strlen(str) + 1 + 1);
|
||||||
for(i = 0; i < t->cursor; i++) out[incr++] = str[i];
|
incr += MwUTF8Copy(str, 0, out, 0, t->cursor);
|
||||||
out[incr++] = code;
|
out[incr++] = code;
|
||||||
for(i = t->cursor; i < (int)strlen(str); i++) out[incr++] = str[i];
|
MwUTF8Copy(str, t->cursor, out, t->cursor + 1, MwUTF8Length(str) - t->cursor);
|
||||||
out[incr++] = 0;
|
|
||||||
|
|
||||||
t->cursor++;
|
t->cursor++;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user