feat: add keyboard layout support

This commit is contained in:
2026-08-13 17:57:44 +02:00
parent 86e3ebfe33
commit 821543238d
36 changed files with 1132 additions and 125 deletions
+14
View File
@@ -14,6 +14,7 @@
#include <montauk/syscall.h>
#include <montauk/string.h>
#include <montauk/heap.h>
#include <montauk/keyboard.h>
#include <gui/gui.hpp>
#include <gui/canvas.hpp>
#include <gui/draw.hpp>
@@ -392,6 +393,14 @@ static void term_handle_mouse(const montauk::abi::WinEvent& ev) {
}
// Keyboard handling shared by both run modes.
// User whose keyboard layout selection console mode follows.
static char g_layout_user[32] = "default";
static void init_layout_user() {
if (montauk::getuser(g_layout_user, sizeof(g_layout_user)) <= 0)
montauk::strcpy(g_layout_user, "default");
}
static void term_handle_key_core(const montauk::abi::KeyEvent& key,
int width, int height) {
if (g_tabs.tab_count <= 0) return;
@@ -586,6 +595,8 @@ static void run_console() {
if (cols < 1) cols = 1;
if (rows < 1) rows = 1;
init_layout_user();
g_tabs.tabs[0] = term_create_tab(cols, rows);
if (!g_tabs.tabs[0])
montauk::exit(1);
@@ -610,6 +621,9 @@ static void run_console() {
while (montauk::is_key_available()) {
montauk::abi::KeyEvent key;
montauk::getkey(&key);
// Console mode reads the kernel buffer directly, so it does not
// get the desktop's layout translation the windowed path does.
montauk::keyboard::translate_direct(&key, g_layout_user);
term_handle_key_core(key, sw, sh);
redraw = true;
if (g_should_exit) break;