mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-06 08:38:30 +09:00
seemingly working hangul 2-set
This commit is contained in:
426
assets/keylayout/ko_kr_2set_ksx5002.ime
Normal file
426
assets/keylayout/ko_kr_2set_ksx5002.ime
Normal file
@@ -0,0 +1,426 @@
|
|||||||
|
let states = {"keylayouts":[[""],[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
["0",")"],
|
||||||
|
["1","!"],
|
||||||
|
["2","@"],
|
||||||
|
["3","#"],
|
||||||
|
["4","$"],
|
||||||
|
["5","%"],
|
||||||
|
["6","^"],
|
||||||
|
["7","&"],
|
||||||
|
["8","*"],
|
||||||
|
["9","("],
|
||||||
|
["*"],
|
||||||
|
["#"],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
["\u3141"],
|
||||||
|
["\u3160"],
|
||||||
|
["\u314A"],
|
||||||
|
["\u3147"],
|
||||||
|
["\u3137"],
|
||||||
|
["\u3139"],
|
||||||
|
["\u314E"],
|
||||||
|
["\u3157"],
|
||||||
|
["\u3151"],
|
||||||
|
["\u3153"],
|
||||||
|
["\u314F"],
|
||||||
|
["\u3163"],
|
||||||
|
["\u3161"],
|
||||||
|
["\u315C"],
|
||||||
|
["\u3150","\u3152"],
|
||||||
|
["\u3154","\u3156"],
|
||||||
|
["\u3142","\u3143"],
|
||||||
|
["\u3131","\u3132"],
|
||||||
|
["\u3134"],
|
||||||
|
["\u3145","\u3146"],
|
||||||
|
["\u3155"],
|
||||||
|
["\u314D"],
|
||||||
|
["\u3148","\u3149"],
|
||||||
|
["\u314C"],
|
||||||
|
["\u315B"],
|
||||||
|
["\u314B"],
|
||||||
|
[",","<"],
|
||||||
|
[".",">"],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[" "],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
["\n"],
|
||||||
|
["\x08"],
|
||||||
|
["`","~"],
|
||||||
|
["-","_"],
|
||||||
|
["=","+"],
|
||||||
|
["[","{"],
|
||||||
|
["]","}"],
|
||||||
|
["\\","|"],
|
||||||
|
[";",":"],
|
||||||
|
["'",'"'],
|
||||||
|
["/","?"],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
["0"],
|
||||||
|
["1"],
|
||||||
|
["2"],
|
||||||
|
["3"],
|
||||||
|
["4"],
|
||||||
|
["5"],
|
||||||
|
["6"],
|
||||||
|
["7"],
|
||||||
|
["8"],
|
||||||
|
["9"],
|
||||||
|
["/"],
|
||||||
|
["*"],
|
||||||
|
["-"],
|
||||||
|
["+"],
|
||||||
|
["."],
|
||||||
|
["."],
|
||||||
|
["\n"],
|
||||||
|
["="],
|
||||||
|
["("],
|
||||||
|
[")"],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined],
|
||||||
|
[undefined]
|
||||||
|
],
|
||||||
|
"code":0,
|
||||||
|
"buf":[]}
|
||||||
|
let reset = () => {
|
||||||
|
states.code = 0
|
||||||
|
states.buf = []
|
||||||
|
}
|
||||||
|
let inRange = (s,a,b) => (a <= s && s <= b)
|
||||||
|
let isHangul = (s) => (s === undefined) ? false : inRange(s.charCodeAt(0), 0x3131, 0x3163)
|
||||||
|
let isConsonant = (s) => (s === undefined) ? false : inRange(s.charCodeAt(0), 0x3131, 0x314E)
|
||||||
|
let isVowel = (s) => (s === undefined) ? false : inRange(s.charCodeAt(0), 0x314F, 0x3163)
|
||||||
|
let isJongseongConsonant = (s) => (s === undefined) ? false : (inRange(s.charCodeAt(0), 0x3131, 0x314E) && !([0x3138, 0x3143, 0x3149].includes(s.charCodeAt(0))))
|
||||||
|
let isJungseongDigraph1 = (s) => (s === undefined) ? false : ([0x3157, 0x315C].includes(s.charCodeAt(0)))
|
||||||
|
let isJungseongDigraphO = (s) => (s === undefined) ? false : ([0x314F, 0x3150, 0x3163].includes(s.charCodeAt(0)))
|
||||||
|
let isJungseongDigraphU = (s) => (s === undefined) ? false : ([0x3153, 0x3154, 0x3163].includes(s.charCodeAt(0)))
|
||||||
|
let isJungseongDigraphEU = (s) => (s === undefined) ? false : ([0x3163].includes(s.charCodeAt(0)))
|
||||||
|
let isJongseongDigraphG = (s) => (s === undefined) ? false : ([0x3145].includes(s.charCodeAt(0)))
|
||||||
|
let isJongseongDigraphN = (s) => (s === undefined) ? false : ([0x3148, 0x314E].includes(s.charCodeAt(0)))
|
||||||
|
let isJongseongDigraphR = (s) => (s === undefined) ? false : ([0x3131, 0x3141, 0x3142, 0x3145, 0x314C, 0x314D, 0x314E].includes(s.charCodeAt(0)))
|
||||||
|
let isJongseongDigraphB = (s) => (s === undefined) ? false : ([0x3145].includes(s.charCodeAt(0)))
|
||||||
|
let jungseongDigraphsO = {"\u314F":"\u3158", "\u3150":"\u3159", "\u3163":"\u315A"}
|
||||||
|
let jungseongDigraphsU = {"\u3153":"\u315D", "\u3154":"\u315E", "\u3163":"\u315F"}
|
||||||
|
let jungseongDigraphsEU = {"\u3163":"\u3162"}
|
||||||
|
let jongseongDigraphsG = {"\u3145":"\u3133"}
|
||||||
|
let jongseongDigraphsN = {"\u3148":"\u3135", "\u314E":"\u3136"}
|
||||||
|
let jongseongDigraphsR = {"\u3131":"\u313A", "\u3141":"\u313B", "\u3142":"\u313C", "\u3145":"\u313D", "\u314C":"\u313E", "\u314D":"\u313F", "\u314E":"\u3140"}
|
||||||
|
let jongseongDigraphsB = {"\u3145":"\u3144"}
|
||||||
|
let isJongseongDigraph = (s) => (s === undefined) ? false : ([0x3133, 0x3135, 0x3136, 0x313A, 0x313B, 0x313C, 0x313D, 0x313E, 0x313F, 0x3140, 0x3144].includes(s.charCodeAt(0)))
|
||||||
|
let choseongTable = {"\u3131":0,"\u3132":1,"\u3134":2,"\u3137":3,"\u3138":4,"\u3139":5,"\u3141":6,"\u3142":7,"\u3143":8,"\u3145":9,"\u3146":10,"\u3147":11,"\u3148":12,"\u3149":13,"\u314A":14,"\u314B":15,"\u314C":16,"\u314D":17,"\u314E":18}
|
||||||
|
let jongseongTable = {"\u3131":0,"\u3132":1,"\u3133":2,"\u3134":3,"\u3135":4,"\u3136":5,"\u3137":6,"\u3139":7,"\u313A":8,"\u313B":9,"\u313C":10,"\u313D":11,"\u313E":12,"\u313F":13,"\u3140":14,"\u3141":15,"\u3142":16,"\u3144":17,"\u3145":18,"\u3146":19,"\u3147":20,"\u3148":21,"\u314A":22,"\u314B":23,"\u314C":24,"\u314D":25,"\u314E":26}
|
||||||
|
let detachJongseongDigraph = {
|
||||||
|
"\u3133":["\u3131","\u3145"],
|
||||||
|
"\u3135":["\u3134","\u3148"],
|
||||||
|
"\u3136":["\u3134","\u314E"],
|
||||||
|
"\u313A":["\u3139","\u3131"],
|
||||||
|
"\u313B":["\u3139","\u3141"],
|
||||||
|
"\u313C":["\u3139","\u3142"],
|
||||||
|
"\u313D":["\u3139","\u3145"],
|
||||||
|
"\u313E":["\u3139","\u314C"],
|
||||||
|
"\u313F":["\u3139","\u314D"],
|
||||||
|
"\u3140":["\u3139","\u314E"],
|
||||||
|
"\u3144":["\u3142","\u3145"]
|
||||||
|
}
|
||||||
|
let bufAssemble = (isPreview) => {
|
||||||
|
// nothing on the buffer
|
||||||
|
if (states.buf[0] === undefined && states.buf[1] === undefined && states.buf[2] === undefined)
|
||||||
|
return ''
|
||||||
|
// Hangul: I P F
|
||||||
|
else if (isConsonant(states.buf[0]) && isVowel(states.buf[1]) && isConsonant(states.buf[2])) {
|
||||||
|
let i = choseongTable[states.buf[0]]
|
||||||
|
let p = states.buf[1].charCodeAt(0) - 0x314F
|
||||||
|
let f = jongseongTable[states.buf[2]] + 1
|
||||||
|
return String.fromCodePoint(0xAC00 + (i * 588) + (p * 28) + f)
|
||||||
|
}
|
||||||
|
// Hangul: I P x
|
||||||
|
else if (isConsonant(states.buf[0]) && isVowel(states.buf[1]) && undefined == states.buf[2]) {
|
||||||
|
let i = choseongTable[states.buf[0]]
|
||||||
|
let p = states.buf[1].charCodeAt(0) - 0x314F
|
||||||
|
return String.fromCodePoint(0xAC00 + (i * 588) + (p * 28))
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return states.buf.join('')
|
||||||
|
}
|
||||||
|
//let bufDebugStringify = (buf) => [0,1,2].map(i => (buf[i] == undefined) ? "·" : `\\u${buf[i].codePointAt(0).toString(16).toUpperCase()}`).join(' ')
|
||||||
|
let bufDebugStringify = (buf) => [0,1,2].map(i => (buf[i] == undefined) ? "·" : `${buf[i]}`).join(' ')
|
||||||
|
return Object.freeze({"n":"두벌식 표준","states":states,
|
||||||
|
// return: [displayed output, composed output]
|
||||||
|
"accept":(headkey,shiftin,altgrin)=>{
|
||||||
|
let layer = 1*shiftin// + 2*altgrin
|
||||||
|
states.code = 1
|
||||||
|
|
||||||
|
/*let purekeys = keycodes.filter(it => (
|
||||||
|
inRange(it,7,18) || // numeric
|
||||||
|
inRange(it,29,56) || // alph
|
||||||
|
it == 62 || // space
|
||||||
|
inRange(it,66,76) || // symbols
|
||||||
|
inRange(it,144,163) // numpad
|
||||||
|
))
|
||||||
|
let headkey = purekeys[0]*/
|
||||||
|
|
||||||
|
let s = states.keylayouts[headkey][layer]
|
||||||
|
|
||||||
|
if (isHangul(s)) {
|
||||||
|
let bufIndex = (isJongseongConsonant(s) && isConsonant(states.buf[0]) && undefined !== states.buf[1]) ? 2 :
|
||||||
|
(isVowel(s) && isConsonant(states.buf[0])) ? 1 : 0
|
||||||
|
let vowelCollision = isVowel(states.buf[1]) && isVowel(s)
|
||||||
|
let hasJongseongAlready = (states.buf[2] !== undefined)
|
||||||
|
|
||||||
|
// console.log(`accepting hangul '${s}' at buf[${bufIndex}] (vowelCollision = ${vowelCollision})`)
|
||||||
|
|
||||||
|
// ㅘ ㅙ ㅚ
|
||||||
|
if (!hasJongseongAlready && 1 == bufIndex && "\u3157" == states.buf[1] && isJungseongDigraphO(s)) {
|
||||||
|
states.buf[1] = jungseongDigraphsO[s]
|
||||||
|
}
|
||||||
|
// ㅝ ㅞ ㅟ
|
||||||
|
else if (!hasJongseongAlready && 1 == bufIndex && "\u315C" == states.buf[1] && isJungseongDigraphU(s)) {
|
||||||
|
states.buf[1] = jungseongDigraphsU[s]
|
||||||
|
}
|
||||||
|
// ㅢ
|
||||||
|
else if (!hasJongseongAlready && 1 == bufIndex && "\u3161" == states.buf[1] && isJungseongDigraphEU(s)) {
|
||||||
|
states.buf[1] = jungseongDigraphsEU[s]
|
||||||
|
}
|
||||||
|
// ㄳ
|
||||||
|
else if (2 == bufIndex && "\u3131" == states.buf[2] && isJongseongDigraphG(s)) {
|
||||||
|
states.buf[2] = jongseongDigraphsG[s]
|
||||||
|
}
|
||||||
|
// ㄵ ㄶ
|
||||||
|
else if (2 == bufIndex && "\u3134" == states.buf[2] && isJongseongDigraphN(s)) {
|
||||||
|
states.buf[2] = jongseongDigraphsN[s]
|
||||||
|
}
|
||||||
|
// ㄺ ㄻ ㄼ ㄽ ㄾ ㄿ ㅀ
|
||||||
|
else if (2 == bufIndex && "\u3139" == states.buf[2] && isJongseongDigraphR(s)) {
|
||||||
|
states.buf[2] = jongseongDigraphsR[s]
|
||||||
|
}
|
||||||
|
// ㅄ
|
||||||
|
else if (2 == bufIndex && "\u3142" == states.buf[2] && isJongseongDigraphB(s)) {
|
||||||
|
states.buf[2] = jongseongDigraphsB[s]
|
||||||
|
}
|
||||||
|
// key inputs that bufIndex collides (end compose and accept incoming char as a new char state)
|
||||||
|
else if (states.buf[bufIndex] !== undefined) {
|
||||||
|
let oldbufstr = bufDebugStringify(states.buf)
|
||||||
|
let sendout = ''
|
||||||
|
if (vowelCollision && isJongseongDigraph(states.buf[2])) {
|
||||||
|
let digraphs = detachJongseongDigraph[states.buf[2]]
|
||||||
|
let newbuf = [digraphs[1], s]
|
||||||
|
states.buf = [states.buf[0], states.buf[1], digraphs[0]]
|
||||||
|
sendout = bufAssemble()
|
||||||
|
states.buf = newbuf
|
||||||
|
}
|
||||||
|
else if (vowelCollision) {
|
||||||
|
let newbuf = [states.buf[2], s]
|
||||||
|
states.buf = [states.buf[0], states.buf[1]]
|
||||||
|
sendout = bufAssemble()
|
||||||
|
states.buf = newbuf
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sendout = bufAssemble()
|
||||||
|
reset()
|
||||||
|
if (bufIndex == 2)
|
||||||
|
states.buf[0] = s
|
||||||
|
else
|
||||||
|
states.buf[bufIndex] = s
|
||||||
|
}
|
||||||
|
let newbufstr = bufDebugStringify(states.buf)
|
||||||
|
// console.log(`sending out: ${oldbufstr} -> ${sendout} ; ${newbufstr}`)
|
||||||
|
return [bufAssemble(1), sendout]
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
states.buf[bufIndex] = s
|
||||||
|
// console.log(`assembling: ${bufDebugStringify(states.buf)} -> ${bufAssemble()}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
return [bufAssemble(1), ""]
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// console.log(`accepting char '${s}'`)
|
||||||
|
let oldbufstr = bufDebugStringify(states.buf)
|
||||||
|
let sendout = bufAssemble() + (s || ''); reset()
|
||||||
|
// console.log(`sending out: ${oldbufstr} -> ${sendout}`)
|
||||||
|
return [bufAssemble(1), sendout]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"end":()=>{
|
||||||
|
// console.log(`end composing`)
|
||||||
|
let ret = bufAssemble()
|
||||||
|
reset()
|
||||||
|
return ret
|
||||||
|
},
|
||||||
|
"reset":()=>{ reset() },
|
||||||
|
"composing":()=>(states.code!=0)
|
||||||
|
})
|
||||||
@@ -141,26 +141,26 @@ let states = {"keylayouts":[[""],[undefined],
|
|||||||
[undefined],
|
[undefined],
|
||||||
[undefined],
|
[undefined],
|
||||||
[undefined],
|
[undefined],
|
||||||
[undefined],
|
["0"],
|
||||||
[undefined],
|
["1"],
|
||||||
[undefined],
|
["2"],
|
||||||
[undefined],
|
["3"],
|
||||||
[undefined],
|
["4"],
|
||||||
[undefined],
|
["5"],
|
||||||
[undefined],
|
["6"],
|
||||||
[undefined],
|
["7"],
|
||||||
[undefined],
|
["8"],
|
||||||
[undefined],
|
["9"],
|
||||||
[undefined],
|
["/"],
|
||||||
[undefined],
|
["*"],
|
||||||
[undefined],
|
["-"],
|
||||||
[undefined],
|
["+"],
|
||||||
[undefined],
|
["."],
|
||||||
[undefined],
|
["."],
|
||||||
[undefined],
|
["\n"],
|
||||||
[undefined],
|
["="],
|
||||||
[undefined],
|
["("],
|
||||||
[undefined],
|
[")"],
|
||||||
[undefined],
|
[undefined],
|
||||||
[undefined],
|
[undefined],
|
||||||
[undefined],
|
[undefined],
|
||||||
@@ -266,7 +266,6 @@ let isChoseong = (s) => (s === undefined) ? false : inRange(s.charCodeAt(0), 0x
|
|||||||
let isJungseong = (s) => (s === undefined) ? false : inRange(s.charCodeAt(0), 0x1161, 0x1175)
|
let isJungseong = (s) => (s === undefined) ? false : inRange(s.charCodeAt(0), 0x1161, 0x1175)
|
||||||
let isJongseong = (s) => (s === undefined) ? false : inRange(s.charCodeAt(0), 0x11A8, 0x11C2)
|
let isJongseong = (s) => (s === undefined) ? false : inRange(s.charCodeAt(0), 0x11A8, 0x11C2)
|
||||||
let isChoseongDigraph = (s) => (s === undefined) ? false : ([0x1100, 0x1103, 0x1107, 0x1109, 0x110C].includes(s.charCodeAt(0)))
|
let isChoseongDigraph = (s) => (s === undefined) ? false : ([0x1100, 0x1103, 0x1107, 0x1109, 0x110C].includes(s.charCodeAt(0)))
|
||||||
let isJungseongDigraph1 = (s) => (s === undefined) ? false : ([0x1169, 0x116E].includes(s.charCodeAt(0)))
|
|
||||||
let isJungseongDigraphO = (s) => (s === undefined) ? false : ([0x1161, 0x1162, 0x1175].includes(s.charCodeAt(0)))
|
let isJungseongDigraphO = (s) => (s === undefined) ? false : ([0x1161, 0x1162, 0x1175].includes(s.charCodeAt(0)))
|
||||||
let isJungseongDigraphU = (s) => (s === undefined) ? false : ([0x1165, 0x1166, 0x1175].includes(s.charCodeAt(0)))
|
let isJungseongDigraphU = (s) => (s === undefined) ? false : ([0x1165, 0x1166, 0x1175].includes(s.charCodeAt(0)))
|
||||||
let isJungseongDigraphEU = (s) => (s === undefined) ? false : ([0x1175].includes(s.charCodeAt(0)))
|
let isJungseongDigraphEU = (s) => (s === undefined) ? false : ([0x1175].includes(s.charCodeAt(0)))
|
||||||
@@ -307,17 +306,14 @@ let bufAssemble = (isPreview) => {
|
|||||||
// nothing on the buffer
|
// nothing on the buffer
|
||||||
if (states.buf[0] === undefined && states.buf[1] === undefined && states.buf[2] === undefined)
|
if (states.buf[0] === undefined && states.buf[1] === undefined && states.buf[2] === undefined)
|
||||||
return ''
|
return ''
|
||||||
// Normalise unterminated hangul assembly
|
|
||||||
else if (!isPreview)
|
|
||||||
return states.buf.map(it => normaliseBuf(it)).join('')
|
|
||||||
// Hangul: I x F
|
// Hangul: I x F
|
||||||
else if (states.buf[1] === undefined && isHangul(states.buf[0]))
|
else if (isPreview && states.buf[1] === undefined && isHangul(states.buf[0]))
|
||||||
return [states.buf[0], "\u1160", states.buf[2]].join('')
|
return [states.buf[0], "\u1160", states.buf[2]].join('')
|
||||||
// Hangul: x P F
|
// Hangul: x P F
|
||||||
else if (states.buf[0] === undefined && isHangul(states.buf[1]))
|
else if (isPreview && states.buf[0] === undefined && isHangul(states.buf[1]))
|
||||||
return ["\u115F", states.buf[1], states.buf[2]].join('')
|
return ["\u115F", states.buf[1], states.buf[2]].join('')
|
||||||
// Hangul: x x F
|
// Hangul: x x F
|
||||||
else if (isHangul(states.buf[2]) && states.buf[0] === undefined && states.buf[1] === undefined )
|
else if (isPreview && isHangul(states.buf[2]) && states.buf[0] === undefined && states.buf[1] === undefined )
|
||||||
return ["\u115F", "\u1160", states.buf[2]].join('')
|
return ["\u115F", "\u1160", states.buf[2]].join('')
|
||||||
// Hangul: I P F
|
// Hangul: I P F
|
||||||
else if (isChoseong(states.buf[0]) && isJungseong(states.buf[1]) && isJongseong(states.buf[2])) {
|
else if (isChoseong(states.buf[0]) && isJungseong(states.buf[1]) && isJongseong(states.buf[2])) {
|
||||||
@@ -326,16 +322,20 @@ let bufAssemble = (isPreview) => {
|
|||||||
let f = states.buf[2].charCodeAt(0) - 0x11A7
|
let f = states.buf[2].charCodeAt(0) - 0x11A7
|
||||||
return String.fromCodePoint(0xAC00 + (i * 588) + (p * 28) + f)
|
return String.fromCodePoint(0xAC00 + (i * 588) + (p * 28) + f)
|
||||||
}
|
}
|
||||||
// Hangul: I P x
|
// Hangul: I P
|
||||||
else if (isChoseong(states.buf[0]) && isJungseong(states.buf[1]) && undefined == states.buf[2]) {
|
else if (isChoseong(states.buf[0]) && isJungseong(states.buf[1]) && undefined == states.buf[2]) {
|
||||||
let i = states.buf[0].charCodeAt(0) - 0x1100
|
let i = states.buf[0].charCodeAt(0) - 0x1100
|
||||||
let p = states.buf[1].charCodeAt(0) - 0x1161
|
let p = states.buf[1].charCodeAt(0) - 0x1161
|
||||||
return String.fromCodePoint(0xAC00 + (i * 588) + (p * 28))
|
return String.fromCodePoint(0xAC00 + (i * 588) + (p * 28))
|
||||||
}
|
}
|
||||||
|
// Normalise unterminated hangul assembly
|
||||||
|
else if (!isPreview)
|
||||||
|
return states.buf.map(it => normaliseBuf(it)).join('')
|
||||||
else
|
else
|
||||||
return states.buf.join('')
|
return states.buf.join('')
|
||||||
}
|
}
|
||||||
Object.freeze({"n":"세벌식 3-90","states":states,
|
let bufDebugStringify = (buf) => [0,1,2].map(i => (buf[i] == undefined) ? "·" : `\\u${buf[i].codePointAt(0).toString(16).toUpperCase()}`).join(' ')
|
||||||
|
return Object.freeze({"n":"세벌식 3-90","states":states,
|
||||||
// return: [displayed output, composed output]
|
// return: [displayed output, composed output]
|
||||||
"accept":(headkey,shiftin,altgrin)=>{
|
"accept":(headkey,shiftin,altgrin)=>{
|
||||||
let layer = 1*shiftin// + 2*altgrin
|
let layer = 1*shiftin// + 2*altgrin
|
||||||
@@ -388,26 +388,29 @@ Object.freeze({"n":"세벌식 3-90","states":states,
|
|||||||
}
|
}
|
||||||
// key inputs that bufIndex collides (end compose and accept incoming char as a new char state)
|
// key inputs that bufIndex collides (end compose and accept incoming char as a new char state)
|
||||||
else if (states.buf[bufIndex] !== undefined) {
|
else if (states.buf[bufIndex] !== undefined) {
|
||||||
|
let oldbufstr = bufDebugStringify(states.buf)
|
||||||
let sendout = bufAssemble(); reset()
|
let sendout = bufAssemble(); reset()
|
||||||
states.buf[bufIndex] = s
|
states.buf[bufIndex] = s
|
||||||
console.log(`sending out: ${sendout}`)
|
let newbufstr = bufDebugStringify(states.buf)
|
||||||
|
// console.log(`sending out: ${oldbufstr} -> ${sendout} ; ${newbufstr}`)
|
||||||
return [bufAssemble(1), sendout]
|
return [bufAssemble(1), sendout]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
states.buf[bufIndex] = s
|
states.buf[bufIndex] = s
|
||||||
console.log(`assembling: ${bufAssemble()}`)
|
// console.log(`assembling: ${bufDebugStringify(states.buf)} -> ${bufAssemble()}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return [bufAssemble(1), ""]
|
return [bufAssemble(1), ""]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let sendout = bufAssemble() + s; reset()
|
let oldbufstr = bufDebugStringify(states.buf)
|
||||||
console.log(`sending out: ${sendout}`)
|
let sendout = bufAssemble() + (s || ''); reset()
|
||||||
|
// console.log(`sending out: ${oldbufstr} -> ${sendout}`)
|
||||||
return [bufAssemble(1), sendout]
|
return [bufAssemble(1), sendout]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"end":()=>{
|
"end":()=>{
|
||||||
console.log(`end composing`)
|
// console.log(`end composing`)
|
||||||
let ret = bufAssemble()
|
let ret = bufAssemble()
|
||||||
reset()
|
reset()
|
||||||
return ret
|
return ret
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ object IME {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun parseImeFile(file: File): TerrarumInputMethod {
|
private fun parseImeFile(file: File): TerrarumInputMethod {
|
||||||
val src = file.readText(Charsets.UTF_8)
|
val code = file.readText(Charsets.UTF_8)
|
||||||
val jsval = context.eval("js", "'use strict';$src")
|
val jsval = context.eval("js", "\"use strict\";(function(){$code})()")
|
||||||
val name = jsval.getMember("n").asString()
|
val name = jsval.getMember("n").asString()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ class UIItemTextLineInput(
|
|||||||
override fun update(delta: Float) {
|
override fun update(delta: Float) {
|
||||||
super.update(delta)
|
super.update(delta)
|
||||||
val mouseDown = Terrarum.mouseDown
|
val mouseDown = Terrarum.mouseDown
|
||||||
|
val oldActive = isActive
|
||||||
|
|
||||||
if (mouseDown) {
|
if (mouseDown) {
|
||||||
isActive = mouseUp
|
isActive = mouseUp
|
||||||
@@ -242,6 +243,7 @@ class UIItemTextLineInput(
|
|||||||
tryCursorBack()
|
tryCursorBack()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO IME endComposing() on hitting Enter
|
||||||
|
|
||||||
// don't put innards of tryCursorBack/Forward here -- you absolutely don't want that behaviour
|
// don't put innards of tryCursorBack/Forward here -- you absolutely don't want that behaviour
|
||||||
|
|
||||||
@@ -258,6 +260,9 @@ class UIItemTextLineInput(
|
|||||||
cursorOn = !cursorOn
|
cursorOn = !cursorOn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (oldActive) { // just became disactivated
|
||||||
|
// TODO IME endComposing()
|
||||||
|
}
|
||||||
|
|
||||||
if (mouseDown && !mouseLatched && (enablePasteButton && enableIMEButton && mouseUpOnButton1 || enableIMEButton && !enablePasteButton && mouseUpOnButton2)) {
|
if (mouseDown && !mouseLatched && (enablePasteButton && enableIMEButton && mouseUpOnButton1 || enableIMEButton && !enablePasteButton && mouseUpOnButton2)) {
|
||||||
toggleIME()
|
toggleIME()
|
||||||
|
|||||||
Reference in New Issue
Block a user