GoSetup-bubble/setup/fields/compute.go

55 lines
914 B
Go
Raw Normal View History

2025-12-26 17:45:37 +05:00
package fields
import (
"fmt"
tea "github.com/charmbracelet/bubbletea"
)
type ComputeModel struct {
Label string
description string
value string
2025-12-26 17:45:37 +05:00
}
func NewComputeModel(label, value, description string) *ComputeModel {
2025-12-26 17:45:37 +05:00
return &ComputeModel{
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 {
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
}