feat: implement dynamic table sizing based on available terminal space

This commit is contained in:
2025-09-03 09:58:53 +02:00
parent 959c084466
commit 8f2837db78
4 changed files with 125 additions and 12 deletions

View File

@@ -99,21 +99,12 @@ func NewModel(hosts []config.SSHHost, configFile string) Model {
})
}
// Determine table height: 1 (header) + number of hosts (max 10)
hostCount := len(rows)
tableHeight := 1 // header
if hostCount < 10 {
tableHeight += hostCount
} else {
tableHeight += 10
}
// Create the table
// Create the table with initial height (will be updated on first WindowSizeMsg)
t := table.New(
table.WithColumns(columns),
table.WithRows(rows),
table.WithFocused(true),
table.WithHeight(tableHeight),
table.WithHeight(10), // Initial height, will be recalculated dynamically
)
// Style the table
@@ -135,6 +126,9 @@ func NewModel(hosts []config.SSHHost, configFile string) Model {
// Initialize table styles based on initial focus state
m.updateTableStyles()
// The table height will be properly set on the first WindowSizeMsg
// when m.ready becomes true and actual terminal dimensions are known
return m
}