Работа над viewport формы, добавление описания для поля формы, комментарии к fileSelect модели
This commit is contained in:
parent
ecc89e34c5
commit
c7ff7662ba
9 changed files with 333 additions and 207 deletions
|
|
@ -7,14 +7,15 @@ import (
|
|||
)
|
||||
|
||||
type SelectModel struct {
|
||||
label string
|
||||
options []string
|
||||
focus int
|
||||
open bool
|
||||
chosen string
|
||||
label string
|
||||
description string
|
||||
options []string
|
||||
focus int
|
||||
open bool
|
||||
chosen string
|
||||
}
|
||||
|
||||
func NewSelectModel(label, value string, options []string) *SelectModel {
|
||||
func NewSelectModel(label, value, description string, options []string) *SelectModel {
|
||||
found := false
|
||||
for i := range options {
|
||||
if options[i] == value {
|
||||
|
|
@ -25,10 +26,11 @@ func NewSelectModel(label, value string, options []string) *SelectModel {
|
|||
value = ""
|
||||
}
|
||||
return &SelectModel{
|
||||
options: options,
|
||||
label: label,
|
||||
focus: len(options),
|
||||
chosen: value,
|
||||
options: options,
|
||||
label: label,
|
||||
description: description,
|
||||
focus: len(options),
|
||||
chosen: value,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -85,6 +87,9 @@ func (m *SelectModel) Update(msg tea.Msg) (FieldModel, tea.Cmd) {
|
|||
|
||||
func (m *SelectModel) View() string {
|
||||
res := fmt.Sprintf("%s: %s", m.label, m.chosen)
|
||||
if m.description != "" {
|
||||
res += fmt.Sprintf("\n%s", m.description)
|
||||
}
|
||||
if m.open && len(m.options) > 0 {
|
||||
for i := range m.options {
|
||||
if m.focus == i {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue