Documentation
¶
Overview ¶
Package remoteview is the machinery pkg/table and pkg/eventlog share for showing data that lives behind a slow remote source: which query the items on screen answer, whether that is still the one the user committed, what failed, what the border says about it, and — in Range — which items are resident at all.
It holds state and answers questions; it renders nothing and owns no component. Each host keeps its own cursor, rendering and query model, and asks this package the questions that must be answered the same way in every component that shows remote data: are these items stale, what does the border suffix read, is a spinner due.
Index ¶
- Constants
- Variables
- type Answer
- type Missing
- type Range
- func (r *Range[T]) Append(items []T, keys []string, at int) (before int)
- func (r Range[T]) At(i int) (T, bool)
- func (r *Range[T]) Clear()
- func (r Range[T]) Count() int
- func (r Range[T]) Edges() (older, newer string)
- func (r Range[T]) Held() (start, count int)
- func (r Range[T]) IndexOf(k string) int
- func (r Range[T]) IsSpan() bool
- func (r Range[T]) KeyAt(i int) string
- func (r Range[T]) Len() int
- func (r *Range[T]) Merge(items []T, keys []string, offset, total int)
- func (r Range[T]) More() (older, newer bool)
- func (r *Range[T]) Prepend(items []T, keys []string, at int) (before int)
- func (r *Range[T]) Replace(items []T, keys []string, offset, total int)
- func (r *Range[T]) SetMore(older, newer bool)
- func (r Range[T]) Total() int
- func (r *Range[T]) Trim(max, first, last int) (front int)
- type Status
- func (s *Status) AnswerCommitted(committed Answer)
- func (s *Status) Arm(token focus.Token, waiting bool) tea.Cmd
- func (s *Status) Handle(token focus.Token, msg tea.Msg) (handled, advanced bool)
- func (s Status) Loading() bool
- func (s Status) PageFailed(missing Missing) bool
- func (s *Status) Rearm()
- func (s *Status) SetAnswer(a, committed Answer) (fresh bool)
- func (s *Status) SetFailed(q, committed Answer, missing Missing)
- func (s Status) Spin() string
- func (s Status) Stale(committed Answer) bool
- func (s Status) Suffix(committed Answer, missing Missing, noun, asc, desc string) string
- func (s Status) Waiting(committed Answer, missing Missing) bool
- type TickMsg
Constants ¶
const FrameEvery = 90 * time.Millisecond
FrameEvery is how often the suffix spinner advances.
Variables ¶
var Frames = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}
Frames is the spinner drawn in the border suffix.
Functions ¶
This section is empty.
Types ¶
type Answer ¶
Answer names the query a set of items answers: the committed filter text, the sort column's title, and its direction. Hosts export it under their own name (table.Answer, eventlog.Answer) as an alias.
func (Answer) Normalized ¶
Normalized is a with the forms that mean the same query made equal.
type Range ¶
type Range[T any] struct { // contains filtered or unexported fields }
Range is the items a component holds of a remote set: a contiguous run, each with a key, either at logical offsets of a Seekable set (with a total) or as a Span of Anchored data (no offsets, more-or-not at each edge). It grows by merging pages, trims the end furthest from the viewport past a cap, and answers "is logical index i resident".
func NewSpan ¶
NewSpan returns an empty span, with more beyond both edges until pages say otherwise.
func (*Range[T]) Append ¶
Append adds items at the newer edge of a span (or the end of a range), oldest first. Keys already held are skipped; an item the page places before a held key — a late arrival — goes before it, so the result keeps the page's own order without comparing cursors. It reports how many items were inserted before index at, so a host can keep its cursor.
func (Range[T]) Count ¶
Count is the logical length: the total when known, else what is held through its end. For a span it is the resident length.
func (Range[T]) Edges ¶
Edges returns the keys of the oldest and newest resident items — the cursors an Anchored source extends from.
func (*Range[T]) Merge ¶
Merge installs a Seekable page: one that touches or overlaps what is held extends it (the page wins where they overlap), one that doesn't replaces it.
func (*Range[T]) Replace ¶
Replace installs items as the whole range, at offset of a set total long (Seekable; ignored for a span).
type Status ¶
type Status struct {
Answer Answer
HasAnswer bool
Failed bool
// Retry marks that committing the unchanged, failed query again must
// still be reported, since that is how the user retries it.
Retry bool
// contains filtered or unexported fields
}
Status is where a host stands with its source: the query its items answer, whether the committed query failed, and a page failure scoped to the items that were missing when it happened.
func (*Status) AnswerCommitted ¶
AnswerCommitted records that items installed with no Answer — a host's plain setters — answer the committed query.
func (*Status) Handle ¶
Handle consumes the host's spinner tick. handled is true for any TickMsg; advanced is true when it was this host's current tick and the frame moved, so the host should redraw and re-arm.
func (Status) Loading ¶
Loading reports whether the host's body should show its Loading spinner: nothing has answered yet, and nothing has failed.
func (Status) PageFailed ¶
PageFailed reports whether the items missing now are the ones whose page failed.
func (*Status) Rearm ¶
func (s *Status) Rearm()
Rearm forgets any spinner tick in flight, so the next Arm schedules a fresh one — for a Status carried onto a rebuilt host, whose ticks the old host's pending one will not match.
func (*Status) SetAnswer ¶
SetAnswer records that newly installed items answer a. It reports whether they end a stale spell — the moment a host moves its cursor to where the new answer begins.
func (*Status) SetFailed ¶
SetFailed records a failed fetch for q. A failure for anything but the committed query is already superseded and ignored. When the committed query is answered and current, only a page of it failed: that failure is scoped to the items missing now, and is not a failed query.
func (Status) Spin ¶
Spin reports the current spinner frame, for hosts drawing other waiting states (an edge loading) with the same glyph.