Работа над viewport формы, добавление описания для поля формы, комментарии к fileSelect модели

This commit is contained in:
XeRo 2026-01-19 17:44:49 +05:00
parent ecc89e34c5
commit c7ff7662ba
9 changed files with 333 additions and 207 deletions

View file

@ -14,6 +14,7 @@ import (
type DirSelectModel struct {
input textinput.Model
label string
description string
focus int
open bool
dir string
@ -22,16 +23,17 @@ type DirSelectModel struct {
optionsCount int
}
func NewDirSelectModel(label, dir string) *DirSelectModel {
func NewDirSelectModel(label, dir, description string) *DirSelectModel {
inputModel := textinput.New()
inputModel.SetValue(dir)
return &DirSelectModel{
input: inputModel,
label: label,
description: description,
currentDirectory: filepath.Dir(dir),
open: false,
dir: dir,
optionsCount: 3,
optionsCount: 10,
}
}
@ -124,6 +126,9 @@ func (m *DirSelectModel) Update(msg tea.Msg) (FieldModel, tea.Cmd) {
func (m *DirSelectModel) View() string {
res := fmt.Sprintf("%s: %s", m.label, m.input.View())
if m.description != "" {
res += fmt.Sprintf("\n%s", m.description)
}
if m.open && len(m.options) > 0 {
visibleCount := m.optionsCount
if visibleCount > len(m.options) {