From ce81e0a8bd9374b14ebf4cc71326415e85cca8b1 Mon Sep 17 00:00:00 2001 From: Benedikt Ziemons Date: Sun, 2 Jun 2024 17:40:22 +0200 Subject: [PATCH] Add pagination info view --- test.lua | 55 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/test.lua b/test.lua index 0829523..6493e73 100644 --- a/test.lua +++ b/test.lua @@ -17,24 +17,47 @@ local function display() term.setCursorPos(1,1) term.setBackgroundColor(colors.yellow) term.setTextColor(colors.black) - term.clearLine() + local activeTab = tabview.currentTab() + if activeTab ~= nil then + term.clearLine() - term.write(" " .. string.upper(tabview.currentTab().name) .. " ") - term.setCursorPos(tw-8,1) - if currently_working then - term.write(" w ") + term.write(" " .. string.upper(activeTab.name) .. " ") + term.setCursorPos(tw-8,1) + if currently_working then + term.write(" w ") + else + term.write(" R ") + end + term.write(" ^ v ") + + term.setBackgroundColor(colors.black) + term.setTextColor(colors.gray) + 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() + end + term.setTextColor(colors.white) + + for name, tab in pairs(tabview.allTabs()) do + tab.displayTab(tab) + end else - term.write(" R ") - end - term.write(" ^ v ") - - term.setBackgroundColor(colors.black) - term.setTextColor(colors.white) - term.setCursorPos(1,2) - term.clearLine() - - for name, tab in pairs(tabview.allTabs()) do - tab.displayTab(tab) + term.setBackgroundColor(colors.black) + term.clear() + term.setBackgroundColor(colors.yellow) + term.clearLine() + term.write(" NO ACTIVE TAB ") end end