mirror of
https://github.com/kepler155c/opus
synced 2025-01-16 18:32:52 +00:00
scrolling term
This commit is contained in:
parent
d769b35672
commit
2d411df7d1
@ -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
|
||||
|
@ -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 = {
|
||||
|
22
sys/autorun/complete.lua
Normal file
22
sys/autorun/complete.lua
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user