Improve terminal.
This commit is contained in:
@ -283,6 +283,8 @@ if (!globalObj.write) {
|
|||||||
if (ch === 8) {
|
if (ch === 8) {
|
||||||
context.cx = Math.max(0, context.cx - 1);
|
context.cx = Math.max(0, context.cx - 1);
|
||||||
} else if (ch === 13) {
|
} else if (ch === 13) {
|
||||||
|
context.lines[context.cy][1].splice(
|
||||||
|
context.cx++, 1, [context.attrib[0], context.attrib[1]]);
|
||||||
context.cx = 0;
|
context.cx = 0;
|
||||||
} else {
|
} else {
|
||||||
context.lines[context.cy][1].splice(
|
context.lines[context.cy][1].splice(
|
||||||
@ -309,7 +311,9 @@ if (!globalObj.write) {
|
|||||||
p[0] |= 0x1000000;
|
p[0] |= 0x1000000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p[2].push(line[x][2]);
|
if (line[x].length >= 2) {
|
||||||
|
p[2].push(line[x][2]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (x == context.cx && y == context.cy) {
|
if (x == context.cx && y == context.cy) {
|
||||||
if (parts.length > 0) {
|
if (parts.length > 0) {
|
||||||
@ -539,6 +543,14 @@ if (!globalObj.write) {
|
|||||||
}
|
}
|
||||||
window.onkeypress = KeyPress;
|
window.onkeypress = KeyPress;
|
||||||
function KeyDown(e) {
|
function KeyDown(e) {
|
||||||
|
const mappings = {
|
||||||
|
'ArrowUp': [27, 91, 65],
|
||||||
|
'ArrowDown': [27, 91, 66],
|
||||||
|
'ArrowRight': [27, 91, 67],
|
||||||
|
'ArrowLeft': [27, 91, 68],
|
||||||
|
'PageUp': [27, 91, 53, 92],
|
||||||
|
'PageDown': [27, 91, 54, 92],
|
||||||
|
};
|
||||||
if (e.ctrlKey) {
|
if (e.ctrlKey) {
|
||||||
if (e.keyCode == 50) {
|
if (e.keyCode == 50) {
|
||||||
context.inbuffer.push(0);
|
context.inbuffer.push(0);
|
||||||
@ -547,6 +559,10 @@ if (!globalObj.write) {
|
|||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
|
} else if (mappings[e.key]) {
|
||||||
|
context.inbuffer = context.inbuffer.concat(mappings[e.key]);
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
} else if (e.keyCode == 8 || e.keyCode == 9 || e.keyCode == 27) {
|
} else if (e.keyCode == 8 || e.keyCode == 9 || e.keyCode == 27) {
|
||||||
context.cursor_time = new Date().getTime();
|
context.cursor_time = new Date().getTime();
|
||||||
context.inbuffer.push(e.keyCode);
|
context.inbuffer.push(e.keyCode);
|
||||||
|
|||||||
Reference in New Issue
Block a user