From c8157f53b1e7eaccfbf80071f3bc159f0529d9cc Mon Sep 17 00:00:00 2001 From: remi Date: Sat, 7 May 2022 17:51:12 +0200 Subject: [PATCH] bugs i think --- ime.js | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/ime.js b/ime.js index 4b18b04..95325e8 100644 --- a/ime.js +++ b/ime.js @@ -90,18 +90,17 @@ class HeonianIME { //close enough? } - imePush() { + imePush(space = false) { //basically equavlient to pressing enter. if (this.selected == -1) { - if (this.currentWord.join() == "") { //blame js :) - let s = document.createElement("p"); - s.innerText = this.input.join(""); - document.body.appendChild(s); - this.input = []; - this.selected = -1; - } else { + if (this.currentWord.join() != "") { //blame js :) this.input.push(this.currentWord); this.currentWord = []; + if (space == true) { + this.currentWord = [" "]; + this.input.push(this.currentWord); + this.currentWord = []; + } } this.imeReset(); } else { @@ -110,14 +109,17 @@ class HeonianIME { } else { this.selected += 1; } + if (space == true) { + this.input.splice(this.selected, 0, [" "]); + } this.imeReset(true); } } imeDown(keyEvent, inputField) { keyEvent.preventDefault(); - switch (keyEvent.key) { - case "Backspace": + switch (keyEvent.keyCode) { + case 8: if (this.selected == -1) { if (this.currentWord.join("") == "") { this.currentWord = this.input.pop() || []; @@ -134,25 +136,25 @@ class HeonianIME { } } break; - case "Enter": + case 13: this.imePush() break; - case "Space": - //TODO LMAO + case 32: + this.imePush(true); break; - case "ArrowLeft": + case 37: this.imeMove("left"); break; - case "ArrowRight": + case 39: this.imeMove("right"); break; - case "ArrowDown": + case 40: this.imeMove("start"); break; - case "ArrowUp": + case 38: this.imeMove("end"); break; - case "Escape": + case 27: this.imeDetach(); return; default: @@ -312,6 +314,10 @@ class HeonianIME { // ari fell asleep imeRestore(array) { + if (array.join("") == " ") { + this.imeChange(0,0,true,array); + return; + } let hex = array[array.length - 1].codePointAt(0).toString(16).split(""); hex[1] = hex[1].toString(16);//parseInt(hex[1], 16); hex[2] = hex[2].toString(16);//parseInt(hex[2], 16);