mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 11:51:49 +09:00
more robust multilingual print
This commit is contained in:
@@ -431,7 +431,10 @@ con.getch = function() {
|
||||
return sys.readKey();
|
||||
};
|
||||
con.move = function(y, x) {
|
||||
print("\x1B["+(y|0)+";"+(x|0)+"H");
|
||||
//print("\x1B["+(y|0)+";"+(x|0)+"H");
|
||||
// NOT using ANSI escape sequence as it conflicts with some multilingual drive which redefines PRINT function
|
||||
// and obviously this method is faster albeit less genuine :p
|
||||
graphics.setCursorYX(y|0, x|0);
|
||||
};
|
||||
con.addch = function(c) {
|
||||
graphics.putSymbol(c|0);
|
||||
@@ -446,20 +449,20 @@ con.getyx = function() {
|
||||
return graphics.getCursorYX();
|
||||
};
|
||||
con.curs_up = function() {
|
||||
let c = graphics.getCursorYX();
|
||||
con.move(c[0]-1,c[1]);
|
||||
let [y,x] = graphics.getCursorYX();
|
||||
con.move(y-1,x);
|
||||
};
|
||||
con.curs_down = function() {
|
||||
let c = graphics.getCursorYX();
|
||||
con.move(c[0]+1,c[1]);
|
||||
let [y,x] = graphics.getCursorYX();
|
||||
con.move(y+1,x);
|
||||
};
|
||||
con.curs_left = function() {
|
||||
let c = graphics.getCursorYX();
|
||||
con.move(c[0],c[1]-1);
|
||||
let [y,x] = graphics.getCursorYX();
|
||||
con.move(y,x-1);
|
||||
};
|
||||
con.curs_right = function() {
|
||||
let c = graphics.getCursorYX();
|
||||
con.move(c[0],c[1]+1);
|
||||
let [y,x] = graphics.getCursorYX();
|
||||
con.move(y,x+1);
|
||||
};
|
||||
con.hitterminate = function() { // ^C
|
||||
sys.poke(-40, 1);
|
||||
|
||||
@@ -330,17 +330,14 @@ unicode.getUniprint = (c) => {
|
||||
print = function(str) {
|
||||
if ((typeof str === 'string' || str instanceof String) && str.length > 0) {
|
||||
let cp = unicode.utf8toCodepoints(str)
|
||||
let q = unicode.getUniprint(cp[0])
|
||||
cp.forEach(c => {
|
||||
if (q == undefined) {
|
||||
let q = unicode.getUniprint(c)
|
||||
|
||||
if (q == undefined || !q[0](c)) {
|
||||
con.addch(4)
|
||||
con.curs_right()
|
||||
}
|
||||
else if (q[0](c)) {
|
||||
q[1](c)
|
||||
}
|
||||
else {
|
||||
q = unicode.getUniprint(c)
|
||||
q[1](c)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -97,7 +97,7 @@ class GraphicsJSR223Delegate(val vm: VM) {
|
||||
|
||||
fun setCursorYX(cy: Int, cx: Int) {
|
||||
getFirstGPU()?.let {
|
||||
it.setCursorPos(cy - 1, cx - 1)
|
||||
it.setCursorPos(cx - 1, cy - 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user