blob: 8b8ba173a42c8b044c73a98a6e4007f62e845507 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
local L = require 'linenoise'
-- L.clearscreen()
print '----- Testing lua-linenoise! ------'
local prompt, history = '? ', 'history.txt'
L.historyload(history) -- load existing history
L.setcompletion(function(c,s)
if s == 'h' then
c:add('help') -- same as L.addcompletion(c,'help)
L.addcompletion(c,'halt') -- same as c:add('halt')
end
end)
L.sethints(function(s)
if s == 'h' then
return ' test hint'
end
end)
L.enableutf8()
local line, err = L.linenoise(prompt)
while line do
if #line > 0 then
print(line:upper())
L.historyadd(line)
L.historysave(history) -- save every new line
end
line, err = L.linenoise(prompt)
end
if err then
print('An error occurred: ' .. err)
end
|