finished?!
This commit is contained in:
parent
cddd475909
commit
be9fe1e3a3
86
ime.js
86
ime.js
@ -17,6 +17,30 @@ window.onload = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function imePush() {
|
||||||
|
//basically equavlient to pressing enter.
|
||||||
|
if (selected == -1) {
|
||||||
|
if (currentWord.join() == "") { //blame js :)
|
||||||
|
let s = document.createElement("p");
|
||||||
|
s.innerText = input.join("");
|
||||||
|
document.body.appendChild(s);
|
||||||
|
input = [];
|
||||||
|
selected = -1;
|
||||||
|
} else {
|
||||||
|
input.push(currentWord);
|
||||||
|
currentWord = [];
|
||||||
|
}
|
||||||
|
imeReset();
|
||||||
|
} else {
|
||||||
|
if (selected+1 >= input.length) {
|
||||||
|
selected = -1;
|
||||||
|
} else {
|
||||||
|
selected += 1;
|
||||||
|
}
|
||||||
|
imeReset(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function imeDown(keyEvent, inputField) {
|
function imeDown(keyEvent, inputField) {
|
||||||
keyEvent.preventDefault();
|
keyEvent.preventDefault();
|
||||||
switch (keyEvent.key) {
|
switch (keyEvent.key) {
|
||||||
@ -38,25 +62,7 @@ function imeDown(keyEvent, inputField) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "Enter":
|
case "Enter":
|
||||||
if (selected == -1) {
|
imePush()
|
||||||
if (currentWord.join() == "") { //blame js :)
|
|
||||||
let s = document.createElement("p");
|
|
||||||
s.innerText = input.join("");
|
|
||||||
document.body.appendChild(s);
|
|
||||||
input = [];
|
|
||||||
selected = -1;
|
|
||||||
} else {
|
|
||||||
input.push(currentWord);
|
|
||||||
currentWord = [];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (selected+1 >= input.length) {
|
|
||||||
selected = -1;
|
|
||||||
} else {
|
|
||||||
selected += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
imeReset();
|
|
||||||
break;
|
break;
|
||||||
case "Space":
|
case "Space":
|
||||||
//adds a ', on second press . an actual space
|
//adds a ', on second press . an actual space
|
||||||
@ -139,7 +145,7 @@ function imeMove(direction) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
imeReset();
|
imeReset(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
let inputState = 0; //STARTING, COMPOSTING, TRAILING, Fucking Nothing, ...cleanup
|
let inputState = 0; //STARTING, COMPOSTING, TRAILING, Fucking Nothing, ...cleanup
|
||||||
@ -209,17 +215,18 @@ function debugInput(key) {
|
|||||||
console.log("------------------------------")
|
console.log("------------------------------")
|
||||||
}
|
}
|
||||||
|
|
||||||
function imeReset() {
|
function imeReset(soft = false) {
|
||||||
stateState = 0;
|
stateState = 0;
|
||||||
inputState = 0;
|
inputState = 0;
|
||||||
inputFull = [];
|
inputFull = [];
|
||||||
inputCurrent = "";
|
inputCurrent = "";
|
||||||
if (selected == -1) {
|
if (!soft) {
|
||||||
currentWord = [];
|
if (selected == -1) {
|
||||||
} else {
|
currentWord = [];
|
||||||
input[selected] = [];
|
} else {
|
||||||
|
input[selected] = [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function imeInfo(decHex) {
|
function imeInfo(decHex) {
|
||||||
@ -386,10 +393,13 @@ function imeInput(key) {
|
|||||||
if (hVowelsK.includes(key)) {
|
if (hVowelsK.includes(key)) {
|
||||||
if (stateState == 1 && inputCurrent != "") {
|
if (stateState == 1 && inputCurrent != "") {
|
||||||
inputFull.pop();
|
inputFull.pop();
|
||||||
inputFull.push(getUnicodeConsonant(inputCurrent, key));
|
let ic = inputCurrent;
|
||||||
|
let k = key;
|
||||||
|
imePush();
|
||||||
|
inputFull.pop();
|
||||||
|
inputFull.push(getUnicodeConsonant(ic, k));
|
||||||
inputCurrent = "";
|
inputCurrent = "";
|
||||||
//reset state???
|
inputState = 2;
|
||||||
stateState = 0;
|
|
||||||
} else {
|
} else {
|
||||||
inputFull.push(getUnicodeVowel(key, "trailing"));
|
inputFull.push(getUnicodeVowel(key, "trailing"));
|
||||||
inputCurrent = "";
|
inputCurrent = "";
|
||||||
@ -397,16 +407,28 @@ function imeInput(key) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
inputFull.push(getUnicodeConsonant(key, "trailing"));
|
inputFull.push(getUnicodeConsonant(key, "trailing"));
|
||||||
if (stateState == 0) inputCurrent = key;
|
inputCurrent = key;
|
||||||
stateState += 1;
|
stateState += 1;
|
||||||
}
|
}
|
||||||
if (stateState == 2) {
|
if (stateState == 2) {
|
||||||
stateState = 0;
|
stateState = 0;
|
||||||
inputState = 3;
|
inputState = 3;
|
||||||
}
|
};
|
||||||
break;
|
break;
|
||||||
case 3: //go to next word uwu
|
case 3: //go to next word uwu
|
||||||
//todo :)
|
if (key != "") {
|
||||||
|
inputFull.pop();
|
||||||
|
let ic = inputCurrent;
|
||||||
|
let k = key;
|
||||||
|
imePush();
|
||||||
|
inputFull.pop();
|
||||||
|
inputFull.push(getUnicodeConsonant(ic, k));
|
||||||
|
inputCurrent = "";
|
||||||
|
inputState = 2;
|
||||||
|
} else {
|
||||||
|
imePush();
|
||||||
|
imeInput(key);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user