2025-12-26 17:45:37 +05:00
|
|
|
package fields
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
tea "github.com/charmbracelet/bubbletea"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ComputeModel struct {
|
2026-01-19 17:44:49 +05:00
|
|
|
Label string
|
|
|
|
|
description string
|
|
|
|
|
value string
|
2025-12-26 17:45:37 +05:00
|
|
|
}
|
|
|
|
|
|
2026-01-19 17:44:49 +05:00
|
|
|
func NewComputeModel(label, value, description string) *ComputeModel {
|
2025-12-26 17:45:37 +05:00
|
|
|
return &ComputeModel{
|
2026-01-19 17:44:49 +05:00
|
|
|
Label: label,
|
|
|
|
|
description: description,
|
|
|
|
|
value: value,
|
2025-12-26 17:45:37 +05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ComputeModel) Init() tea.Cmd {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ComputeModel) Update(msg tea.Msg) (FieldModel, tea.Cmd) {
|
|
|
|
|
return m, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ComputeModel) View() string {
|
2026-01-19 17:44:49 +05:00
|
|
|
res := fmt.Sprintf("%s: %s", m.Label, m.value)
|
|
|
|
|
if m.description != "" {
|
|
|
|
|
res += fmt.Sprintf("\n%s", m.description)
|
|
|
|
|
}
|
|
|
|
|
return res
|
2025-12-26 17:45:37 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ComputeModel) Focus() {}
|
|
|
|
|
|
|
|
|
|
func (m *ComputeModel) Blur() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ComputeModel) CaptureKeys() bool {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ComputeModel) GetLabel() string {
|
|
|
|
|
return m.Label
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *ComputeModel) GetValue() interface{} {
|
|
|
|
|
return m.value
|
|
|
|
|
}
|