feat: switch text to UTF-8; add Unicode key events, dead keys & Czech layout; fix numpad navigation; add NumLock support

This commit is contained in:
daniel committed 2026-10-03 10:11:49 +02:00
1 parent 32660ddd1a
commit 2aa6360b3d
101 files changed
+3733 -1639

No files matched your search

@@ -9,12 +9,32 @@
#include <montauk/syscall.h>
#include <montauk/string.h>
#include <montauk/heap.h>
#include <montauk/utf8.h>
namespace gui {
// The clipboard carries UTF-8. Text that is not well-formed (legacy
// Windows-1252 bytes) is converted on the way in and on the way out, so
// every reader can assume valid UTF-8.
inline char* clipboard_utf8_copy(const char* text, int len, int* out_len) {
int cap = len * 3 + 1; // each stray byte grows to at most 3
char* out = (char*)montauk::malloc(cap);
if (!out) return nullptr;
*out_len = montauk::utf8::normalize(text, len, out, cap);
return out;
}
inline bool clipboard_set_text(const char* text, int len) {
if (len < 0) return false;
if (len > 0 && text == nullptr) return false;
if (len > 0 && !montauk::utf8::valid(text, len)) {
int fixed_len = 0;
char* fixed = clipboard_utf8_copy(text, len, &fixed_len);
if (!fixed) return false;
bool ok = montauk::clipboard_set_text(fixed, (uint32_t)fixed_len) == 0;
montauk::mfree(fixed);
return ok;
}
return montauk::clipboard_set_text(text, (uint32_t)len) == 0;
}
@@ -53,6 +73,14 @@ namespace gui {
}
text[actual_len] = '\0';
if (!montauk::utf8::valid(text, (int)actual_len)) {
int fixed_len = 0;
char* fixed = clipboard_utf8_copy(text, (int)actual_len, &fixed_len);
montauk::mfree(text);
if (!fixed) return nullptr;
text = fixed;
actual_len = (uint32_t)fixed_len;
}
if (out_len) *out_len = (int)actual_len;
if (out_serial) *out_serial = serial;
return text;