1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-23 19:57:39 +00:00

ui improvements

This commit is contained in:
kepler155c@gmail.com
2017-10-03 00:50:54 -04:00
parent c0baa00668
commit 8e381d3ebf
10 changed files with 393 additions and 228 deletions

View File

@@ -489,17 +489,18 @@ local function autocomplete(line, suggestions)
end
end
local function shellRead(_tHistory )
local function shellRead(history)
term.setCursorBlink( true )
local sLine = ""
local nHistoryPos
local nPos = 0
local lastPattern
local w = term.getSize()
local sx = term.getCursorPos()
history:reset()
local function redraw( sReplace )
local nScroll = 0
if sx + nPos >= w then
@@ -563,32 +564,19 @@ local function shellRead(_tHistory )
redraw()
end
elseif param == keys.up or param == keys.down then
if _tHistory then
redraw(" ")
if param == keys.up then
if nHistoryPos == nil then
if #_tHistory > 0 then
nHistoryPos = #_tHistory
end
elseif nHistoryPos > 1 then
nHistoryPos = nHistoryPos - 1
end
else
if nHistoryPos == #_tHistory then
nHistoryPos = nil
elseif nHistoryPos ~= nil then
nHistoryPos = nHistoryPos + 1
end
end
if nHistoryPos then
sLine = _tHistory[nHistoryPos]
nPos = string.len( sLine )
else
sLine = ""
nPos = 0
end
redraw()
redraw(" ")
if param == keys.up then
sLine = history:back()
else
sLine = history:forward()
end
if sLine then
nPos = string.len(sLine)
else
sLine = ""
nPos = 0
end
redraw()
elseif param == keys.backspace then
if nPos > 0 then
redraw(" ")
@@ -637,13 +625,13 @@ while not bExit do
write("$ " )
term.setTextColour(_colors.commandTextColor)
term.setBackgroundColor(colors.black)
local sLine = shellRead(history.entries)
local sLine = shellRead(history)
if bExit then -- terminated
break
end
sLine = Util.trim(sLine)
if #sLine > 0 and sLine ~= 'exit' then
history.add(sLine)
history:add(sLine)
end
term.setTextColour(_colors.textColor)
if #sLine > 0 then