mirror of
https://github.com/taigrr/teaqlite.git
synced 2026-04-02 04:59:03 -07:00
update size based on screen
This commit is contained in:
@@ -588,11 +588,23 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
m.width = msg.Width
|
m.width = msg.Width
|
||||||
m.height = msg.Height
|
m.height = msg.Height
|
||||||
// Update current view with new dimensions
|
// Update current view with new dimensions
|
||||||
if tableList, ok := m.currentView.(*TableListModel); ok {
|
switch v := m.currentView.(type) {
|
||||||
tableList.Shared.Width = m.width
|
case *TableListModel:
|
||||||
tableList.Shared.Height = m.height
|
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:
|
case tea.KeyMsg:
|
||||||
switch {
|
switch {
|
||||||
|
|||||||
@@ -165,9 +165,16 @@ func (m *RowDetailModel) View() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
value := row[i]
|
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
|
// Wrap long values
|
||||||
lines := WrapText(value, 50)
|
lines := WrapText(value, availableWidth)
|
||||||
value = strings.Join(lines, "\n ")
|
value = strings.Join(lines, "\n ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user