Home > other >  Xterm. Use js
Xterm. Use js

Time:11-16

Xterm TypeScript. Write the front end of the terminal is a component that can be directly in the browser to implement a command line terminal application,
Main features:
Terminal application to work properly: Xterm. Js is suitable for most of the terminal application, such as bash, vim and tmux, this includes based on the application of curses and mouse events to support support
Performant: Xterm. Js very fast, it even includes a GPU acceleration renderer
Rich in unicode support: support for CJK, emoticons and IME
Self contained: zero dependencies accessible: can use screenReaderMode options open screen reader support
There's more: links, themes, plugins, record a good API, etc.,

Xterm. Js is recommended to use the latest version of
Basic display:
 & lt; Template> 




<script>
The import 'xterm/dist/xterm. CSS
The import {Terminal} from 'xterm';

Export the default {
Mounted () {
Let terminalContainer=document. GetElementById (' terminal - container)
Let term=new Terminal ()
Term. The open (terminalContainer)
}
};
</script>

Project of copy, paste,
 & lt; Template> 




<script>
"Import" xterm/dist/xterm. CSS;
The import Terminal from attach "xterm";
The import * as fit the from "xterm/lib/addons/fit/fit";
Terminal. ApplyAddon (fit);//the Apply the ` fit ` addon
Export the default {
Data () {
Return {
Copy: ""
};
},
Mounted () {
Let terminalContainer=document. GetElementById (" terminal - container ");
Let term=new Terminal ({
//the cursor blink
CursorBlink: true
});
Term. The open (terminalContainer, true);
Term. The fit ();

Ws: let the websocket=new websocket (' * * * * * * * * * * ');//address
Websocket. BinaryType="arraybuffer";
//the connection is successful
Websocket. Onopen=function (evt) {
The console. The log (" onopen, "evt);
Term. Writeln (
"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"
);
};
//enter
Term. On (" data ", function (data) {
The console. The log (" data ", data);
Websocket. Send (new TextEncoder (.) encode (" \ x00 "+ data));
});
//return
Websocket. Onmessage=function (evt) {
Let the STR=new TextDecoder (). The decode (evt) data);
Term. The write (STR);
};
//close
Websocket. Onclose=function (evt) {
The console. The log (" close ", evt);
};
//error
Websocket. one rror=function (evt) {
The console. The log (" error ", evt);
};
//select copy
Term. On (" selection ", function () {
{if (term. HasSelection ())
Enclosing the copy=term. GetSelection ();
}
});
Term. AttachCustomKeyEventHandler (function (ev) {
//paste CTRL + v
If (ev) keyCode==86 & amp; & Ev. CtrlKey) {
Websocket. Send (new TextEncoder (.) encode (" \ x00 "+ enclosing the copy));
}
});
}
};
</script>

Attached: the project example: http://www.canis.cn/app_download.html
The tool supporting the IT operations engineer, welcome to register to download,
  • Related