Documentation
¶
Overview ¶
Package ui is the interactive terminal UI behind `apic ui`: a request list on the left, a tabbed detail pane on the right, and a status bar. The model is driven entirely by messages and renders to a string, so tests call Update and View directly and need no terminal; program.go is the only part that touches one.
Index ¶
- func Run(ctx context.Context, m *Model, in *os.File, out io.Writer) error
- type Cmd
- type Config
- type Key
- type KeyType
- type Model
- func (m *Model) Env() string
- func (m *Model) Live() bool
- func (m *Model) Press(name string)
- func (m *Model) PressAll(keys string)
- func (m *Model) PressWatch(name string, each func())
- func (m *Model) Resize(width, height int)
- func (m *Model) Result(req *httpfile.Request) *runner.Result
- func (m *Model) Running() bool
- func (m *Model) Selected() *httpfile.Request
- func (m *Model) Status() string
- func (m *Model) Update(msg Msg) Cmd
- func (m *Model) View() string
- type Msg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Root string // project root shown in the status bar
Env string // initial environment
Runner *runner.Runner // initial runner
NewRunner func(env string) (*runner.Runner, error) // rebuilds the runner on env change or reload
Editor string // command for the o key; empty disables it
Redact bool // --redact
Demo bool // shows a demo badge in the status bar
Theme output.Theme
}
Config is everything the CLI hands the UI; tests build it directly.
type Key ¶
Key is one decoded keypress.
type KeyType ¶
type KeyType int
KeyType names the keys the UI reacts to. Anything printable arrives as KeyRune with the rune set.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the whole UI state.
func (*Model) Live ¶ added in v0.1.4
Live reports whether the screen changes on its own: a run is in flight, or the pane counts a token's expiry down. The program ticks only then.
func (*Model) Press ¶
Press feeds one key and settles everything it starts, so a run sent by enter has landed by the time Press returns.
func (*Model) PressAll ¶
PressAll presses several keys in order, splitting a space-separated list for brevity: "j enter 3".
func (*Model) PressWatch ¶
PressWatch is Press with a callback after every piece of background work the key started has landed: for `f`, once per request of the flow, so a caller can capture the screen as rows light up one by one. The callback also runs once at the end, after the last message.
func (*Model) Resize ¶
Resize tells the model how big the terminal is. The program loop does this from the real terminal; callers without one say so themselves.