arrow key works on gdi

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@244 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-09 13:21:01 +00:00
parent 2cecb6c34a
commit a8f2628009
5 changed files with 57 additions and 1 deletions

View File

@@ -76,6 +76,11 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
int n = wp;
MwLLDispatch(u->ll, key, &n);
} else if(msg == WM_KEYDOWN) {
int n = -1;
if(wp == VK_LEFT) n = MwLLKeyLeft;
if(wp == VK_RIGHT) n = MwLLKeyRight;
if(n != -1) MwLLDispatch(u->ll, key, &n);
} else {
return (u->old == NULL) ? DefWindowProc(hWnd, msg, wp, lp) : CallWindowProc(u->old, hWnd, msg, wp, lp);
}

View File

@@ -97,3 +97,27 @@ int MwUTF8Copy(const char* src, int srcskip, char* dst, int dstskip, int len) {
return total;
}
int MwUTF32ToUTF8(int input, char* output) {
if(input < 128) {
output[0] = input;
return 1;
} else if(input < 2048) {
output[0] = 0xc0 | (input >> 6);
output[1] = 0x80 | (input & 0x3f);
return 2;
} else if(input < 65536) {
output[0] = 0xe0 | (input >> 12);
output[1] = 0x80 | ((input >> 6) & 0x3f);
output[2] = 0x80 | (input & 0x3f);
return 3;
} else {
output[0] = 0xf0 | (input >> 18);
output[1] = 0x80 | ((input >> 12) & 0x3f);
output[2] = 0x80 | ((input >> 6) & 0x3f);
output[3] = 0x80 | (input & 0x3f);
return 4;
}
return 0;
}

View File

@@ -106,7 +106,7 @@ static void key(MwWidget handle, int code) {
int incr = 0;
out = malloc(strlen(str) + 1 + 1);
incr += MwUTF8Copy(str, 0, out, 0, t->cursor);
out[incr++] = code;
MwUTF32ToUTF8(code, out + incr);
MwUTF8Copy(str, t->cursor, out, t->cursor + 1, MwUTF8Length(str) - t->cursor);
t->cursor++;