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, }