You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
koreader/frontend/ui/data/keyboardlayouts/ko_KR_keyboard.lua

170 lines
5.8 KiB
Lua

local logger = require("logger")
--------
-- # Korean 2-beolsik Keyboard layout
--------
local HgHelper = require("ui/data/keyboardlayouts/ko_KR_helper")
--------
-- UI handler implementation for communicating with text input box widget
--------
function HgHelper.UIHandler:put_char(char)
HgHelper.UIHandler.inputbox:_addChars(char)
end
function HgHelper.UIHandler:del_char(char)
HgHelper.UIHandler.inputbox:_delChar()
end
HgHelper.HgFSM:init(HgHelper.UIHandler)
--------
-- Custom key event handlers with Hangul support
--------
local wrapInputBox = function(inputbox)
HgHelper.HgFSM.clean_state() -- reset helper
if inputbox._wrapped == nil then
inputbox._wrapped = true
-- helper function
local function copy_func_reference(obj, name)
obj["_" .. name] = obj[name]
end
-- override original implementations with helper object
copy_func_reference(inputbox, "addChars")
copy_func_reference(inputbox, "delChar")
function inputbox:addChars(key)
logger.dbg("ko_KR_kbd:addChar(", key, ")")
HgHelper.UIHandler.inputbox = self
HgHelper.HgFSM:process_char(key)
end
function inputbox:delChar()
logger.dbg("ko_KR_kbd:delChar()")
HgHelper.UIHandler.inputbox = self
HgHelper.HgFSM:process_bsp()
end
-- override implementations: reset helper if we have to stop combining current syllable
---- helper function
local function wrap_func_with_hghelper_reset(obj, name)
copy_func_reference(obj, name)
obj[name] = function(self)
HgHelper.HgFSM.clean_state()
self["_" .. name](self)
end
end
---- delete text
wrap_func_with_hghelper_reset(inputbox, "delToStartOfLine")
wrap_func_with_hghelper_reset(inputbox, "clear")
---- move cursor
wrap_func_with_hghelper_reset(inputbox, "leftChar")
wrap_func_with_hghelper_reset(inputbox, "rightChar")
wrap_func_with_hghelper_reset(inputbox, "upLine")
wrap_func_with_hghelper_reset(inputbox, "downLine")
---- unfocus: move to other inputbox
wrap_func_with_hghelper_reset(inputbox, "unfocus")
---- tap/hold/swipe: move cursor
------ helper function
local function wrap_touch_event_func_with_hghelper_reset(obj, name)
copy_func_reference(obj, name)
obj[name] = function(self, arg, ges)
HgHelper.HgFSM.clean_state()
return self["_" .. name](self, arg, ges)
end
end
wrap_touch_event_func_with_hghelper_reset(inputbox, "onTapTextBox")
wrap_touch_event_func_with_hghelper_reset(inputbox, "onHoldTextBox")
wrap_touch_event_func_with_hghelper_reset(inputbox, "onSwipeTextBox")
end
end
-- Belows are just same as the English keyboard popup
local en_popup = require("ui/data/keyboardlayouts/keypopup/en_popup")
local com = en_popup.com -- comma (,)
local prd = en_popup.prd -- period (.)
local _at = en_popup._at
local _eq = en_popup._eq -- equals sign (=)
return {
min_layer = 1,
max_layer = 4,
shiftmode_keys = {[""] = true},
symbolmode_keys = {["Sym"] = true, ["ABC"] = true},
utf8mode_keys = {["🌐"] = true},
umlautmode_keys = {["Äéß"] = false}, -- Disabled 'umlaut' keys
keys = {
-- [shift, unshift, symbol-shift, symbol-unshift]
-- first row
{ -- 1 2 3 4
{ "", "", "", "0", },
{ "", "", "!", "1", },
{ "", "", _at, "2", },
{ "", "", "#", "3", },
{ "", "", "+", _eq, },
{ "", "", "", "(", },
{ "", "", "", ")", },
{ "", "", "", "\\", },
{ "", "", "", "/", },
{ "", "", "", "`", },
},
-- second row
{ -- 1 2 3 4
{ "", "", "", "@", },
{ "", "", "$", "4", },
{ "", "", "%", "5", },
{ "", "", "^", "6", },
{ "", "", ":", "'", },
{ "", "", "", "\"", },
{ "", "", "", "[", },
{ "", "", "", "]", },
{ "", "", "", "-", },
},
-- third row
{ -- 1 2 3 4
{ label = "",
width = 1.5
},
{ "", "", "", "7", },
{ "", "", "", "8", },
{ "", "", "*", "9", },
{ "", "", "", com, },
{ "", "", "&", prd, },
{ "", "", "", "", },
{ "", "", "", "", },
{ label = "",
width = 1.5,
bold = false
},
},
-- fourth row
{
{ "Sym", "Sym", "ABC", "ABC",
width = 1.5},
{ label = "🌐",
width = 2,
},
-- { "Äéß", "Äéß", "Äéß", "Äéß",},
{ label = "간격",
" ", " ", " ", " ",
width = 3.0},
{ com, com, "", "", },
{ prd, prd, "", "", },
{ label = "",
"\n", "\n", "\n", "\n",
width = 1.5,
bold = true
},
},
},
-- wrap InputBox for hooking events to the helper
wrapInputBox = wrapInputBox,
}