mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Update README.md
Adding a getting started instruction for adding xterm to a parent div and listening for data output from xterm
This commit is contained in:
@@ -52,6 +52,28 @@ npm start
|
||||
|
||||
Then open http://0.0.0.0:3000 in a web browser (use http://127.0.0.1:3000 if running under Windows).
|
||||
|
||||
## Getting Started
|
||||
|
||||
To attact the xterm `Terminal` to a parent div
|
||||
|
||||
```html
|
||||
<div id="terminal"></div>
|
||||
```
|
||||
|
||||
```js
|
||||
var term = new Terminal();
|
||||
term.open(document.getElementById('#terminal'));
|
||||
term.write('Hello from \033[1;3;31mxterm.js\033[0m $ ')
|
||||
```
|
||||
To get the data from xterm to send to a server or for proccessing you can
|
||||
|
||||
```js
|
||||
function onDataReceived(data) {
|
||||
// Your logic
|
||||
}
|
||||
term.on('data', onDataReceived);
|
||||
```
|
||||
|
||||
## Addons
|
||||
|
||||
Addons are JavaScript modules that attach functions to the `Terminal` prototype to extend its functionality. There are a handful available in the main repository in the `dist/addons` directory, you can even write your own (though they may break when the internals of xterm.js change across versions).
|
||||
|
||||
Reference in New Issue
Block a user