russian phonetic keyboard and its supporting components

This commit is contained in:
minjaesong
2021-11-14 15:04:00 +09:00
parent 6c98005bc8
commit a2935ff3ff
4 changed files with 110 additions and 14 deletions

View File

@@ -260,7 +260,7 @@ let reset = () => {
}
let inRange = (s,a,b) => (a <= s && s <= b)
let isDiacritics = (s) => s !== undefined && inRange(s.charCodeAt(0), 0x0300, 0x036F)
return Object.freeze({"n":"Русс. ЙЦУКЕН","v":"none","c":"CuriousTo\uA75Bvald","m":"rewrite",
return Object.freeze({"n":"Рус. ЙЦУКЕН (MS)","v":"none","c":"CuriousTo\uA75Bvald","m":"rewrite",
"t":states.keylayouts.map(it => [it[0],it[1]]),
// return: [displayed output, composed output]
"accept":(headkey,shiftin,altgrin)=>{

View File

@@ -0,0 +1,60 @@
let states = {"layouttable":{
"[":"ю",
"]":"щ",
"{":"Ю",
"}":"Щ",
"$":'"',
"%":":",
"`":"ё",
"~":"Ё",
"\\":"э",
"|":"Э",
"=":"ъ",
"+":"Ъ",
"'":"ж",
'"':"Ж",
";":"ь",
":":"Ь",
" ":" "
},
"code":0} // practically unused as long as there are no diacritics on the keyboard
;(function(){
let s = "АБЦДЕФГЧИЙКЛМНОПЯРСТУВШХЫЗ"
for (let i=0;i<s.length;i++) {
states.layouttable[String.fromCodePoint(i+65)] = String.fromCodePoint(s.codePointAt(i))
states.layouttable[String.fromCodePoint(i+97)] = String.fromCodePoint(s.codePointAt(i)+32)
}
})();
let reset = () => {
states.code = 0
}
let inRange = (s,a,b) => (a <= s && s <= b)
let isDiacritics = (s) => s !== undefined && inRange(s.charCodeAt(0), 0x0300, 0x036F)
return Object.freeze({"n":"Рус. Фонетическая","v":"none","c":"CuriousTo\uA75Bvald","m":"rewrite",
"tf":states.layouttable,
// return: [displayed output, composed output]
"accept":(headkey,shiftin,altgrin,lowlayerkey)=>{
let layer = 1*shiftin// + 2*altgrin
states.code = 1
let s = states.layouttable[lowlayerkey] || lowlayerkey
if (isDiacritics(s)) {
return ['1', '']
}
else {
return ['0', s]
}
},
"backspace":()=>{
reset()
return ''
},
"end":()=>{
reset()
return ''
},
"reset":()=>{ reset() },
"composing":()=>(states.code!=0)
})