commit - 9192f9e6bc31960f2056c2d174b5f447246617bf
commit + 095f1cbe955bbb38c49fc5c9e195a1fe1783773d
blob - 94d6649fac47a28aff2989f0eb08a42bfc495535
blob + 1299751ba0bb185628edcb3c9f6ed5ba77854e49
--- aestel/display.lua
+++ aestel/display.lua
return TYPE_COLORS[item_type] or colors.WHITE
end
+-- Write a header block at the top of the terminal:
+-- line 1: bold title (or omitted if title is empty)
+-- line 2: "Current Path: <cwd>"
+-- line 3: blank separator (only when title is present)
+-- Returns the number of lines written, for callers to position
+-- a menu immediately below the header.
+function M.write_header(title, cwd)
+ M.clear_and_position(1, 1)
+ local lines = 0
+ if title and title ~= "" then
+ io.write(colors.BOLD .. title .. colors.RESET .. "\n")
+ lines = lines + 1
+ end
+ io.write("Current Path: " .. (cwd or "") .. "\n")
+ lines = lines + 1
+ if title and title ~= "" then
+ io.write("\n")
+ lines = lines + 1
+ end
+ io.flush()
+ return lines
+end
+
return M
blob - d19e4d35a47d917ab3ddcfaca8f32c88beab67c2
blob + 19e7bb342806b143f3703a356c106db4ae0cd171
--- aestel/menu.lua
+++ aestel/menu.lua
-- Display a key-navigated menu and return the selected index
-- (1-based, 0 for "up", or nil (quit))
-function M.menu(title, options, start_row, header_lines)
+function M.menu(title, options, start_row, header_lines, empty_message)
if not options or #options == 0 then
+ if empty_message then
+ start_row = start_row or 1
+ local terminal_height = input.get_terminal_height()
+ input.enable_raw()
+
+ -- Write the empty message on the last terminal line
+ io.write(string.format("\27[%d;1H\27[K", terminal_height))
+ io.write(colors.REVERSE .. empty_message .. colors.RESET)
+ io.flush()
+
+ local key = read_key_full()
+ input.disable_raw()
+
+ if key == "h" or key == "left" then
+ return 0 -- Signal "go up"
+ end
+ return nil -- Quit
+ end
return nil
end
blob - 1411ce481537f6985960169eaa58eb33fd347748
blob + 894793b05cbb9fca0d8a49e212031dbecb680f58
--- aestel/navigate.lua
+++ aestel/navigate.lua
return new_path
end
--- UPDATED refresh_headers: Debug print for title/cwd; simplified title, extra flushes
-local function refresh_headers(title, cwd, start_row)
- display.clear_and_position(1, 1)
- title = title or "" -- Ensure string
--- io.stderr:write("DEBUG refresh: title='" .. title .. "', cwd='" .. cwd .. "'\n")
- io.stderr:flush()
- if title ~= "" then
- io.write(colors.BOLD .. title .. colors.RESET .. "\n")
- io.flush()
- end
- io.write("Current Path: " .. cwd .. "\n")
- io.flush()
- if title ~= "" then
- io.write("\n") -- Empty line for title case
- io.flush()
- end
-end
-
-- handle_empty_dir (unchanged)
local function handle_empty_dir(title, cwd, base_dir)
- refresh_headers(title, cwd, nil)
+ display.write_header(title, cwd)
local height = input.get_terminal_height()
io.write(string.format("\27[%d;1H\27[K", height))
io.write("Empty directory. Press 'q' to quit or 'h' to go up.\n")
local cwd = normalize_path(start_dir or lfs.currentdir() or home_dir)
local header_lines = title ~= "" and 3 or 1
- refresh_headers(title, cwd, nil)
+ display.write_header(title, cwd)
local running = true
local selected_file = nil
local empty_result = handle_empty_dir(title, cwd, base_dir)
if type(empty_result) == "string" then
cwd = empty_result
- refresh_headers(title, cwd, nil)
+ display.write_header(title, cwd)
else
running = false
end
local new_cwd, err = change_dir(cwd, "..", base_dir)
if new_cwd then
cwd = new_cwd
- refresh_headers(title, cwd, nil)
+ display.write_header(title, cwd)
else
- refresh_headers(title, cwd, nil)
+ display.write_header(title, cwd)
local height = input.get_terminal_height()
io.write(string.format("\27[%d;1H\27[K", height))
io.write("Error: " .. (err or "unknown") .. "\n")
local new_cwd, err = change_dir(cwd, sel.name, base_dir)
if new_cwd then
cwd = new_cwd
- refresh_headers(title, cwd, nil)
+ display.write_header(title, cwd)
else
- refresh_headers(title, cwd, nil)
+ display.write_header(title, cwd)
local height = input.get_terminal_height()
io.write(string.format("\27[%d;1H\27[K", height))
io.write("Error: " .. (err or "unknown") .. "\n")