Add pagination info view

This commit is contained in:
Ben 2024-06-02 17:40:22 +02:00
parent 17af6e2304
commit ce81e0a8bd
Signed by: ben
GPG key ID: 0F54A7ED232D3319

View file

@ -17,9 +17,11 @@ local function display()
term.setCursorPos(1,1) term.setCursorPos(1,1)
term.setBackgroundColor(colors.yellow) term.setBackgroundColor(colors.yellow)
term.setTextColor(colors.black) term.setTextColor(colors.black)
local activeTab = tabview.currentTab()
if activeTab ~= nil then
term.clearLine() term.clearLine()
term.write(" " .. string.upper(tabview.currentTab().name) .. " ") term.write(" " .. string.upper(activeTab.name) .. " ")
term.setCursorPos(tw-8,1) term.setCursorPos(tw-8,1)
if currently_working then if currently_working then
term.write(" w ") term.write(" w ")
@ -29,13 +31,34 @@ local function display()
term.write(" ^ v ") term.write(" ^ v ")
term.setBackgroundColor(colors.black) term.setBackgroundColor(colors.black)
term.setTextColor(colors.white) term.setTextColor(colors.gray)
term.setCursorPos(1,2) term.setCursorPos(1,2)
if tabview_window ~= nil then
local tabviewW, tabviewH = tabview_window.getSize()
local estimatedHeight = "?"
if activeTab.estimatedHeight ~= nil then
estimatedHeight = activeTab.estimatedHeight()
end
local paginationInfo = activeTab.scrollPos .. "-" .. tabviewH .. "/" .. estimatedHeight
local padding = winhlp.alignRightPadding(term, #paginationInfo)
term.write(string.format("%" .. padding-1 .. "s", " "))
term.write(paginationInfo)
term.write(" ")
else
term.clearLine() term.clearLine()
end
term.setTextColor(colors.white)
for name, tab in pairs(tabview.allTabs()) do for name, tab in pairs(tabview.allTabs()) do
tab.displayTab(tab) tab.displayTab(tab)
end end
else
term.setBackgroundColor(colors.black)
term.clear()
term.setBackgroundColor(colors.yellow)
term.clearLine()
term.write(" NO ACTIVE TAB ")
end
end end