mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 12:04:06 +09:00
3set: delete by letter pieces when assemblying
This commit is contained in:
@@ -266,6 +266,9 @@ let isChoseong = (s) => (s === undefined) ? false : inRange(s.charCodeAt(0), 0x
|
||||
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 isChoseongDigraph = (s) => (s === undefined) ? false : ([0x1100, 0x1103, 0x1107, 0x1109, 0x110C].includes(s.charCodeAt(0)))
|
||||
let isThisCharChoseongDigraph = (s) => (s === undefined) ? false : ([0x1101, 0x1104, 0x1108, 0x110A, 0x110D].includes(s.charCodeAt(0)))
|
||||
let isThisCharJungseongDigraph = (s) => (s === undefined) ? false : ([0x116A, 0x116B, 0x116C, 0x116F, 0x1170, 0x1171, 0x1174].includes(s.charCodeAt(0)))
|
||||
let isThisCharJongseongDigraph = (s) => (s === undefined) ? false : ([0x11A9, 0x11AA, 0x11AC, 0x11AD, 0x11B0, 0x11B1, 0x11B2, 0x11B3, 0x11B4, 0x11B5, 0x11B6, 0x11B9].includes(s.charCodeAt(0))) // ㅆ is an exception!
|
||||
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 isJungseongDigraphEU = (s) => (s === undefined) ? false : ([0x1175].includes(s.charCodeAt(0)))
|
||||
@@ -281,6 +284,37 @@ let jongseongDigraphsG = {"\u11A8":"\u11A9", "\u11BA":"\u11AA"}
|
||||
let jongseongDigraphsN = {"\u11BD":"\u11AC", "\u11C2":"\u11AD"}
|
||||
let jongseongDigraphsR = {"\u11A8":"\u11B0", "\u11B7":"\u11B1", "\u11B8":"\u11B2", "\u11BA":"\u11B3", "\u11C0":"\u11B4", "\u11C1":"\u11B5", "\u11C2":"\u11B6"}
|
||||
let jongseongDigraphsB = {"\u11BA":"\u11B9"}
|
||||
let detachChoseongDigraph = {
|
||||
"\u1101":["\u1100","\u1100"],
|
||||
"\u1104":["\u1103","\u1103"],
|
||||
"\u1108":["\u1107","\u1107"],
|
||||
"\u110A":["\u1109","\u1109"],
|
||||
"\u110D":["\u110C","\u110C"]
|
||||
}
|
||||
let detachJungseongDigraph = {
|
||||
"\u116A":["\u1169","\u1161"],
|
||||
"\u116B":["\u1169","\u1162"],
|
||||
"\u116C":["\u1169","\u1175"],
|
||||
"\u116F":["\u116E","\u1165"],
|
||||
"\u1170":["\u116E","\u1166"],
|
||||
"\u1171":["\u116E","\u1175"],
|
||||
"\u1174":["\u1173","\u1175"]
|
||||
}
|
||||
let detachJongseongDigraph = {
|
||||
"\u11A9":["\u11A8","\u11A8"],
|
||||
"\u11AA":["\u11A8","\u11BA"],
|
||||
"\u11AC":["\u11AB","\u11BD"],
|
||||
"\u11AD":["\u11AB","\u11C2"],
|
||||
"\u11B0":["\u11AF","\u11A8"],
|
||||
"\u11B1":["\u11AF","\u11B7"],
|
||||
"\u11B2":["\u11AF","\u11B8"],
|
||||
"\u11B3":["\u11AF","\u11BA"],
|
||||
"\u11B4":["\u11AF","\u11C0"],
|
||||
"\u11B5":["\u11AF","\u11C1"],
|
||||
"\u11B6":["\u11AF","\u11C2"],
|
||||
"\u11B9":["\u11B8","\u11BA"],
|
||||
"\u11BB":["\u11BA","\u11BA"]
|
||||
}
|
||||
let normaliseLUT = {
|
||||
// Hangul Jamo Initials → Hangul Compatibility Jamo
|
||||
"\u1100":"\u3131","\u1101":"\u3132","\u1102":"\u3134","\u1103":"\u3137","\u1104":"\u3138",
|
||||
@@ -388,10 +422,10 @@ return Object.freeze({"n":"세벌식 3-90","states":states,
|
||||
}
|
||||
// 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 oldbufstr = bufDebugStringify(states.buf)
|
||||
let sendout = bufAssemble(); reset()
|
||||
states.buf[bufIndex] = s
|
||||
let newbufstr = bufDebugStringify(states.buf)
|
||||
// let newbufstr = bufDebugStringify(states.buf)
|
||||
// console.log(`sending out: ${oldbufstr} -> ${sendout} ; ${newbufstr}`)
|
||||
return [bufAssemble(1), sendout]
|
||||
}
|
||||
@@ -403,12 +437,36 @@ return Object.freeze({"n":"세벌식 3-90","states":states,
|
||||
return [bufAssemble(1), ""]
|
||||
}
|
||||
else {
|
||||
let oldbufstr = bufDebugStringify(states.buf)
|
||||
// let oldbufstr = bufDebugStringify(states.buf)
|
||||
let sendout = bufAssemble() + (s || ''); reset()
|
||||
// console.log(`sending out: ${oldbufstr} -> ${sendout}`)
|
||||
return [bufAssemble(1), sendout]
|
||||
}
|
||||
},
|
||||
"backspace":()=>{
|
||||
// disassemble jung/jongseong digraphs
|
||||
// let oldbufstr = bufDebugStringify(states.buf)
|
||||
let last = states.buf.pop()
|
||||
|
||||
if (last !== undefined) {
|
||||
// detach jongseong
|
||||
if (isThisCharJongseongDigraph(last))
|
||||
states.buf[2] = detachJongseongDigraph[last][0]
|
||||
// detach jungseong
|
||||
else if (isThisCharJungseongDigraph(last))
|
||||
states.buf[1] = detachJungseongDigraph[last][0]
|
||||
// detach choseong
|
||||
else if (isThisCharChoseongDigraph(last))
|
||||
states.buf[0] = detachChoseongDigraph[last][0]
|
||||
}
|
||||
|
||||
if (states.buf.length == 0) reset()
|
||||
|
||||
// let newbufstr = bufDebugStringify(states.buf)
|
||||
// console.log(`popping assembly: ${oldbufstr} -> ${newbufstr}`)
|
||||
|
||||
return bufAssemble(1)
|
||||
},
|
||||
"end":()=>{
|
||||
// console.log(`end composing`)
|
||||
let ret = bufAssemble()
|
||||
|
||||
Reference in New Issue
Block a user