Update README.md

Added Getting started content from the xtermjs.org website
This commit is contained in:
Saswat Das
2016-12-18 04:48:19 +05:30
committed by GitHub
parent 4ee1e00808
commit d018a547a2
+17 -17
View File
@@ -54,25 +54,25 @@ Then open http://0.0.0.0:3000 in a web browser (use http://127.0.0.1:3000 if run
## Getting Started ## Getting Started
To attact the xterm `Terminal` to a parent div To start using xterm.js on your browser, add the `xterm.js` and `xterm.css` to the head of your html page. Then create a `<div id="terminal"></div>` onto which xterm can attach itself.
```html ```html
<div id="terminal"></div> <!doctype html>
``` <html>
<head>
```js <link rel="stylesheet" href="bower_components/xterm.js/dist/xterm.css" />
var term = new Terminal(); <script src="bower_components/xterm.js/dist/xterm.js"></script>
term.open(document.getElementById('#terminal')); </head>
term.write('Hello from \033[1;3;31mxterm.js\033[0m $ ') <body>
``` <div id="terminal"></div>
To get the data from xterm to send to a server or for proccessing you can <script>
var term = new Terminal();
```js term.open(document.getElementById('#terminal'));
function onDataReceived(data) { term.write('Hello from \033[1;3;31mxterm.js\033[0m $ ')
// Your logic </script>
} </body>
term.on('data', onDataReceived); </html>
``` ```
Finally instantiate the `Terminal` object and then call the `open` function with the DOM object of the `div`.
## Addons ## Addons