Добавление и исправление комментариев, начало добавление валидации, сообщение прокрути viewport на форме
This commit is contained in:
parent
c7ff7662ba
commit
e37cabadcc
14 changed files with 371 additions and 297 deletions
|
|
@ -5,15 +5,17 @@ import (
|
|||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
|
||||
// ComputeModel структура описывающая модель вывода вычисляемых значений
|
||||
type ComputeModel struct {
|
||||
Label string
|
||||
description string
|
||||
value string
|
||||
label string //Имя поля
|
||||
description string //Описание поля
|
||||
value string //Значение поля
|
||||
}
|
||||
|
||||
// NewComputeModel создаем новую модель вывода вычисляемых значений
|
||||
func NewComputeModel(label, value, description string) *ComputeModel {
|
||||
return &ComputeModel{
|
||||
Label: label,
|
||||
label: label,
|
||||
description: description,
|
||||
value: value,
|
||||
}
|
||||
|
|
@ -23,12 +25,13 @@ func (m *ComputeModel) Init() tea.Cmd {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Update отслеживает действия с полем. Так как поле нужно только для вывода, никаких действий не выполняем.
|
||||
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)
|
||||
res := fmt.Sprintf("%s: %s", m.label, m.value)
|
||||
if m.description != "" {
|
||||
res += fmt.Sprintf("\n%s", m.description)
|
||||
}
|
||||
|
|
@ -46,7 +49,7 @@ func (m *ComputeModel) CaptureKeys() bool {
|
|||
}
|
||||
|
||||
func (m *ComputeModel) GetLabel() string {
|
||||
return m.Label
|
||||
return m.label
|
||||
}
|
||||
|
||||
func (m *ComputeModel) GetValue() interface{} {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue