fixing edit.js wip

This commit is contained in:
minjaesong
2021-09-23 17:58:31 +09:00
parent d0196786b4
commit 3a1bb48514

View File

@@ -229,17 +229,21 @@ function writeout() {
// KEYBOARDING FUNCTIONS // // KEYBOARDING FUNCTIONS //
function hitCtrlS() { function hitCtrlS() {
sys.poke(-40, 1); sys.poke(-40, 255);
return (sys.peek(-41) == 47 && (sys.peek(-42) == 129 || sys.peek(-42) == 130)); return (sys.peek(-41) == 47 && (sys.peek(-42) == 129 || sys.peek(-42) == 130));
} }
function hitCtrlX() { function hitCtrlQ() {
sys.poke(-40, 1); sys.poke(-40, 255);
return (sys.peek(-41) == 52 && (sys.peek(-42) == 129 || sys.peek(-42) == 130)); return (sys.peek(-41) == 45 && (sys.peek(-42) == 129 || sys.peek(-42) == 130));
} }
function hitAny() { function hitAny() {
sys.poke(-40, 1); sys.poke(-40, 255);sys.spin();
return sys.peek(-41) != 0; return sys.peek(-41) != 0;
} }
function getch() {
sys.poke(-40, 255);
return sys.peek(-41);
}
function insertChar(code, row, col) { function insertChar(code, row, col) {
if (textbuffer[row] === undefined) if (textbuffer[row] === undefined)
@@ -427,13 +431,21 @@ else {
} }
while (!exit) { while (!exit) {
let key = con.getch(); let key = getch();
// TODO: either implement the new strobing-getch() by yourself or modify the sys.getch() so that CTRL-alph would return correct numbers
if (key != 0) {
serial.println(`getch = ${key}`)
if (bulletinShown) dismissBulletin(); if (bulletinShown) dismissBulletin();
if (key == 17) // Ctrl-Q sys.poke(-40, 255)
serial.println(`strobe: ${sys.peek(-41)}\t${sys.peek(-42)}`)
if (hitCtrlQ()) // Ctrl-Q
exit = true; exit = true;
else if (key == 19 && !bulletinShown) { else if (hitCtrlS() && !bulletinShown) {
writeout(); writeout();
displayBulletin(`Wrote ${textbuffer.length} lines`); displayBulletin(`Wrote ${textbuffer.length} lines`);
} }
@@ -496,6 +508,7 @@ while (!exit) {
// end of con.KEY_RIGHT // end of con.KEY_RIGHT
drawTextLineAbsolute(cursorRow, scrollHor); drawLnCol(); gotoText(); drawTextLineAbsolute(cursorRow, scrollHor); drawLnCol(); gotoText();
} }
}
} }
con.clear(); con.clear();