mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-11 07:14:04 +09:00
fixing edit.js wip
This commit is contained in:
@@ -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`);
|
||||||
}
|
}
|
||||||
@@ -497,6 +509,7 @@ while (!exit) {
|
|||||||
drawTextLineAbsolute(cursorRow, scrollHor); drawLnCol(); gotoText();
|
drawTextLineAbsolute(cursorRow, scrollHor); drawLnCol(); gotoText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
con.clear();
|
con.clear();
|
||||||
return 0;
|
return 0;
|
||||||
Reference in New Issue
Block a user