https://github.com/jprjr/lua-lecho
A small lua/luajit module for enabling/disabling terminal echo
https://github.com/jprjr/lua-lecho
Last synced: 3 months ago
JSON representation
A small lua/luajit module for enabling/disabling terminal echo
- Host: GitHub
- URL: https://github.com/jprjr/lua-lecho
- Owner: jprjr
- License: mit
- Created: 2017-03-07T15:43:06.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-07T14:40:24.000Z (almost 8 years ago)
- Last Synced: 2025-01-24T21:13:45.835Z (5 months ago)
- Language: C
- Size: 4.88 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lecho
A small Lua module for enabling/disabling terminal echo
## Usage:
* `local lecho = require'lecho'`
Initializes a new `lecho` object and grabs the
current state of standard input's terminal settings.Object has the following methods:
* `ok = lecho:off()` - turns off terminal echo, returns true if successful
* `ok = lecho:on()` - turns on terminal echo, returns true if successful
* `echo_on = lecho:status()` - returns true if echo is enabled## Example:
```lua
local lecho = require'lecho'if lecho:status() then
print("Terminal echo is on")
else
print("Terminal echo is off - turning on")
if not lecho:on() then
print("Warning - unable to enable terminal echo")
end
endprint("Type some data - this should be visible")
local clear_data = io.read()print("Turning off terminal echo")
if not lecho:off() then
print("Warning - unable to disable terminal echo")
endprint("Type some data - this should be invisible")
local invis_data = io.read()if not lecho:on() then
print("Warning - unable to enable terminal echo")
endprint("Data read: " .. invis_data)
```
## LICENSE
MIT - see file `LICENSE`