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
99The 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
0 commit comments