From 7032659d072211e80f1ee60ff16be65787c53f72 Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Sun, 13 Jul 2025 21:12:21 -0700 Subject: [PATCH] update size based on screen --- internal/app/app.go | 20 ++++++++++++++++---- internal/app/row_detail.go | 11 +++++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/internal/app/app.go b/internal/app/app.go index ea38725..95af2b8 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -588,11 +588,23 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.width = msg.Width m.height = msg.Height // Update current view with new dimensions - if tableList, ok := m.currentView.(*TableListModel); ok { - tableList.Shared.Width = m.width - tableList.Shared.Height = m.height + switch v := m.currentView.(type) { + case *TableListModel: + v.Shared.Width = m.width + v.Shared.Height = m.height + case *TableDataModel: + v.Shared.Width = m.width + v.Shared.Height = m.height + case *RowDetailModel: + v.Shared.Width = m.width + v.Shared.Height = m.height + case *EditCellModel: + v.Shared.Width = m.width + v.Shared.Height = m.height + case *QueryModel: + v.Shared.Width = m.width + v.Shared.Height = m.height } - // Add similar updates for other model types as needed case tea.KeyMsg: switch { diff --git a/internal/app/row_detail.go b/internal/app/row_detail.go index 556ad02..92a5292 100644 --- a/internal/app/row_detail.go +++ b/internal/app/row_detail.go @@ -165,9 +165,16 @@ func (m *RowDetailModel) View() string { } value := row[i] - if len(value) > 50 { + // Calculate available width for value display + // Account for column name, ": ", and indentation + availableWidth := m.Shared.Width - len(col) - 4 // 4 for ": " and "> " prefix + if availableWidth < 20 { + availableWidth = 20 // Minimum width + } + + if len(value) > availableWidth { // Wrap long values - lines := WrapText(value, 50) + lines := WrapText(value, availableWidth) value = strings.Join(lines, "\n ") }