From c1be488a11bc9efb3082b77affe990e189fbdbe6 Mon Sep 17 00:00:00 2001 From: poire-z Date: Mon, 8 Jun 2020 21:54:26 +0200 Subject: [PATCH] Keyboard: better isolation of FR/ES/TR from EN base dofile() wasn't enough to copy en_keyboard, as the references to key popups would still be shared, and hacks to them (as done by the FR keyboard) would be active on the EN keyboard. Also, for the FR Keyboard: - bring M key popup too when moving it to 2nd row. - keep original ',' and '.' as on EN keyboard. - add ';' instead of ',' as the added key, and let it have some key popup too, with keys helpful when CSS editing. --- .../ui/data/keyboardlayouts/es_keyboard.lua | 4 +-- .../ui/data/keyboardlayouts/fr_keyboard.lua | 36 +++++++++++++------ .../ui/data/keyboardlayouts/tr_keyboard.lua | 6 ++-- frontend/ui/widget/virtualkeyboard.lua | 3 ++ 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/frontend/ui/data/keyboardlayouts/es_keyboard.lua b/frontend/ui/data/keyboardlayouts/es_keyboard.lua index 95aabbd1f..11c107b89 100644 --- a/frontend/ui/data/keyboardlayouts/es_keyboard.lua +++ b/frontend/ui/data/keyboardlayouts/es_keyboard.lua @@ -1,5 +1,5 @@ --- Start with the english keyboard layout -local es_keyboard = dofile("frontend/ui/data/keyboardlayouts/en_keyboard.lua") +-- Start with the english keyboard layout (deep copy, to not alter it) +local es_keyboard = require("util").tableDeepCopy(require("ui/data/keyboardlayouts/en_keyboard")) local keys = es_keyboard.keys diff --git a/frontend/ui/data/keyboardlayouts/fr_keyboard.lua b/frontend/ui/data/keyboardlayouts/fr_keyboard.lua index 61babd603..ce2bcf363 100644 --- a/frontend/ui/data/keyboardlayouts/fr_keyboard.lua +++ b/frontend/ui/data/keyboardlayouts/fr_keyboard.lua @@ -1,5 +1,5 @@ --- Start with the english keyboard layout -local fr_keyboard = dofile("frontend/ui/data/keyboardlayouts/en_keyboard.lua") +-- Start with the english keyboard layout (deep copy, to not alter it) +local fr_keyboard = require("util").tableDeepCopy(require("ui/data/keyboardlayouts/en_keyboard")) -- Swap the four AZWQ keys (only in the lowercase and -- uppercase letters layouts) to change it from QWERTY to AZERTY @@ -14,14 +14,30 @@ table.insert(keys[2], -- 1 2 3 4 5 6 7 8 { "M", "m", "§", "+", "Œ", "œ", "Ő", "ő", } ) --- And swap the english M on the 3rd row to ',' -keys[3][8][1] = "," -keys[3][8][2] = "," --- And swap the english ',' on the 4th row (an extended key --- including a popup) to ';' -local en_com = keys[4][5][1] -en_com[1] = ";" -en_com.north = "," -- and swap the ';' there to ',' +-- But replace the alpha "M" and "m" with the original key+popup from english M/m +keys[2][10][1] = keys[3][8][1] +keys[2][10][2] = keys[3][8][2] + +-- We have one more key than en_keyboard: replace that original M key +-- to show another char on alpha layouts: let's use ";", and a popup +-- helpful for CSS style tweaks editing. +local _semicolon = { + ";", + -- north = "!", + north = { label = "!…", key = "!important;" }, + northeast = "}", + northwest = "{", + west = "-", + east = ":", + south = "*", + southwest = "0", + southeast = ">", + "[", + '+', + "]", +} +keys[3][8][1] = _semicolon +keys[3][8][2] = _semicolon -- Swap ê and ë (and the like) in the keyboard popups, so the -- common french accentuated chars are all on the upper row. diff --git a/frontend/ui/data/keyboardlayouts/tr_keyboard.lua b/frontend/ui/data/keyboardlayouts/tr_keyboard.lua index 388bf97ff..4c09e6398 100644 --- a/frontend/ui/data/keyboardlayouts/tr_keyboard.lua +++ b/frontend/ui/data/keyboardlayouts/tr_keyboard.lua @@ -1,5 +1,5 @@ --- Start with the english keyboard layout -local tr_keyboard = dofile("frontend/ui/data/keyboardlayouts/en_keyboard.lua") +-- Start with the english keyboard layout (deep copy, to not alter it) +local tr_keyboard = require("util").tableDeepCopy(require("ui/data/keyboardlayouts/en_keyboard")) local keys = tr_keyboard.keys @@ -68,4 +68,4 @@ keys[4][4].label = "boşluk" --keys[4][1].width = 1 --keys[4][3].width = 1 -return tr_keyboard \ No newline at end of file +return tr_keyboard diff --git a/frontend/ui/widget/virtualkeyboard.lua b/frontend/ui/widget/virtualkeyboard.lua index 3c0b33eb3..a16cb0696 100644 --- a/frontend/ui/widget/virtualkeyboard.lua +++ b/frontend/ui/widget/virtualkeyboard.lua @@ -132,6 +132,9 @@ function VirtualKey:init() local key_function = self.key_chars[ges.direction.."_func"] if not key_function and key_string then + if type(key_string) == "table" and key_string.key then + key_string = key_string.key + end self.keyboard:addChar(key_string) elseif key_function then key_function()