Compare commits
2 Commits
4d863c6ff1
...
8b3ccc8e4b
Author | SHA1 | Date | |
---|---|---|---|
8b3ccc8e4b | |||
f9af8fb9ef |
@ -1,7 +1,7 @@
|
|||||||
local serial = require "serialization"
|
local serial = require "serialization"
|
||||||
local event = require "event"
|
|
||||||
local fs = require "filesystem"
|
|
||||||
local unicode = require "unicode"
|
local unicode = require "unicode"
|
||||||
|
local fs = require "filesystem"
|
||||||
|
local event = require "event"
|
||||||
|
|
||||||
local tArgs = {...}
|
local tArgs = {...}
|
||||||
local ipackages = {} -- installed packages
|
local ipackages = {} -- installed packages
|
||||||
@ -49,6 +49,10 @@ end
|
|||||||
|
|
||||||
function info(pkg) -- shows info for pkg
|
function info(pkg) -- shows info for pkg
|
||||||
clear()
|
clear()
|
||||||
|
local fh = io.popen("less","w")
|
||||||
|
local function print(str)
|
||||||
|
fh:write(str.."\n")
|
||||||
|
end
|
||||||
print(string.format("%s - %s",pkg,packages[pkg].name))
|
print(string.format("%s - %s",pkg,packages[pkg].name))
|
||||||
print(packages[pkg].description)
|
print(packages[pkg].description)
|
||||||
if packages[pkg].files then
|
if packages[pkg].files then
|
||||||
@ -63,6 +67,7 @@ function info(pkg) -- shows info for pkg
|
|||||||
print(" - "..k)
|
print(" - "..k)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
fh:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
local preamble = false
|
local preamble = false
|
||||||
@ -82,14 +87,25 @@ if preamble then -- display pre-inst screen
|
|||||||
event.pull("key_down")
|
event.pull("key_down")
|
||||||
end
|
end
|
||||||
|
|
||||||
local selected = 1
|
local mx, my = require("term").getViewport()
|
||||||
|
local selected, start = 1, 1
|
||||||
|
|
||||||
local function drawmenu() -- draw the menu display - nothing but text and VT100 escape codes
|
local function drawmenu() -- draw the menu display - nothing but text and VT100 escape codes
|
||||||
|
local infostring = string.format("[%s][%s]%s", unicode.char(0x2191), unicode.char(0x2193), " Move [Space] (De)select [i] More Info [q] Quit [Enter] Confirm")
|
||||||
clear()
|
clear()
|
||||||
|
io.write(string.format("\27[%d;1H%s\27[H",my,infostring))
|
||||||
|
local workingSpace = my - math.ceil(infostring:len() / mx) - 1
|
||||||
if install.label then
|
if install.label then
|
||||||
print(install.label .. " installer")
|
print(install.label .. " installer")
|
||||||
|
workingSpace = workingSpace - 1
|
||||||
end
|
end
|
||||||
for k,v in pairs(pkgmap) do
|
if selected > start + workingSpace - 3 then
|
||||||
|
start = math.min(start + 3, #pkgmap - workingSpace)
|
||||||
|
elseif selected < start + 3 then
|
||||||
|
start = math.max(start - 3, 1)
|
||||||
|
end
|
||||||
|
for k = start, math.min(#pkgmap,start+workingSpace) do
|
||||||
|
local v = pkgmap[k]
|
||||||
if k == selected then
|
if k == selected then
|
||||||
io.write("\27[30;47m")
|
io.write("\27[30;47m")
|
||||||
end
|
end
|
||||||
@ -101,7 +117,6 @@ local function drawmenu() -- draw the menu display - nothing but text and VT100
|
|||||||
io.write(v)
|
io.write(v)
|
||||||
print("\27[0m")
|
print("\27[0m")
|
||||||
end
|
end
|
||||||
print("Use the arrow keys to navigate. (De)select options with space. View more info by pressing i, and quit by pressing q. Confirm with enter.")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@ -126,8 +141,6 @@ while run do -- menu loop
|
|||||||
install = false
|
install = false
|
||||||
elseif ch == 105 and co == 23 then
|
elseif ch == 105 and co == 23 then
|
||||||
info(pkgmap[selected])
|
info(pkgmap[selected])
|
||||||
print("\nPress any key to return to the menu.")
|
|
||||||
event.pull("key_down")
|
|
||||||
elseif ch == 0 and co == 208 then
|
elseif ch == 0 and co == 208 then
|
||||||
selected = selected + 1
|
selected = selected + 1
|
||||||
if selected > #pkgmap then
|
if selected > #pkgmap then
|
||||||
|
Loading…
Reference in New Issue
Block a user