Skip to content

Commit fc45634

Browse files
committed
Using webpack, jest for tests and travis
1 parent c02f809 commit fc45634

13 files changed

Lines changed: 5922 additions & 612 deletions

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["@babel/preset-env"]
3+
}

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: node_js
2+
node_js:
3+
- "7"
4+
- "8"

README.md

Lines changed: 61 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# term-echo
1+
# 📢 local-echo
22

33
> A fully functional local echo controller for xterm.js
44
@@ -8,36 +8,71 @@ You will be surprised how difficult it is to implement a fully functional local-
88

99
The local echo controller tries to replicate most of the bash-like user experience primitives, such as:
1010

11-
1. **Arrow Navigation** - Use `left` and `right` arrows to navigate in your input
12-
2. **Word-Boundary Navigation** - Use `alt+left` and `alt+right` to jump between words
13-
3. **Word-Boundary Deletion** - Use `alt+backspace` to delete a word
14-
4. **Multi-Line Continuation** - Break command to multiple lines if they contain incomplete quotation marks, boolean operators (`&&` or `||`), pipe operator (`|`), or new-line escape sequence (`\`).
15-
5. **Fully-Editable Multi-Line Continuation** - Navigate with your arrows and modify any line in your multi-line command.
16-
5. **Local History** - Just like bash, access the commands you previously typed using the `up` and `down` arrows.
17-
6. **Tab-Completion** - Provides callbacks where you can registry your custom tab-completion methods.
11+
- _Arrow navigation_: Use `left` and `right` arrows to navigate in your input
12+
- _Word-boundary navigation_: Use `alt+left` and `alt+right` to jump between words
13+
- _Word-boundary deletion_: Use `alt+backspace` to delete a word
14+
- _Multi-line continuation_: Break command to multiple lines if they contain incomplete quotation marks, boolean operators (`&&` or `||`), pipe operator (`|`), or new-line escape sequence (`\`).
15+
- _Full-navigation on multi-line command_: You are not limited only on the line you are editing, you can navigate and edit all of your lines.
16+
- _Local History_: Just like bash, access the commands you previously typed using the `up` and `down` arrows.
17+
- _Tab-Completion_: Provides support for registering your own tab-completion callbacks.
1818

19-
# Installation
19+
# Usage
2020

21-
```sh
22-
npm install --save wavesoft/local-echo
23-
```
21+
## As ES6 Module
2422

25-
# Usage
23+
1. Install it using `npm`:
24+
25+
```sh
26+
npm install --save wavesoft/local-echo
27+
```
28+
29+
Or yarn:
30+
31+
```sh
32+
yarn add wavesoft/local-echo
33+
```
34+
35+
2. Use it like so:
36+
37+
```js
38+
import { Terminal } from 'xterm';
39+
import LocalEchoController from 'local-echo';
40+
41+
// Start an xterm.js instance
42+
const term = new Terminal();
43+
term.open(document.getElementById('terminal'));
44+
45+
// Create a local echo controller
46+
const localEcho = new LocalEchoController(term);
47+
48+
// Read a single line from the user
49+
localEcho.read("~$ ")
50+
.then(input => alert(`User entered: ${input}`))
51+
.catch(error => alert(`Error reading: ${error}`));
52+
```
53+
54+
## Directly in the browser
55+
56+
1. Download `local-echo.js` from the latest [release](/wavesoft/local-echo/releases)
57+
2. Include it in your HTML:
58+
59+
```
60+
<script src="/local-echo.js"></script>
61+
```
2662
27-
```js
28-
import { Terminal } from 'xterm';
29-
import LocalEchoController from 'local-echo';
63+
3. Use it like so:
3064
31-
// Start an xterm.js instance
32-
const term = new Terminal();
33-
term.open(document.getElementById('terminal'));
65+
```js
66+
// Start an xterm.js instance
67+
const term = new Terminal();
68+
term.open(document.getElementById('terminal'));
3469
35-
// Create a local echo controller
36-
const localEcho = new LocalEchoController(term);
70+
// Create a local echo controller
71+
const localEcho = new LocalEchoController(term);
3772
38-
// Read a single line from the user
39-
localEcho.read("~$ ")
40-
.then(input => alert(`User entered: ${input}`))
41-
.catch(error => alert(`Error reading: ${error}`));
42-
```
73+
// Read a single line from the user
74+
localEcho.read("~$ ")
75+
.then(input => alert(`User entered: ${input}`))
76+
.catch(error => alert(`Error reading: ${error}`));
77+
```
4378

dist/local-echo.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/local-echo.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)