Skip to content

Commit 80c2663

Browse files
committed
feat: add dynamic page size based on terminal height for stats and log views
1 parent 0e77f34 commit 80c2663

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

src/views/log.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,21 @@ func UpdateLogContent(m *models.Model) {
264264
table.NewColumn("time", "Time", timeWidth),
265265
}
266266

267-
// Create table with custom styles - fixed page size for scrolling
267+
// Calculate page size based on available height
268+
// Reserve space for: header row (3 lines with borders), help bar (1 line), and padding
269+
pageSize := m.Height - 5
270+
if pageSize < 5 {
271+
pageSize = 5 // minimum page size
272+
}
273+
274+
// Create table with custom styles - dynamic page size based on terminal height
268275
m.LogTable = table.New(columns).
269276
WithRows(rows).
270277
Focused(true).
271278
Border(styles.TableBorder).
272279
HeaderStyle(styles.TableHeaderStyle).
273280
WithBaseStyle(styles.TableBaseStyle).
274-
WithPageSize(20).
281+
WithPageSize(pageSize).
275282
WithFooterVisibility(false)
276283

277284
// Just update the table - don't store anything in viewport

src/views/stats.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,21 @@ func UpdateStatsContent(m *models.Model) {
9494
table.NewColumn("removed", "Removed", removedWidth).WithStyle(lipgloss.NewStyle().Align(lipgloss.Right).Foreground(lipgloss.Color("9"))),
9595
}
9696

97-
// Create table with custom styles - fixed page size for scrolling
97+
// Calculate page size based on available height
98+
// Reserve space for: header row (3 lines with borders), help bar (1 line), and padding
99+
pageSize := m.Height - 5
100+
if pageSize < 5 {
101+
pageSize = 5 // minimum page size
102+
}
103+
104+
// Create table with custom styles - dynamic page size based on terminal height
98105
m.StatsTable = table.New(columns).
99106
WithRows(rows).
100107
Focused(true).
101108
Border(styles.TableBorder).
102109
HeaderStyle(styles.TableHeaderStyle).
103110
WithBaseStyle(styles.TableBaseStyle).
104-
WithPageSize(15).
111+
WithPageSize(pageSize).
105112
WithFooterVisibility(false)
106113
}
107114

0 commit comments

Comments
 (0)