commit - 5b6952961c7f0dfd864f9c70feac701a23296495
commit + 60e1b851d9eaef063c50b64c27f1c1c0ad4efcde
blob - 70e5b5ff52af593eb19b5d1efc50a80aa84ddd44
blob + f784095db59ac6059fdbbbf333c45e8fbe8e77b9
--- aestel/display.lua
+++ aestel/display.lua
-- aestel/display.lua
--- Display helpers for common terminal output patterns
+-- A module for shared terminal output display
local input = require("aestel.input")
local colors = require("aestel.colors")
local M = {}
--- Write a padded message on the last terminal line with optional style
--- style: optional ANSI prefix (e.g., colors.REVERSE for inverse video)
-function M.status_line(message, style)
- local height = input.get_terminal_height()
- local width = input.get_terminal_width()
- local padding = string.rep(" ", math.max(0, width - #message))
- io.stderr:write(string.format("\27[%d;1H\27[K", height))
- io.stderr:write((style or "") .. message .. padding .. colors.RESET)
- io.stderr:flush()
-end
-
--- Clear entire screen and position cursor at (1, 1)
function M.clear_screen()
io.stderr:write("\27[2J\27[1;1H")
io.stderr:flush()
end
--- Position cursor at (row, col) and clear from there
function M.clear_and_position(row, col)
io.stderr:write("\27[2J")
io.stderr:write(string.format("\27[%d;%dH", row or 1, col or 1))
return lines
end
+function M.status_line(message, style)
+ local height = input.get_terminal_height()
+ local width = input.get_terminal_width()
+ local padding = string.rep(" ", math.max(0, width - #message))
+ io.stderr:write(string.format("\27[%d;1H\27[K", height))
+ io.stderr:write((style or "") .. message .. padding .. colors.RESET)
+ io.stderr:flush()
+end
+
function M.status_bar(cwd, selected, total)
local message = " (" .. selected .. "/" .. total .. ") " .. cwd
M.status_line(message, colors.REVERSE)