2019-06-03 09:03:28 +00:00
|
|
|
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
|
|
|
|
|
2019-11-25 13:31:52 +00:00
|
|
|
-- helper functions
|
|
|
|
local copied_names = {}
|
|
|
|
local function restore_func_references(obj)
|
|
|
|
for __, name in ipairs(copied_names) do
|
|
|
|
local orig_name = "_" .. name
|
|
|
|
if obj[orig_name] then
|
|
|
|
obj[name] = obj[orig_name]
|
|
|
|
obj[orig_name] = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-03 09:03:28 +00:00
|
|
|
local function copy_func_reference(obj, name)
|
|
|
|
obj["_" .. name] = obj[name]
|
2019-11-25 13:31:52 +00:00
|
|
|
table.insert(copied_names, name)
|
2019-06-03 09:03:28 +00:00
|
|
|
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")
|
2019-11-25 13:31:52 +00:00
|
|
|
|
|
|
|
return function() -- return unwrap function
|
|
|
|
restore_func_references(inputbox)
|
|
|
|
inputbox._wrapped = nil
|
|
|
|
end
|
2019-06-03 09:03:28 +00:00
|
|
|
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 (=)
|
2019-11-18 22:33:22 +00:00
|
|
|
|
2019-06-03 09:03:28 +00:00
|
|
|
return {
|
2019-11-18 16:16:06 +00:00
|
|
|
min_layer = 1,
|
2019-11-18 22:33:22 +00:00
|
|
|
max_layer = 4,
|
2019-11-18 16:16:06 +00:00
|
|
|
shiftmode_keys = {[""] = true},
|
2019-06-03 09:03:28 +00:00
|
|
|
symbolmode_keys = {["Sym"] = true, ["ABC"] = true},
|
2019-11-18 16:16:06 +00:00
|
|
|
utf8mode_keys = {["🌐"] = true},
|
2019-06-03 09:03:28 +00:00
|
|
|
umlautmode_keys = {["Äéß"] = false}, -- Disabled 'umlaut' keys
|
|
|
|
keys = {
|
|
|
|
-- [shift, unshift, symbol-shift, symbol-unshift]
|
|
|
|
-- first row
|
2019-11-18 22:33:22 +00:00
|
|
|
{ -- 1 2 3 4
|
|
|
|
{ "ㅃ", "ㅂ", "₩", "0", },
|
|
|
|
{ "ㅉ", "ㅈ", "!", "1", },
|
|
|
|
{ "ㄸ", "ㄷ", _at, "2", },
|
|
|
|
{ "ㄲ", "ㄱ", "#", "3", },
|
|
|
|
{ "ㅆ", "ㅅ", "+", _eq, },
|
|
|
|
{ "ㅛ", "ㅛ", "☆", "(", },
|
|
|
|
{ "ㅕ", "ㅕ", "★", ")", },
|
|
|
|
{ "ㅑ", "ㅑ", "♡", "\\", },
|
|
|
|
{ "ㅒ", "ㅐ", "♥", "/", },
|
|
|
|
{ "ㅖ", "ㅔ", "※", "`", },
|
2019-06-03 09:03:28 +00:00
|
|
|
},
|
|
|
|
-- second row
|
2019-11-18 22:33:22 +00:00
|
|
|
{ -- 1 2 3 4
|
|
|
|
{ "ㅁ", "ㅁ", "…", "@", },
|
|
|
|
{ "ㄴ", "ㄴ", "$", "4", },
|
|
|
|
{ "ㅇ", "ㅇ", "%", "5", },
|
|
|
|
{ "ㄹ", "ㄹ", "^", "6", },
|
|
|
|
{ "ㅎ", "ㅎ", ":", "'", },
|
|
|
|
{ "ㅗ", "ㅗ", "♩", "\"", },
|
|
|
|
{ "ㅓ", "ㅓ", "♪", "[", },
|
|
|
|
{ "ㅏ", "ㅏ", "♬", "]", },
|
|
|
|
{ "ㅣ", "ㅣ", "™", "-", },
|
2019-06-03 09:03:28 +00:00
|
|
|
},
|
|
|
|
-- third row
|
2019-11-18 22:33:22 +00:00
|
|
|
{ -- 1 2 3 4
|
2019-11-18 16:16:06 +00:00
|
|
|
{ label = "",
|
2019-06-03 09:03:28 +00:00
|
|
|
width = 1.5
|
|
|
|
},
|
2019-11-18 22:33:22 +00:00
|
|
|
{ "ㅋ", "ㅋ", "「", "7", },
|
|
|
|
{ "ㅌ", "ㅌ", "」", "8", },
|
|
|
|
{ "ㅊ", "ㅊ", "*", "9", },
|
|
|
|
{ "ㅍ", "ㅍ", "❤", com, },
|
|
|
|
{ "ㅠ", "ㅠ", "&", prd, },
|
|
|
|
{ "ㅜ", "ㅜ", "『", "↑", },
|
|
|
|
{ "ㅡ", "ㅡ", "』", "↓", },
|
2019-11-25 22:34:31 +00:00
|
|
|
{ label = "",
|
|
|
|
width = 1.5,
|
|
|
|
bold = false
|
2019-06-03 09:03:28 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
-- fourth row
|
|
|
|
{
|
2019-11-18 22:33:22 +00:00
|
|
|
{ "Sym", "Sym", "ABC", "ABC",
|
2019-06-03 09:03:28 +00:00
|
|
|
width = 1.5},
|
2019-11-18 16:16:06 +00:00
|
|
|
{ label = "🌐",
|
2019-06-03 09:03:28 +00:00
|
|
|
width = 2,
|
|
|
|
},
|
2019-11-18 22:33:22 +00:00
|
|
|
-- { "Äéß", "Äéß", "Äéß", "Äéß",},
|
2019-06-03 09:03:28 +00:00
|
|
|
{ label = "간격",
|
2019-11-18 22:33:22 +00:00
|
|
|
" ", " ", " ", " ",
|
2019-06-03 09:03:28 +00:00
|
|
|
width = 3.0},
|
2019-11-18 22:33:22 +00:00
|
|
|
{ com, com, "“", "←", },
|
|
|
|
{ prd, prd, "”", "→", },
|
2019-11-25 22:34:31 +00:00
|
|
|
{ label = "⮠",
|
2019-11-18 22:33:22 +00:00
|
|
|
"\n", "\n", "\n", "\n",
|
2019-06-03 09:03:28 +00:00
|
|
|
width = 1.5,
|
2019-11-25 22:34:31 +00:00
|
|
|
bold = true
|
2019-06-03 09:03:28 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
-- wrap InputBox for hooking events to the helper
|
|
|
|
wrapInputBox = wrapInputBox,
|
|
|
|
}
|