1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-10 18:24:14 +00:00
This commit is contained in:
Tw93
2025-11-25 17:25:13 +08:00
parent 2830eb69ca
commit e517bf4a3e
16 changed files with 331 additions and 326 deletions

View File

@@ -14,13 +14,13 @@ _ms_get_terminal_height() {
# Try stty size first (most reliable, real-time)
# Use </dev/tty to ensure we read from terminal even if stdin is redirected
if [[ -t 0 ]] || [[ -t 2 ]]; then
height=$(stty size </dev/tty 2>/dev/null | awk '{print $1}')
height=$(stty size < /dev/tty 2> /dev/null | awk '{print $1}')
fi
# Fallback to tput
if [[ -z "$height" || $height -le 0 ]]; then
if command -v tput > /dev/null 2>&1; then
height=$(tput lines 2>/dev/null || echo "24")
height=$(tput lines 2> /dev/null || echo "24")
else
height=24
fi
@@ -33,7 +33,7 @@ _ms_get_terminal_height() {
_ms_calculate_items_per_page() {
local term_height=$(_ms_get_terminal_height)
# Layout: header(1) + spacing(1) + items + spacing(1) + footer(1) + clear(1) = 5 fixed lines
local reserved=6 # Increased to prevent header from being overwritten
local reserved=6 # Increased to prevent header from being overwritten
local available=$((term_height - reserved))
# Ensure minimum and maximum bounds