bug fix for less; console colour is preserved after the error print

This commit is contained in:
minjaesong
2022-06-21 11:43:12 +09:00
parent 371b80ca26
commit 8a0e89f5b9
3 changed files with 18 additions and 15 deletions

View File

@@ -39,5 +39,6 @@ if (exec_args[1]) {
serial.println(fo)
graphics.setBackground(ba[0], ba[1], ba[2])
_G.shell.usrcfg.textCol = fo
con.color_pair(fo, 255)
}

View File

@@ -108,6 +108,7 @@ function trimStartRevSlash(s) {
}
let shell = {};
shell.usrcfg = {textCol: 254}
shell.replaceVarCall = function(value) {
// syntax:
// line = literal [varcall] [literal] ;
@@ -306,12 +307,8 @@ shell.coreutils = {
graphics.clearPixels2(240);
},
cp: function(args) {
if (args[2] === undefined) {
printerrln("Syntax error")
return
}
else if (args[1] === undefined) {
printerrln(`Usage: ${args[0].toUpperCase()} SOURCE DEST`)
if (args[2] === undefined || args[1] === undefined) {
printerrln(`Usage: ${args[0].toUpperCase()} source_file destination_file`)
return
}
let path = shell.resolvePathInput(args[1])
@@ -367,7 +364,7 @@ shell.coreutils = {
},
del: function(args) {
if (args[1] === undefined) {
printerrln("Syntax error");
printerrln(`Usage: ${args[0].toUpperCase()} file_to_delete`);
return
}
@@ -386,7 +383,7 @@ shell.coreutils = {
},
mkdir: function(args) {
if (args[1] === undefined) {
printerrln("Syntax error");
printerrln(`Usage: ${args[0].toUpperCase()} directory_name_to_create`);
return
}
var path = shell.resolvePathInput(args[1])
@@ -718,6 +715,7 @@ if (goInteractive) {
let cmdHistoryScroll = 0; // 0 for outside-of-buffer, 1 for most recent
while (!cmdExit) {
con.curs_set(1);
con.color_pair(shell.usrcfg.textCol,255)
print_prompt_text();
var cmdbuf = "";

View File

@@ -15,7 +15,7 @@ let buf = "";
let fileContent = undefined
let key = -1;
let panSize = termW >> 1;
let scrollSize = termH >> 3;
let scrollSize = (termH / 6)|0;
let startAddr = -1;
let paintCur = 0;
@@ -106,14 +106,18 @@ while (true) {
/*Q*/if (key == 113 || key == 81) break;
/*R*/else if (key == 114 || key == 82) repaint();
/*up*/else if (key == con.KEY_UP) {
scroll -= scrollSize;
if (scroll < 0) scroll = 0;
repaint();
if (lineToBytes.length >= termH) { // only allow scrolling if the text is taller than the screen
scroll -= scrollSize;
if (scroll < 0) scroll = 0;
repaint();
}
}
/*down*/else if (key == con.KEY_DOWN) {
scroll += scrollSize;
if (scroll > lineToBytes.length - termH) scroll = lineToBytes.length - termH;
repaint();
if (lineToBytes.length >= termH) { // only allow scrolling if the text is taller than the screen
scroll += scrollSize;
if (scroll > lineToBytes.length - termH) scroll = lineToBytes.length - termH;
repaint();
}
}
/*left*/else if (key == con.KEY_LEFT && pan > 0) {
pan -= panSize;