behaviour of con.addch changed - no longer advances cursor

This commit is contained in:
minjaesong
2021-01-29 14:19:37 +09:00
parent c73a725466
commit d963cf8294
10 changed files with 36 additions and 19 deletions

View File

@@ -394,6 +394,22 @@ con.getmaxyx = function() {
con.getyx = function() {
return graphics.getCursorYX();
};
con.curs_up = function() {
let c = graphics.getCursorYX();
con.move(c[0]-1,c[1]);
};
con.curs_down = function() {
let c = graphics.getCursorYX();
con.move(c[0]+1,c[1]);
};
con.curs_left = function() {
let c = graphics.getCursorYX();
con.move(c[0],c[1]-1);
};
con.curs_right = function() {
let c = graphics.getCursorYX();
con.move(c[0],c[1]+1);
};
con.hitterminate = function() { // ^C
sys.poke(-40, 1);
return (sys.peek(-41) == 31 && (sys.peek(-42) == 129 || sys.peek(-42) == 130));

View File

@@ -2,6 +2,6 @@ con.clear();
con.move(1,1);
for (let i = 0; i < 1024; i++) {
if (i < 512) con.color_pair(239, 0); else con.color_pair(0, 239);
con.addch(i%256);
con.addch(i%256);con.curs_right();
}
println();

View File

@@ -236,11 +236,11 @@ const greetRightPad = termWidth - greetLeftPad - greetText.length - 6;
con.clear();
con.color_pair(253,255);
print(' ');con.addch(17);
print(' ');con.addch(17);con.curs_right();
con.color_pair(0,253);
print(" ".repeat(greetLeftPad)+greetText+" ".repeat(greetRightPad));
con.color_pair(253,255);
con.addch(16);
con.addch(16);con.curs_right();print(' ');
con.move(3,1);
con.color_pair(239,255);
@@ -1117,9 +1117,10 @@ if no arg text were given (e.g. "10 NEXT"), args will have zero length
let printstr = "";
if (rsvArg === undefined)
print("")
else if (!isNaN(rsvArg)) {
else if (isNumable(rsvArg)) {
let c = con.getyx();
con.addch(rsvArg);
con.addch(tonum(rsvArg));
con.move(c[0],c[1]+1);
}
else if (rsvArg.toString !== undefined)
print(rsvArg.toString());

View File

@@ -21,7 +21,7 @@ function print_prompt_text() {
con.color_pair(239,161);
print(" "+CURRENT_DRIVE+":");
con.color_pair(161,253);
con.addch(16);
con.addch(16);con.curs_right();
con.color_pair(0,253);
print(" \\"+shell_pwd.join("\\").substring(1)+" ");
if (errorlevel != 0) {
@@ -29,8 +29,8 @@ function print_prompt_text() {
print("["+errorlevel+"] ");
}
con.color_pair(253,255);
con.addch(16);
con.addch(32);
con.addch(16);con.curs_right();
con.addch(32);con.curs_right();
con.color_pair(239,255);
}
else {
@@ -46,11 +46,11 @@ function greet() {
con.color_pair(239,255);
con.clear();
con.color_pair(253,255);
print(' ');con.addch(17);
print(' ');con.addch(17);con.curs_right();
con.color_pair(0,253);
print(" ".repeat(greetLeftPad)+welcome_text+" ".repeat(greetRightPad));
con.color_pair(253,255);
con.addch(16);print(' ');
con.addch(16);con.curs_right();print(' ');
con.move(3,1);
}
else

View File

@@ -9,12 +9,12 @@ function print_prompt_text() {
con.color_pair(239,161);
print(" "+CURRENT_DRIVE+":");
con.color_pair(161,253);
con.addch(16);
con.addch(16);con.curs_right();
con.color_pair(0,253);
print(" \\"+shell_pwd.join("\\")+" ");
con.color_pair(253,255);
con.addch(16);
con.addch(32);
con.addch(16);con.curs_right();
con.addch(32);con.curs_right();
con.color_pair(239,255);
}

View File

@@ -69,7 +69,7 @@ let repaint = function() {
if (cx >= 0 && cx < termW) {
con.move(cy, cx);
if (char != 10 && char != 13)
con.addch(char);
con.addch(char);con.curs_right();
}
cx += 1;
}

View File

@@ -26,11 +26,12 @@ class SimpleScreen {
con.move(1,1);
con.color_pair(253,255);
print(' ');con.addch(17);
print(' ');con.addch(17);con.curs_right();
con.color_pair(0,253);
print(" ".repeat(titleLeftPad)+this.title+" ".repeat(titleRightPad));
con.color_pair(253,255);
con.addch(16);print(' ');
con.addch(16);con.curs_right();print(' ');
con.move(3,1);
}
redraw() {
con.color_pair(239,255);

View File

@@ -88,7 +88,6 @@ class GraphicsJSR223Delegate(val vm: VM) {
it.putChar(cx, cy, c.toByte())
it.setCursorPos(cx + 1, cy)
}
}

View File

@@ -123,7 +123,7 @@ open class GraphicsAdapter(val vm: VM, val config: AdapterConfig, val sgr: Super
var newx = x
var newy = y
if (newx > TEXT_COLS) {
if (newx >= TEXT_COLS) {
newx = 0
newy += 1
}

View File

@@ -39,7 +39,7 @@ class TTY(val vm: VM) : GlassTty(TEXT_ROWS, TEXT_COLS), PeriBase {
var newx = x
var newy = y
if (newx > TEXT_COLS) {
if (newx >= TEXT_COLS) {
newx = 0
newy += 1
}