mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-11-30 19:08:18 +08:00
退格键
This commit is contained in:
parent
1dc6b82739
commit
5fa68fa45b
@ -201,6 +201,11 @@ public class SshHandler extends BaseHandler {
|
||||
}
|
||||
|
||||
private static void sendBinary(WebSocketSession session, String msg) {
|
||||
// 判断退格键
|
||||
char[] chars = msg.toCharArray();
|
||||
if (chars.length == 1 && chars[0] == 127) {
|
||||
return;
|
||||
}
|
||||
synchronized (session.getId()) {
|
||||
BinaryMessage byteBuffer = new BinaryMessage(msg.getBytes());
|
||||
try {
|
||||
|
@ -40,10 +40,27 @@
|
||||
term.onData(function (data) {
|
||||
sock.send(JSON.stringify({'data': data}));
|
||||
});
|
||||
|
||||
// 监听按键
|
||||
var startX = 2;
|
||||
term.onKey(function (key) {
|
||||
var ev = key.domEvent;
|
||||
// const printable = !ev.altKey && !ev.altGraphKey && !ev.ctrlKey && !ev.metaKey;
|
||||
if (ev.keyCode === 8) {
|
||||
// Do not delete the prompt
|
||||
if (term._core.buffer.x > startX) {
|
||||
term.write('\b \b');
|
||||
}
|
||||
}
|
||||
});
|
||||
//
|
||||
sock.onopen = function () {
|
||||
term.open(terminal, true);
|
||||
top.layer.closeAll();
|
||||
setTimeout(function () {
|
||||
startX = term._core.buffer.x;
|
||||
// console.log();
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
sock.onmessage = function (msg) {
|
||||
|
Loading…
Reference in New Issue
Block a user