Documentation
¶
Overview ¶
Package forms provides keys.Action-driven forms and confirm dialogs for viewkit terminal UIs.
Index ¶
- type Confirm
- type Field
- type FieldKind
- type Form
- func (fm *Form) Focused() *Field
- func (fm *Form) Handle(a keys.Action) bool
- func (fm *Form) Insert(s string)
- func (fm *Form) Overlay(bg string, f layout.Frame, title string, pos ...layout.OverlayPos) string
- func (fm *Form) Render(f layout.Frame, title string) string
- func (fm *Form) Values() map[string]any
- type Result
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶
type Form ¶
type Form struct {
Fields []Field
// contains filtered or unexported fields
}
Example ¶
package main
import (
"github.com/codyconfer/viewkit/forms"
"github.com/codyconfer/viewkit/keys"
"github.com/codyconfer/viewkit/layout"
)
func main() {
fm := forms.NewForm(
forms.Field{Key: "name", Label: "Name", Kind: forms.FieldText},
forms.Field{
Key: "risk",
Label: "Risk",
Kind: forms.FieldSelect,
Options: []string{"low", "med", "high"},
},
forms.Field{Key: "auto", Label: "Auto", Kind: forms.FieldToggle},
)
fm.Insert("example")
fm.Handle(keys.Down)
fm.Handle(keys.Right)
fm.Handle(keys.Down)
fm.Handle(keys.Confirm)
_ = fm.Values()
_ = fm.Render(layout.NewFrame(60), "SETTINGS")
}
Output:
Click to show internal directories.
Click to hide internal directories.