Documentation
¶
Overview ¶
Package tui is the terminal view of the daemon: the task views of its tasks, the plugins' views of their units and the workflows' plan, with the keys of #keys.
Index ¶
- Constants
- Variables
- func Matches(r api.Row, query, kindLabel string, extra ...string) bool
- func Run(ctx context.Context, cfg Config) error
- type Command
- type Config
- type Daemon
- type Decoder
- type EditRequest
- type Editor
- type Key
- type Model
- func (m *Model) Done(c Command, lines []string, err error)
- func (m *Model) Edited(e *EditRequest, text string, err error) (Command, bool)
- func (m *Model) FilterTerms() []string
- func (m *Model) Key(k Key) (c Command, ok bool)
- func (m *Model) Quit() bool
- func (m *Model) Refetch() (Command, bool)
- func (m *Model) Render(width, height int, now time.Time) []string
- func (m *Model) SetCatalog(c api.CatalogResponse)
- func (m *Model) SetClosed(closed []api.ClosedSession)
- func (m *Model) SetColor(on bool)
- func (m *Model) SetCounters(c api.Counters)
- func (m *Model) SetData(rows []api.Row, h api.Health)
- func (m *Model) SetDetail(id string, e api.TaskView, err error)
- func (m *Model) SetDrafts(id string, ds []api.Draft)
- func (m *Model) SetError(err error)
- func (m *Model) SetFilteredCounters(area string, c api.Counters)
- func (m *Model) SetGates(gs []api.GateView)
- func (m *Model) SetKeys(b []api.KeyView)
- func (m *Model) SetLoading(ls []api.Loading)
- func (m *Model) SetPlan(items []api.PlanItem, err error)
- func (m *Model) SetPlanSpecs(specs []api.ActionSpec)
- func (m *Model) SetPlugins(ps []api.Plugin)
- func (m *Model) SetReview(r api.Review)
- func (m *Model) SetSpecs(specs []api.ActionSpec)
- func (m *Model) SetTasks(view string, tasks []api.TaskView, c api.Counters)
- func (m *Model) SetViews(c api.ViewsCatalog)
- func (m *Model) Stay(why string)
- func (m *Model) TakeEdit() *EditRequest
- func (m *Model) TaskQuery() (view, area string, ok bool)
- type Suspender
- type TTY
- type Terminal
- type View
Constants ¶
const ( KeyUp = "up" KeyDown = "down" KeyEnter = "enter" KeyEsc = "esc" KeyBackspace = "backspace" KeyTab = "tab" KeyCtrlC = "ctrl-c" KeyCtrlZ = "ctrl-z" KeyCtrlK = "ctrl-k" KeyCtrlE = "ctrl-e" KeyPaste = "paste" )
const Source = string(turn.TUI)
Source is what every request of the TUI names, an answer included.
Variables ¶
var ErrNotTerminal = errors.New(brand.Command + " tui needs a terminal on stdin and stdout")
Functions ¶
Types ¶
type Command ¶
type Command struct {
Unit unit.Unit
Label string
Action string
Req api.ActionRequest
PlanID string
// contains filtered or unexported fields
}
Command is an action for the daemon on one unit; Label names it on the status line. A plan action carries its item's PlanID.
type Config ¶
type Config struct {
Daemon Daemon
Term Terminal
Now func() time.Time
// Tick redraws the ages and countdowns; zero means every second.
Tick time.Duration
// Refresh polls the rows while the daemon has no event stream; zero
// means every 30 seconds. With a stream up, nothing polls.
Refresh time.Duration
// Reconnect is the wait before asking for the event stream again while
// the daemon does not answer; zero means 2 seconds.
Reconnect time.Duration
// Color styles the screen; the caller decides it as termfmt does.
Color bool
// OpenURL opens a unit's link, as the open command does; nil cannot.
OpenURL func(url string) error
}
type Daemon ¶
type Daemon interface {
RowsSince(ctx context.Context, since api.Since) (api.RowsPage, error)
Health(ctx context.Context) (api.Health, error)
Catalog(ctx context.Context) (api.CatalogResponse, error)
Plugins(ctx context.Context) ([]api.Plugin, error)
Actions(ctx context.Context) (api.ActionsResponse, error)
Ask(ctx context.Context, u unit.Unit, action string, req api.ActionRequest) (api.ActionResult, error)
Events(ctx context.Context, client string, since api.Since) (<-chan api.Change, error)
Plan(ctx context.Context, q api.PlanQuery) (api.PlanResponse, error)
ActOnPlan(ctx context.Context, req api.PlanActRequest) (api.PlanResponse, error)
Views(ctx context.Context) (api.ViewsCatalog, error)
TasksSince(ctx context.Context, q client.TaskQuery, since api.Since) (api.TasksPage, error)
Counters(ctx context.Context, area string, terms ...string) (api.Counters, error)
Task(ctx context.Context, id string) (api.TaskView, error)
TaskDo(ctx context.Context, id, verb string, req api.TaskRequest) (api.TaskResult, error)
TaskDrafts(ctx context.Context, task string) ([]api.Draft, error)
ResolveGate(ctx context.Context, id int64, intent string, req api.TaskRequest) (api.GateView, error)
Gates(ctx context.Context) ([]api.GateView, error)
CreateTask(ctx context.Context, req api.TaskCreate) (api.TaskView, error)
Keys(ctx context.Context, surface string) (api.KeysResponse, error)
Review(ctx context.Context) (api.Review, error)
ReviewStepDone(ctx context.Context, step string) (api.Review, error)
}
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder turns what a raw terminal sends into keys, across reads: an escape sequence or a UTF-8 rune split between two reads is held for the next one, so its second half never arrives as typed text. Escape sequences it does not know are dropped whole.
func (*Decoder) Expire ¶
func (d *Decoder) Expire()
Expire is called when a paste went idle: what came so far is dropped and so is the rest, up to the end marker. A discard that goes idle too ends.
func (*Decoder) Flush ¶
Flush is called when no more bytes came within a key's time: a lone ESC is the Esc key, and anything else held is dropped. A paste is not touched.
type EditRequest ¶
EditRequest is a prompt's text handed to the editor; Submit takes what the editor returns.
type Editor ¶
An Editor can hand the terminal to the user's editor on a text and return the text it left.
type Key ¶
Key is one key press: a printable rune, or a named key with Rune 0. A bracketed paste arrives whole as KeyPaste with its Text. Read numbers the terminal read the key came in, so a key typed ahead in the same read as the one that opened a prompt can be told apart from a deliberate answer.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func (*Model) FilterTerms ¶ added in v0.2.0
FilterTerms are the filter's words.
func (*Model) Render ¶
Render draws the screen as height lines of at most width cells: the views, the list of the current one, the selected pull request's detail, a status line and the help or prompt line.
func (*Model) SetCatalog ¶
func (m *Model) SetCatalog(c api.CatalogResponse)
SetCatalog takes the terminal's row views and the kinds' labels from the served catalog, keeping the current view by id.
func (*Model) SetClosed ¶ added in v0.2.0
func (m *Model) SetClosed(closed []api.ClosedSession)
SetClosed replaces the sessions closed in the last day.
func (*Model) SetCounters ¶
SetCounters replaces the counts the tabs show.
func (*Model) SetData ¶
SetData replaces the rows and keeps the selected pull request while it is still in the view, else the same place in the list.
func (*Model) SetFilteredCounters ¶ added in v0.2.0
SetFilteredCounters takes the counts of area narrowed to the tasks the filter keeps.
func (*Model) SetGates ¶ added in v0.3.0
SetGates takes the open gates: a plan gate with a deadline is an automatic round its unit's row counts down to.
func (*Model) SetLoading ¶ added in v0.3.0
SetLoading takes the plugins the last page of tasks said are still loading.
func (*Model) SetPlan ¶
SetPlan replaces the plan items, pending ones whose window ends soonest first, and keeps the selected one while it is still pending or blocked, else the same place in the list.
func (*Model) SetPlanSpecs ¶
func (m *Model) SetPlanSpecs(specs []api.ActionSpec)
SetPlanSpecs replaces the specs of the actions a plan item may offer.
func (*Model) SetPlugins ¶
SetPlugins keeps the plugins the daemon serves, whose views the catalog lists, keeping the current view by id.
func (*Model) SetReview ¶
SetReview takes the Review the daemon serves; with no step shown, or one it no longer has, the first open step is shown.
func (*Model) SetSpecs ¶
func (m *Model) SetSpecs(specs []api.ActionSpec)
SetSpecs replaces the action specs the keys follow.
func (*Model) SetTasks ¶ added in v0.3.0
SetTasks replaces the tasks of view, as its last page left them, and the counters that page carried.
func (*Model) SetViews ¶ added in v0.3.0
func (m *Model) SetViews(c api.ViewsCatalog)
SetViews takes the profile's views of GET /api/views. The first time, before the user moved to a view, it shows the first.
func (*Model) TakeEdit ¶
func (m *Model) TakeEdit() *EditRequest
TakeEdit is the text a prompt handed to the editor, nil when none waits.
type Suspender ¶
type Suspender interface {
Suspend() error
}
A Suspender can hand the terminal back to the shell on Ctrl-Z.
type TTY ¶
type TTY struct {
// contains filtered or unexported fields
}
TTY is the process's terminal in raw mode on the alternate screen.