mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-18 02:14:04 +09:00
fixing edit.js wip
This commit is contained in:
@@ -229,17 +229,21 @@ function writeout() {
|
||||
// KEYBOARDING FUNCTIONS //
|
||||
|
||||
function hitCtrlS() {
|
||||
sys.poke(-40, 1);
|
||||
sys.poke(-40, 255);
|
||||
return (sys.peek(-41) == 47 && (sys.peek(-42) == 129 || sys.peek(-42) == 130));
|
||||
}
|
||||
function hitCtrlX() {
|
||||
sys.poke(-40, 1);
|
||||
return (sys.peek(-41) == 52 && (sys.peek(-42) == 129 || sys.peek(-42) == 130));
|
||||
function hitCtrlQ() {
|
||||
sys.poke(-40, 255);
|
||||
return (sys.peek(-41) == 45 && (sys.peek(-42) == 129 || sys.peek(-42) == 130));
|
||||
}
|
||||
function hitAny() {
|
||||
sys.poke(-40, 1);
|
||||
sys.poke(-40, 255);sys.spin();
|
||||
return sys.peek(-41) != 0;
|
||||
}
|
||||
function getch() {
|
||||
sys.poke(-40, 255);
|
||||
return sys.peek(-41);
|
||||
}
|
||||
|
||||
function insertChar(code, row, col) {
|
||||
if (textbuffer[row] === undefined)
|
||||
@@ -427,13 +431,21 @@ else {
|
||||
}
|
||||
|
||||
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 (key == 17) // Ctrl-Q
|
||||
sys.poke(-40, 255)
|
||||
serial.println(`strobe: ${sys.peek(-41)}\t${sys.peek(-42)}`)
|
||||
|
||||
|
||||
if (hitCtrlQ()) // Ctrl-Q
|
||||
exit = true;
|
||||
else if (key == 19 && !bulletinShown) {
|
||||
else if (hitCtrlS() && !bulletinShown) {
|
||||
writeout();
|
||||
displayBulletin(`Wrote ${textbuffer.length} lines`);
|
||||
}
|
||||
@@ -497,6 +509,7 @@ while (!exit) {
|
||||
drawTextLineAbsolute(cursorRow, scrollHor); drawLnCol(); gotoText();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
con.clear();
|
||||
return 0;
|
||||
Reference in New Issue
Block a user