mirror of
https://github.com/kepler155c/opus
synced 2025-01-29 08:34:46 +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()
|
function win.clear()
|
||||||
canvas.offy = 0
|
canvas.offy = 0
|
||||||
canvas:clear(bg, fg)
|
|
||||||
for i = #canvas.lines, canvas.height + 1, -1 do
|
for i = #canvas.lines, canvas.height + 1, -1 do
|
||||||
canvas.lines[i] = nil
|
canvas.lines[i] = nil
|
||||||
end
|
end
|
||||||
|
canvas:clear(bg, fg)
|
||||||
update()
|
update()
|
||||||
end
|
end
|
||||||
|
|
||||||
function win.clearLine()
|
function win.clearLine()
|
||||||
canvas:clearLine(cy, bg, fg)
|
canvas:clearLine(cy + canvas.offy, bg, fg)
|
||||||
win.setCursorPos(cx, cy)
|
win.setCursorPos(cx, cy)
|
||||||
update()
|
update()
|
||||||
end
|
end
|
||||||
@ -127,15 +127,15 @@ function Terminal.window(parent, sx, sy, w, h, isVisible)
|
|||||||
function win.scroll(n)
|
function win.scroll(n)
|
||||||
n = n or 1
|
n = n or 1
|
||||||
if n > 0 then
|
if n > 0 then
|
||||||
for _ = 1, n do
|
local lines = #canvas.lines
|
||||||
canvas.lines[#canvas.lines + 1] = { }
|
for i = 1, n do
|
||||||
canvas:clearLine(#canvas.lines, bg, fg)
|
canvas.lines[lines + i] = { }
|
||||||
|
canvas:clearLine(lines + i, bg, fg)
|
||||||
end
|
end
|
||||||
while #canvas.lines > maxScroll do
|
while #canvas.lines > maxScroll do
|
||||||
table.remove(canvas.lines, 1)
|
table.remove(canvas.lines, 1)
|
||||||
end
|
end
|
||||||
scrollTo(#canvas.lines - canvas.height)
|
scrollTo(#canvas.lines)
|
||||||
canvas.offy = #canvas.lines - canvas.height
|
|
||||||
canvas:dirty()
|
canvas:dirty()
|
||||||
update()
|
update()
|
||||||
end
|
end
|
||||||
|
@ -371,10 +371,10 @@ local oldTerm
|
|||||||
local terminal = term.current()
|
local terminal = term.current()
|
||||||
|
|
||||||
if not terminal.scrollUp then
|
if not terminal.scrollUp then
|
||||||
-- local Terminal = require('terminal')
|
local Terminal = require('terminal')
|
||||||
-- terminal = Terminal.window(term.current())
|
terminal = Terminal.window(term.current())
|
||||||
-- terminal.setMaxScroll(200)
|
terminal.setMaxScroll(200)
|
||||||
-- oldTerm = term.redirect(terminal)
|
oldTerm = term.redirect(terminal)
|
||||||
end
|
end
|
||||||
|
|
||||||
local config = {
|
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