Documentation
¶
Overview ¶
Package focus is a small, pure focus-ring state machine shared by every chatshell screen. It replaces the boolean flags DataTug's chat UI used (gridFocused, messageFocused, workspaceFocused, ...) with a single source of truth: which Zone holds focus and, when the zone is Transcript, which "stop" (an index into the transcript's ordered list of focusable entries, e.g. result grids and user messages) is focused.
Semantics (identical to DataTug's chat UI, generalised):
- Shift+Up from an empty input focuses the latest (bottom-most) focusable transcript stop.
- Shift+Up / Shift+Down move between transcript stops.
- Shift+Down past the last stop returns focus to the input.
- Shift+Right moves focus to the sidebar, remembering where focus was so Shift+Left can return to it.
- Shift+Left, from the sidebar, returns focus to the remembered zone/stop.
- Esc always returns focus to the input.
Ring holds no rendering state and knows nothing about tea.Msg; callers decide which key presses trigger which method (see tui/chatshell).
Index ¶
- type Ring
- func (r *Ring) Esc()
- func (r *Ring) FocusInput()
- func (r *Ring) FocusSidebar()
- func (r *Ring) FocusStop(index int)
- func (r *Ring) ShiftDown(stops int) bool
- func (r *Ring) ShiftLeft(stops int) bool
- func (r *Ring) ShiftRight() bool
- func (r *Ring) ShiftUp(stops int) bool
- func (r *Ring) Stop() int
- func (r *Ring) Zone() Zone
- type Zone
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
Ring is the focus-ring state machine. The zero value is ready to use and starts focused on the input, matching New().
func (*Ring) FocusInput ¶
func (r *Ring) FocusInput()
FocusInput focuses the composer directly (equivalent to Esc).
func (*Ring) FocusSidebar ¶
func (r *Ring) FocusSidebar()
FocusSidebar moves focus to the sidebar, remembering the current zone/stop so ShiftLeft can return to it. A no-op when already in the sidebar.
func (*Ring) FocusStop ¶
FocusStop focuses transcript stop index directly, e.g. after a click or an Enter-driven navigation elsewhere in the product. index must be a valid stop (the caller is expected to have checked it against the current stop count); an out-of-range index is clamped to input focus.
func (*Ring) ShiftDown ¶
ShiftDown implements Shift+Down: moves toward later transcript stops, and past the last stop returns focus to the input. It reports whether focus moved.
func (*Ring) ShiftLeft ¶
ShiftLeft implements Shift+Left: returns focus from the sidebar to where it was before ShiftRight. stops is the CURRENT number of focusable transcript entries: when the remembered zone was Transcript and its stop no longer exists (entries were removed while the sidebar had focus), the returned stop is clamped to the last valid one, or to Input when there are no stops left at all. It reports whether focus moved.
func (*Ring) ShiftRight ¶
ShiftRight implements Shift+Right: moves focus into the sidebar. Callers gate this on the sidebar being visible/split. It reports whether focus moved.
func (*Ring) ShiftUp ¶
ShiftUp implements Shift+Up. stops is the current number of focusable transcript entries. It reports whether focus moved.