Skip to content

Commit

Permalink
Using webpack, jest for tests and travis
Browse files Browse the repository at this point in the history
  • Loading branch information
wavesoft committed Sep 12, 2018
1 parent c02f809 commit fc45634
Show file tree
Hide file tree
Showing 13 changed files with 5,922 additions and 612 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env"]
}
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: node_js
node_js:
- "7"
- "8"
87 changes: 61 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# term-echo
# 📢 local-echo

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

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

1. **Arrow Navigation** - Use `left` and `right` arrows to navigate in your input
2. **Word-Boundary Navigation** - Use `alt+left` and `alt+right` to jump between words
3. **Word-Boundary Deletion** - Use `alt+backspace` to delete a word
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 (`\`).
5. **Fully-Editable Multi-Line Continuation** - Navigate with your arrows and modify any line in your multi-line command.
5. **Local History** - Just like bash, access the commands you previously typed using the `up` and `down` arrows.
6. **Tab-Completion** - Provides callbacks where you can registry your custom tab-completion methods.
- _Arrow navigation_: Use `left` and `right` arrows to navigate in your input
- _Word-boundary navigation_: Use `alt+left` and `alt+right` to jump between words
- _Word-boundary deletion_: Use `alt+backspace` to delete a word
- _Multi-line continuation_: Break command to multiple lines if they contain incomplete quotation marks, boolean operators (`&&` or `||`), pipe operator (`|`), or new-line escape sequence (`\`).
- _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.
- _Local History_: Just like bash, access the commands you previously typed using the `up` and `down` arrows.
- _Tab-Completion_: Provides support for registering your own tab-completion callbacks.

# Installation
# Usage

```sh
npm install --save wavesoft/local-echo
```
## As ES6 Module

# Usage
1. Install it using `npm`:

```sh
npm install --save wavesoft/local-echo
```

Or yarn:

```sh
yarn add wavesoft/local-echo
```

2. Use it like so:

```js
import { Terminal } from 'xterm';
import LocalEchoController from 'local-echo';
// Start an xterm.js instance
const term = new Terminal();
term.open(document.getElementById('terminal'));
// Create a local echo controller
const localEcho = new LocalEchoController(term);
// Read a single line from the user
localEcho.read("~$ ")
.then(input => alert(`User entered: ${input}`))
.catch(error => alert(`Error reading: ${error}`));
```
## Directly in the browser
1. Download `local-echo.js` from the latest [release](/wavesoft/local-echo/releases)
2. Include it in your HTML:
```
<script src="/local-echo.js"></script>
```
```js
import { Terminal } from 'xterm';
import LocalEchoController from 'local-echo';
3. Use it like so:
// Start an xterm.js instance
const term = new Terminal();
term.open(document.getElementById('terminal'));
```js
// Start an xterm.js instance
const term = new Terminal();
term.open(document.getElementById('terminal'));
// Create a local echo controller
const localEcho = new LocalEchoController(term);
// Create a local echo controller
const localEcho = new LocalEchoController(term);
// Read a single line from the user
localEcho.read("~$ ")
.then(input => alert(`User entered: ${input}`))
.catch(error => alert(`Error reading: ${error}`));
```
// Read a single line from the user
localEcho.read("~$ ")
.then(input => alert(`User entered: ${input}`))
.catch(error => alert(`Error reading: ${error}`));
```
2 changes: 2 additions & 0 deletions dist/local-echo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/local-echo.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit fc45634

Please sign in to comment.