xterm.js 框架 vim显示不到全屏

huang5hun 2017-02-28 08:09:20
xterm.js 框架使用vim后 数据就无法占据全部屏幕。

这里是部分代码

term = new Terminal({
cols: 120,
rows: 24,
cursorBlink: 5,
scrollback: 100,
tabStopWidth: 4
});
term.open(document.getElementById('#term'));
term.fit();
conn = new WebSocket("ws://localhost:12345");
conn.onerror = function () { showErrorMessage('connect error.') };
conn.onmessage = function(event) {
term.write(event.data);
};
conn.onopen = function () { loginSshServer(); }
...全文
3533 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
红色雨海 2021-06-24
  • 打赏
  • 举报
回复

这个问题最后怎么解决的呀楼主

 

ligang626 2019-11-21
  • 打赏
  • 举报
回复
你好,我想问下,你的问题解决了么? 我有两个问题: 1.vim怎么使用?需要调用xterm的什么方法? 2.使用xterm.write("")。然后想修改刚才打印的数据,怎么办? xterm.refresh(0,1),感觉这个方法会有用。但是不知道怎么使用 谢谢
qq_28773507 2017-11-13
  • 打赏
  • 举报
回复
dfgdfgd
qq_28773507 2017-11-11
  • 打赏
  • 举报
回复
引用 1 楼 mny007 的回复:
请问楼主, 我的xterm.js怎么不能输入字符,我想模拟Linux终端用到xterm.js,页面代码如下,麻烦帮我看看,用什么问题? <!DOCTYPE html> <%@page pageEncoding="utf-8" %> <%@page contentType="text/html;charset=utf-8" %> <html> <head> <meta http-equiv="Content-Type" content="text/html charset=utf-8" /> <link rel="stylesheet" href="../js/xterm.css"/> <script type="text/javascript" src="../js/xterm.js"></script> </head> <body> <div id="terminal"></div> <script> var term = new Terminal(); var wsurl = 'ws://localhost:8080/webTerm/webSecureCRT/192.168.48.154/22/root/aa'; term.open(document.getElementById('terminal')); ws = new WebSocket(wsurl); ws.onerror = function () { console.log("error occurred!"); }; ws.onmessage = function(event) { term.write(event.data); }; ws.onopen = function () { console.log("connection opened!"); } ws.onclose = function (event) { //关闭连接 console.log("connection closed!"); websocket.close(); }; </script> </body> </html>
我在写webshell 遇到问题 不知道能否帮忙解答一下?
qq_28773507 2017-11-11
  • 打赏
  • 举报
回复
引用 楼主 huang5hun 的回复:
xterm.js 框架使用vim后 数据就无法占据全部屏幕。 这里是部分代码

term = new Terminal({
        cols: 120,
        rows: 24,
        cursorBlink: 5,
        scrollback: 100,
        tabStopWidth: 4
    });
term.open(document.getElementById('#term'));
term.fit();
conn = new WebSocket("ws://localhost:12345");
conn.onerror = function () { showErrorMessage('connect error.') };
conn.onmessage = function(event) {
    term.write(event.data);
};
conn.onopen = function () { loginSshServer(); }
我在写webshell 遇到问题 不知道能否帮忙解答一下?
huang5hun 2017-06-05
  • 打赏
  • 举报
回复
引用 1 楼 mny007 的回复:
请问楼主, 我的xterm.js怎么不能输入字符,我想模拟Linux终端用到xterm.js,页面代码如下,麻烦帮我看看,用什么问题? <!DOCTYPE html> <%@page pageEncoding="utf-8" %> <%@page contentType="text/html;charset=utf-8" %> <html> <head> <meta http-equiv="Content-Type" content="text/html charset=utf-8" /> <link rel="stylesheet" href="../js/xterm.css"/> <script type="text/javascript" src="../js/xterm.js"></script> </head> <body> <div id="terminal"></div> <script> var term = new Terminal(); var wsurl = 'ws://localhost:8080/webTerm/webSecureCRT/192.168.48.154/22/root/aa'; term.open(document.getElementById('terminal')); ws = new WebSocket(wsurl); ws.onerror = function () { console.log("error occurred!"); }; ws.onmessage = function(event) { term.write(event.data); }; ws.onopen = function () { console.log("connection opened!"); } ws.onclose = function (event) { //关闭连接 console.log("connection closed!"); websocket.close(); }; </script> </body> </html>
不好意思。现在才看到这个信息。不知道您解决没有。这里给出我的答案。 xterm有一个键盘响应事件。把字符发送给sshServer, sshServer会返回相应的字符回来。只要webSocket接受显示就行了。

term.on('data', function($data) {
   ws.send($data);
});
huang5hun 2017-06-05
  • 打赏
  • 举报
回复
引用 2 楼 libonanaiqiu 的回复:
这个问题,是由于连接SSH时未指定Bash窗口的大小造成的,如下代码可以参考: /** * 创建到远程服务器的ssh的channel * * @param username 登录用户名 * @param password 登录密码 * @param host 远程主机 * @param port 远程端口 * @param col 终端的列数 * @param row 终端的行数 * @param wp 窗口的宽度,px单位 * @param hp 窗口的高度,px单位 * @return 创建好的channelShell * @throws JSchException */ public ChannelShell createChannel(String username, String password, String host, int port, int col, int row, int wp, int hp) throws JSchException { Session session = jsch.getSession(username, host, port); session.setPassword(password); session.setConfig("StrictHostKeyChecking", "no"); session.setConfig("PreferredAuthentications", "password"); session.setServerAliveInterval(40000); session.setTimeout(120000); session.setDaemonThread(true); session.connect(30000); ChannelShell channel = (ChannelShell) session.openChannel("shell"); channel.setEnv("LANG", "zh_CN.UTF8"); channel.setAgentForwarding(false); channel.setPtyType("xterm"); channel.connect(10000); channel.setPtySize(col, row, wp, hp); return channel; }
感谢。我用的是Python,现在已经在paramiko库中找到相应的接口了。
libonanaiqiu 2017-06-03
  • 打赏
  • 举报
回复 1
这个问题,是由于连接SSH时未指定Bash窗口的大小造成的,如下代码可以参考: /** * 创建到远程服务器的ssh的channel * * @param username 登录用户名 * @param password 登录密码 * @param host 远程主机 * @param port 远程端口 * @param col 终端的列数 * @param row 终端的行数 * @param wp 窗口的宽度,px单位 * @param hp 窗口的高度,px单位 * @return 创建好的channelShell * @throws JSchException */ public ChannelShell createChannel(String username, String password, String host, int port, int col, int row, int wp, int hp) throws JSchException { Session session = jsch.getSession(username, host, port); session.setPassword(password); session.setConfig("StrictHostKeyChecking", "no"); session.setConfig("PreferredAuthentications", "password"); session.setServerAliveInterval(40000); session.setTimeout(120000); session.setDaemonThread(true); session.connect(30000); ChannelShell channel = (ChannelShell) session.openChannel("shell"); channel.setEnv("LANG", "zh_CN.UTF8"); channel.setAgentForwarding(false); channel.setPtyType("xterm"); channel.connect(10000); channel.setPtySize(col, row, wp, hp); return channel; }
mny007 2017-04-05
  • 打赏
  • 举报
回复
请问楼主, 我的xterm.js怎么不能输入字符,我想模拟Linux终端用到xterm.js,页面代码如下,麻烦帮我看看,用什么问题? <!DOCTYPE html> <%@page pageEncoding="utf-8" %> <%@page contentType="text/html;charset=utf-8" %> <html> <head> <meta http-equiv="Content-Type" content="text/html charset=utf-8" /> <link rel="stylesheet" href="../js/xterm.css"/> <script type="text/javascript" src="../js/xterm.js"></script> </head> <body> <div id="terminal"></div> <script> var term = new Terminal(); var wsurl = 'ws://localhost:8080/webTerm/webSecureCRT/192.168.48.154/22/root/aa'; term.open(document.getElementById('terminal')); ws = new WebSocket(wsurl); ws.onerror = function () { console.log("error occurred!"); }; ws.onmessage = function(event) { term.write(event.data); }; ws.onopen = function () { console.log("connection opened!"); } ws.onclose = function (event) { //关闭连接 console.log("connection closed!"); websocket.close(); }; </script> </body> </html>

87,993

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧