-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinputLayout.go
More file actions
37 lines (28 loc) · 1.4 KB
/
inputLayout.go
File metadata and controls
37 lines (28 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package devtui
import (
"github.com/charmbracelet/lipgloss"
"github.com/tinywasm/fmt"
)
// calculateInputWidths calculates the width available for text input based on viewport and other elements
// Returns valueWidth (total width for the input area) and availableTextWidth (width for the text itself)
func (h *DevTUI) calculateInputWidths(fieldLabel string) (valueWidth, availableTextWidth int) {
horizontalPadding := 1
// Process label (same logic as footerInput.go)
labelText := fmt.Convert(fieldLabel).Truncate(h.labelWidth, 0).String()
fixedWidthLabel := h.labelStyle.Render(labelText)
paddedLabel := h.headerTitleStyle.Render(fixedWidthLabel)
// Calculate other components (All elements in footer)
infoWidth := lipgloss.Width(h.renderScrollInfo())
// Force fixed width for alignment (matching footerInput.go)
fieldPagination := lipgloss.NewStyle().Width(PaginationColumnWidth).Align(lipgloss.Center).Render(" 1/ 1")
paginationWidth := lipgloss.Width(h.paginationStyle.Render(fieldPagination))
// Layout: pagination|space|label|space|value|space|scroll
usedWidth := infoWidth + lipgloss.Width(paddedLabel) + paginationWidth + horizontalPadding*3
// Calculate final widths
valueWidth = h.viewport.Width - usedWidth
if valueWidth < 10 {
valueWidth = 10 // Mínimo
}
availableTextWidth = valueWidth - (horizontalPadding * 2)
return valueWidth, availableTextWidth
}