summaryrefslogtreecommitdiffstatshomepage
path: root/plugins/console/init.lua
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2023-03-07 05:33:37 +1100
committer Vas Crabb <vas@vastheman.com>2023-03-07 05:33:37 +1100
commit8384223ac82670d39e1f40834dc4375f43c02a94 (patch)
tree1c2f43c825753e82f323b710bcbe226c0864de58 /plugins/console/init.lua
parente9ecdc9a6eb5b1cced5423cac2bde6fa8b20f5b7 (diff)
Updated forked linenoise to latest upstream.
This removes the need to force it to build as C++, and adds proper UTF-8 support for Windows. Since this is a fork of linenoise, there's no hope for getting lua-linenoise to sync with it upstream. I made the bare minimum changes to keep it working, but didn't add bindings for new functionality (e.g. multi-line editing).
Diffstat (limited to 'plugins/console/init.lua')
-rw-r--r--plugins/console/init.lua20
1 files changed, 5 insertions, 15 deletions
diff --git a/plugins/console/init.lua b/plugins/console/init.lua
index 1b40ac50bee..3e10e17bc14 100644
--- a/plugins/console/init.lua
+++ b/plugins/console/init.lua
@@ -23,16 +23,6 @@ function console.startplugin()
local matches = {}
local lastindex = 0
local consolebuf
- _G.history = function (index)
- local history = ln.historyget()
- if index then
- ln.preload(history[index])
- return
- end
- for num, line in ipairs(history) do
- print(num, line)
- end
- end
print(" /| /| /| /| /| _______")
print(" / | / | / | / | / | / /")
print(" / |/ | / | / |/ | / ____/ ")
@@ -51,11 +41,11 @@ function console.startplugin()
ln.historysetmaxlen(50)
local scr = [[
local ln = require('linenoise')
- ln.setcompletion(function(c, str, pos)
- status = str .. "\x01" .. tostring(pos)
+ ln.setcompletion(
+ function(c, str)
yield()
- ln.addcompletion(c, status:match("([^\x01]*)\x01(.*)"))
- end)
+ ln.addcompletion(c, str)
+ end)
local ret = ln.linenoise('$PROMPT')
if ret == nil then
return "\n"
@@ -256,7 +246,7 @@ function console.startplugin()
lastindex = lastindex + 1
print(consolebuf[lastindex])
end
- ln.refresh()
+ -- ln.refresh() FIXME: how to replicate this now that the API has been removed?
end
if conth.yield then
conth:continue(get_completions(conth.result:match("([^\x01]*)\x01(.*)")))