[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tyndur-devel] [PATCH] Deadkeys
+ vterm kann jetzt Deadkeys
Signed-off-by: Arne Hasselbring <arne.hasselbring@xxxxxxxxxxxxxx>
---
src/modules/vterm/include/keymap.h | 2 +
src/modules/vterm/input.c | 104 ++++++++++++++++++++++++++++++
src/modules/vterm/keymaps/Makefile.all | 2 +-
src/modules/vterm/keymaps/de.c | 6 +-
src/modules/vterm/keymaps/de_nodeadkeys.c | 41 ++++++++++++
5 Dateien geändert, 151 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)
create mode 100644 src/modules/vterm/keymaps/de_nodeadkeys.c
diff --git a/src/modules/vterm/include/keymap.h b/src/modules/vterm/include/keymap.h
index 4a8a733..604080d 100644
--- a/src/modules/vterm/include/keymap.h
+++ b/src/modules/vterm/include/keymap.h
@@ -39,6 +39,8 @@
#include <stddef.h>
#include <lostio.h>
+#define KEYMAP_DEADKEY 0x80000000
+
/**
* Eintrag in der Keymap
*/
diff --git a/src/modules/vterm/input.c b/src/modules/vterm/input.c
index 95cf991..5d1ce57 100644
--- a/src/modules/vterm/input.c
+++ b/src/modules/vterm/input.c
@@ -51,6 +51,64 @@ extern vterminal_t* current_vterm;
/// Pid von kbc
static pid_t kbc_pid = 0;
+static wchar_t deadkey = 0;
+
+static wchar_t deadkey_chars[53][4] = {
+ { L'Ã', L'Á', L'À', L'Â' }, //A
+ { 0, 0, 0, 0 },
+ { 0, L'Ć', 0, L'Ĉ' },
+ { 0, 0, 0, 0 },
+ { L'Ẽ', L'É', L'È', L'Ê' },
+ { 0, 0, 0, 0 },
+ { 0, L'Ǵ', 0, L'Ĝ' },
+ { 0, 0, 0, L'Ĥ' },
+ { L'Ĩ', L'Í', L'Ì', L'Î' },
+ { 0, 0, 0, L'Ĵ' },
+ { 0, L'Ḱ', 0, 0 },
+ { 0, L'Ĺ', 0, 0 },
+ { 0, L'Ḿ', 0, 0 },
+ { L'Ñ', L'Ń', L'Ǹ', 0 },
+ { L'Õ', L'Ó', L'Ò', L'Ô' },
+ { 0, L'Ṕ', 0, 0 },
+ { 0, 0, 0, 0 },
+ { 0, L'Ŕ', 0, 0 },
+ { 0, L'Ś', 0, L'Ŝ' },
+ { 0, 0, 0, 0 },
+ { L'Ũ', L'Ú', L'Ù', L'Û' },
+ { L'Ṽ', L'Ǘ', L'Ǜ', 0 },
+ { 0, L'Ẃ', L'Ẁ', L'Ŵ' },
+ { 0, 0, 0, 0 },
+ { L'Ỹ', L'Ý', L'Ỳ', L'Ŷ' },
+ { 0, L'Ź', 0, L'Ẑ' },
+ { L'ã', L'á', L'à', L'â' }, //a
+ { 0, 0, 0, 0 },
+ { 0, L'ć', 0, L'ĉ' },
+ { 0, 0, 0, 0 },
+ { L'ẽ', L'é', L'è', L'ê' },
+ { 0, 0, 0, 0 },
+ { 0, L'ǵ', 0, L'ĝ' },
+ { 0, 0, 0, L'ĥ' },
+ { L'ĩ', L'í', L'ì', L'î' },
+ { 0, 0, 0, L'ĵ' },
+ { 0, L'ḱ', 0, 0 },
+ { 0, L'ĺ', 0, 0 },
+ { 0, L'ḿ', 0, 0 },
+ { L'ñ', L'ń', L'ǹ', 0 },
+ { L'õ', L'ó', L'ò', L'ô' },
+ { 0, L'ṕ', 0, 0 },
+ { 0, 0, 0, 0 },
+ { 0, L'ŕ', 0, 0 },
+ { 0, L'ś', 0, L'ŝ' },
+ { 0, 0, 0, 0 },
+ { L'ũ', L'ú', L'ù', L'û' },
+ { L'ṽ', L'ǘ', L'ǜ', 0 },
+ { 0, L'ẃ', L'ẁ', L'ŵ' },
+ { 0, 0, 0, 0 },
+ { L'ỹ', L'ý', L'ỳ', L'ŷ' },
+ { 0, L'ź', 0, L'ẑ' },
+ { '~', L'´', '`', '^' }, //space
+};
+
/**
* Calback handler
*/
@@ -110,6 +168,45 @@ static void rpc_kbd_callback(pid_t pid, uint32_t cid, size_t data_size,
}
/**
+ * Aus Deadkey und Zeichen das passende Zeichen bestimmen
+ *
+ * @param c Zeichen
+ */
+static wchar_t get_real_key(wchar_t c)
+{
+ c &= ~KEYMAP_DEADKEY;
+ if (c >= 'A' && c <= 'Z') {
+ c -= 'A';
+ } else if (c >= 'a' && c <= 'z') {
+ c -= 'a' - 26;
+ } else if (c == ' ' || c == deadkey) {
+ c = 52;
+ } else {
+ deadkey = 0;
+ return 0;
+ }
+ switch (deadkey) {
+ case '~':
+ c = deadkey_chars[c][0];
+ break;
+ case L'´':
+ c = deadkey_chars[c][1];
+ break;
+ case '`':
+ c = deadkey_chars[c][2];
+ break;
+ case '^':
+ c = deadkey_chars[c][3];
+ break;
+ default:
+ c = 0;
+ break;
+ }
+ deadkey = 0;
+ return c;
+}
+
+/**
* Tastendruecke an ein virtuelles Terminal senden
*
* @param vterm Terminal-Handle
@@ -187,6 +284,13 @@ static void send_key_to_vterm(vterminal_t* vterm, uint8_t keycode,
c = e->normal;
}
+ if ((c & KEYMAP_DEADKEY) && !deadkey) {
+ deadkey = (c & ~KEYMAP_DEADKEY);
+ return;
+ } else if (deadkey) {
+ c = get_real_key(c);
+ }
+
if ((c != 0) && ((len = wctomb(buf, c)) != -1)) {
vterm_process_input(buf, len);
}
diff --git a/src/modules/vterm/keymaps/Makefile.all b/src/modules/vterm/keymaps/Makefile.all
index 7e47059..ba7fa5c 100644
--- a/src/modules/vterm/keymaps/Makefile.all
+++ b/src/modules/vterm/keymaps/Makefile.all
@@ -3,7 +3,7 @@ source $LOST_BUILDMK_ROOT/config.sh
mkdir -p $1/system/keymaps
-for lang in de us de_ch; do
+for lang in de de_nodeadkeys us de_ch; do
echo "KMAP $lang"
$LOST_TOOLS_LD --oformat binary $lang.o -e 0 -o $1/system/keymaps/$lang.kbd
chmod a-x $1/system/keymaps/$lang.kbd
diff --git a/src/modules/vterm/keymaps/de.c b/src/modules/vterm/keymaps/de.c
index df400bd..4e0eb71 100644
--- a/src/modules/vterm/keymaps/de.c
+++ b/src/modules/vterm/keymaps/de.c
@@ -49,7 +49,7 @@ keymap_entry_t keymap[128] = {
{ '9', ')', ']', 0 }, // 10
{ '0', '=', '}', 0 },
{L'ß', '?', '\\', 0 },
- { 0, '`', 0, 0 },
+ {L'´' | KEYMAP_DEADKEY, '`' | KEYMAP_DEADKEY, 0, 0 },
{ '\b', 0, 0, 0 },
{ '\t', 0, 0, 0 },
{ 'q', 'Q', '@', 17 },
@@ -63,7 +63,7 @@ keymap_entry_t keymap[128] = {
{ 'o', 'O', 0, 15 },
{ 'p', 'P', 0, 16 },
{L'ü', L'Ü', 0, 0 },
- { '+', '*', '~', 0 },
+ { '+', '*', '~' | KEYMAP_DEADKEY, 0 },
{ '\n', 0, 0, 0 },
{ 0, 0, 0, 0 },
{ 'a', 'A', 0, 1 }, // 30
@@ -77,7 +77,7 @@ keymap_entry_t keymap[128] = {
{ 'l', 'L', 0, 12 },
{L'ö', L'Ö', 0, 0 },
{L'ä', L'Ä', 0, 0 }, // 40
- { 0, 0, 0, 0 },
+ { '^' | KEYMAP_DEADKEY, L'°', 0, 0 },
{ 0, 0, 0, 0 },
{ '#', '\'', 0, 0 },
{ 'y', 'Y', 0, 25 },
diff --git a/src/modules/vterm/keymaps/de_nodeadkeys.c b/src/modules/vterm/keymaps/de_nodeadkeys.c
new file mode 100644
index 0000000..c856f28
--- /dev/null
+++ b/src/modules/vterm/keymaps/de_nodeadkeys.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2012 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Arne Hasselbring.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the tyndur Project
+ * and its contributors.
+ * 4. Neither the name of the tyndur Project nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "keymap.h"
+
+#undef KEYMAP_DEADKEY
+#define KEYMAP_DEADKEY 0
+
+#include "de.c"
--
1.7.11.1