mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-10 15:04:03 +09:00
edit.js: filename display will get an extra asterisk if the contents has been changed
This commit is contained in:
@@ -28,6 +28,8 @@ else {
|
|||||||
let driveLetter = _G.shell.getCurrentDrive();
|
let driveLetter = _G.shell.getCurrentDrive();
|
||||||
let filePath = _G.shell.getPwdString() + filename;
|
let filePath = _G.shell.getPwdString() + filename;
|
||||||
|
|
||||||
|
let contentChanged = false;
|
||||||
|
|
||||||
let scroll = 0;
|
let scroll = 0;
|
||||||
let scrollHor = 0;
|
let scrollHor = 0;
|
||||||
let textbuffer = [""];
|
let textbuffer = [""];
|
||||||
@@ -135,8 +137,9 @@ function drawMenubarBase() {
|
|||||||
con.addch(222);con.curs_right();
|
con.addch(222);con.curs_right();
|
||||||
con.addch(221);con.curs_right();
|
con.addch(221);con.curs_right();
|
||||||
let cursPos = con.getyx();
|
let cursPos = con.getyx();
|
||||||
|
let filenameStr = (contentChanged) ? `${filename}*` : filename;
|
||||||
for (let i = cursPos[1]; i < windowWidth; i++) {
|
for (let i = cursPos[1]; i < windowWidth; i++) {
|
||||||
con.mvaddch(1, i, filename.codePointAt(i-cursPos[1]));
|
con.mvaddch(1, i, filenameStr.codePointAt(i-cursPos[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,8 +200,13 @@ function gotoText() {
|
|||||||
|
|
||||||
// FUNCTIONING FUNCTIONS (LOL) //
|
// FUNCTIONING FUNCTIONS (LOL) //
|
||||||
|
|
||||||
|
function setContentChanged(b) {
|
||||||
|
contentChanged = b
|
||||||
|
}
|
||||||
|
|
||||||
function writeout() {
|
function writeout() {
|
||||||
file.swrite(textbuffer.join("\n"))
|
file.swrite(textbuffer.join("\n"))
|
||||||
|
setContentChanged(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// KEYBOARDING FUNCTIONS //
|
// KEYBOARDING FUNCTIONS //
|
||||||
@@ -417,23 +425,22 @@ while (!exit) {
|
|||||||
let keycodes = [event[3],event[4],event[5],event[6],event[7],event[8],event[9],event[10]]
|
let keycodes = [event[3],event[4],event[5],event[6],event[7],event[8],event[9],event[10]]
|
||||||
let keycode = keycodes[0]
|
let keycode = keycodes[0]
|
||||||
|
|
||||||
// TODO: either implement the new strobing-getch() by yourself or modify the sys.getch() so that CTRL-alph would return correct numbers
|
|
||||||
|
|
||||||
// serial.println(`getch = ${key}`)
|
|
||||||
|
|
||||||
if (bulletinShown) dismissBulletin();
|
if (bulletinShown) dismissBulletin();
|
||||||
|
|
||||||
if (keysym == "q" && keycodes[1] == 129) // Ctrl-Q
|
if (keysym == "q" && keycodes[1] == 129) // Ctrl-Q
|
||||||
exit = true;
|
exit = true;
|
||||||
else if (keysym == "s" && keycodes[1] == 129 && !bulletinShown) {
|
else if (keysym == "s" && keycodes[1] == 129 && !bulletinShown) {
|
||||||
writeout();
|
writeout();
|
||||||
|
drawLnCol();
|
||||||
displayBulletin(`Wrote ${textbuffer.length} lines`);
|
displayBulletin(`Wrote ${textbuffer.length} lines`);
|
||||||
}
|
}
|
||||||
else if (keycode == 67) { // Bksp
|
else if (keycode == 67) { // Bksp
|
||||||
|
setContentChanged(true)
|
||||||
backspaceOnce();
|
backspaceOnce();
|
||||||
drawLnCol(); gotoText();
|
drawLnCol(); gotoText();
|
||||||
}
|
}
|
||||||
else if (keycode == 66) { // Return
|
else if (keycode == 66) { // Return
|
||||||
|
setContentChanged(true)
|
||||||
appendLine(); drawLnCol(); gotoText();
|
appendLine(); drawLnCol(); gotoText();
|
||||||
}
|
}
|
||||||
else if (keysym == "<LEFT>") {
|
else if (keysym == "<LEFT>") {
|
||||||
@@ -467,6 +474,7 @@ while (!exit) {
|
|||||||
cursorMoveRelative(BIG_STRIDE, 0);
|
cursorMoveRelative(BIG_STRIDE, 0);
|
||||||
}
|
}
|
||||||
else if (keysym == "<TAB>") { // insert spaces appropriately
|
else if (keysym == "<TAB>") { // insert spaces appropriately
|
||||||
|
setContentChanged(true)
|
||||||
let tabsize = TAB_SIZE - (cursorCol % TAB_SIZE);
|
let tabsize = TAB_SIZE - (cursorCol % TAB_SIZE);
|
||||||
|
|
||||||
for (let k = 0; k < tabsize; k++) {
|
for (let k = 0; k < tabsize; k++) {
|
||||||
@@ -480,6 +488,7 @@ while (!exit) {
|
|||||||
drawTextLineAbsolute(cursorRow, scrollHor); drawLnCol(); gotoText();
|
drawTextLineAbsolute(cursorRow, scrollHor); drawLnCol(); gotoText();
|
||||||
}
|
}
|
||||||
else if (keysym.length == 1 || !keysym.startsWith("<")) { // printables (excludes \n)
|
else if (keysym.length == 1 || !keysym.startsWith("<")) { // printables (excludes \n)
|
||||||
|
setContentChanged(true)
|
||||||
insertChar(keysym, cursorRow, cursorCol);
|
insertChar(keysym, cursorRow, cursorCol);
|
||||||
// identical to con.KEY_RIGHT
|
// identical to con.KEY_RIGHT
|
||||||
cursoringCol = cursorCol + 1;
|
cursoringCol = cursorCol + 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user