mirror of
https://github.com/elua/elua.git
synced 2025-01-08 20:56:17 +08:00
47 lines
2.8 KiB
Plaintext
47 lines
2.8 KiB
Plaintext
// $$HEADER$$
|
|
What is linenoise?
|
|
------------------
|
|
Technically speaking, https://github.com/antirez/linenoise[Linenoise] is a small
|
|
replacement library for GNU's http://tiswww.case.edu/php/chet/readline/rltop.html[readline]
|
|
library, which is already supported by standard Lua. What it actually does is
|
|
give you a nice way to edit your Lua commands inside the Lua interpreter
|
|
(by using the arrow keys and other key sequences presented below)
|
|
recall a line that was already entered, and save the history of the lines you
|
|
entered. It's very convenient when prototyping within the Lua interpreter, because
|
|
all the lines entered at the Lua prompt can be saved and turned into a proper
|
|
application by editing the saved file. It also takes the Lua interpreter much
|
|
closer to its desktop counterpart with regards to ease of use.
|
|
|
|
Linenoise in eLua
|
|
-----------------
|
|
Starting with version 0.8, eLua contains a port of the linenoise library. To use it, make sure it is included
|
|
in the build, refer to the link:building.html[build instructions] for details. Note that linenoise requires
|
|
ANSI terminal support (*BUILD_TERM*), so you need to enable that too. To use it, simply start the Lua interpreter.
|
|
The table below contains a list of keys that can be used to take advantage of linenoise:
|
|
|
|
[width="80%", cols="<2,<5", options="header"]
|
|
|=============================================
|
|
^| Key(s) ^| Action
|
|
| Left and right | Move left and right in the current prompt line
|
|
| Up | Recall the previous line
|
|
| Down | Recall the next line
|
|
| CTRL+C | Abandon the current line
|
|
| Home | Go to the beginning of the line
|
|
| End | Go to the end of the line
|
|
| CTRL+K | Delete from the cursor to the end of the line
|
|
| CTRL+U | Delete the current line
|
|
|=============================================
|
|
|
|
To save the history, simply call *elua.save_history* with the name of the file in which the history will be saved
|
|
(check link:refman_gen_elua.html[here] for details). Be careful, the file will be overwritten. +
|
|
The exact same keys presented in the table above can be used by the eLua shell if linenoise is enabled for it.
|
|
However, you won't be able to save history from the eLua shell. +
|
|
The reason why this component isn't enabled by default is that it takes RAM (like all good things in eLua :) ) so
|
|
keep this in mind when deciding if you want it or not.
|
|
|
|
IMPORTANT: linenoise support seems to be dependent on the terminal emulator used with eLua on the PC side. It was tested
|
|
(and works properly) with http://www.ayera.com/teraterm/[TeraTerm] under Windows and with _screen_ in Linux. Other
|
|
terminal emulators might not work equally as well.
|
|
|
|
// $$FOOTER$$
|