diff --git a/sys/apis/terminal.lua b/sys/apis/terminal.lua index 5755d52..bfac681 100644 --- a/sys/apis/terminal.lua +++ b/sys/apis/terminal.lua @@ -63,15 +63,15 @@ function Terminal.window(parent, sx, sy, w, h, isVisible) function win.clear() canvas.offy = 0 - canvas:clear(bg, fg) for i = #canvas.lines, canvas.height + 1, -1 do canvas.lines[i] = nil end + canvas:clear(bg, fg) update() end function win.clearLine() - canvas:clearLine(cy, bg, fg) + canvas:clearLine(cy + canvas.offy, bg, fg) win.setCursorPos(cx, cy) update() end @@ -127,15 +127,15 @@ function Terminal.window(parent, sx, sy, w, h, isVisible) function win.scroll(n) n = n or 1 if n > 0 then - for _ = 1, n do - canvas.lines[#canvas.lines + 1] = { } - canvas:clearLine(#canvas.lines, bg, fg) + local lines = #canvas.lines + for i = 1, n do + canvas.lines[lines + i] = { } + canvas:clearLine(lines + i, bg, fg) end while #canvas.lines > maxScroll do table.remove(canvas.lines, 1) end - scrollTo(#canvas.lines - canvas.height) - canvas.offy = #canvas.lines - canvas.height + scrollTo(#canvas.lines) canvas:dirty() update() end diff --git a/sys/apps/shell b/sys/apps/shell index e1010fb..d9da2e2 100644 --- a/sys/apps/shell +++ b/sys/apps/shell @@ -371,10 +371,10 @@ local oldTerm local terminal = term.current() if not terminal.scrollUp then --- local Terminal = require('terminal') --- terminal = Terminal.window(term.current()) --- terminal.setMaxScroll(200) --- oldTerm = term.redirect(terminal) + local Terminal = require('terminal') + terminal = Terminal.window(term.current()) + terminal.setMaxScroll(200) + oldTerm = term.redirect(terminal) end local config = { diff --git a/sys/autorun/complete.lua b/sys/autorun/complete.lua new file mode 100644 index 0000000..332c8a3 --- /dev/null +++ b/sys/autorun/complete.lua @@ -0,0 +1,22 @@ +local function completeMultipleChoice(sText, tOptions, bAddSpaces) + local tResults = { } + for n = 1,#tOptions do + local sOption = tOptions[n] + if #sOption + (bAddSpaces and 1 or 0) > #sText and string.sub(sOption, 1, #sText) == sText then + local sResult = string.sub(sOption, #sText + 1) + if bAddSpaces then + table.insert(tResults, sResult .. " ") + else + table.insert(tResults, sResult) + end + end + end + return tResults +end + +_ENV.shell.setCompletionFunction("sys/apps/package.lua", + function(_, index, text) + if index == 1 then + return completeMultipleChoice(text, { "install ", "update ", "uninstall " }) + end + end)