Documentation
¶
Overview ¶
Package interactive houses interactive UI types and helpers shared across the application.
Index ¶
- Constants
- Variables
- func Run(gitClient git.StatusInfoReader) []string
- type ANSIColors
- type CommandInfo
- type CommandRouter
- type Context
- type ContextManager
- type ContextualKeyBindingMap
- type GitStatus
- type KeyBindingMap
- type KeyBindingResolver
- type KeyHandler
- type KeyStroke
- type Profile
- type Renderer
- type UI
- func (ui *UI) AddToWorkflow(command string, args []string, description string) int
- func (ui *UI) ApplyContextualKeybindings(contextual *ContextualKeyBindingMap)
- func (ui *UI) ClearWorkflow()
- func (ui *UI) ExecuteWorkflow() error
- func (ui *UI) ResetToSearchMode() bool
- func (ui *UI) Run() []string
- func (ui *UI) ToggleWorkflowView()
- type UIState
- func (s *UIState) AddRune(r rune)
- func (s *UIState) ClearInput()
- func (s *UIState) DeleteToEnd()
- func (s *UIState) DeleteWord()
- func (s *UIState) EnterContext(newContext Context)
- func (s *UIState) ExitContext()
- func (s *UIState) GetCurrentContext() Context
- func (s *UIState) GetSelectedCommand() *CommandInfo
- func (s *UIState) HasInput() bool
- func (s *UIState) HasMatches() bool
- func (s *UIState) IsInInputMode() bool
- func (s *UIState) IsInResultsMode() bool
- func (s *UIState) IsInSearchMode() bool
- func (s *UIState) MoveDown()
- func (s *UIState) MoveLeft()
- func (s *UIState) MoveRight()
- func (s *UIState) MoveToBeginning()
- func (s *UIState) MoveToEnd()
- func (s *UIState) MoveUp()
- func (s *UIState) MoveWordLeft()
- func (s *UIState) MoveWordRight()
- func (s *UIState) RemoveChar()
- func (s *UIState) SetContext(ctx Context)
- func (s *UIState) UpdateFiltered()
- type Workflow
- type WorkflowExecutor
- type WorkflowStep
Constants ¶
const ( // InteractiveQuitCommand instructs the interactive UI to exit. InteractiveQuitCommand = "quit" // InteractiveWorkflowCommand signals that an interactive workflow has been executed. InteractiveWorkflowCommand = "workflow-executed" )
const ( // ProfileDefault exposes the default key binding profile identifier. ProfileDefault = kb.ProfileDefault // ProfileEmacs exposes the emacs key binding profile identifier. ProfileEmacs = kb.ProfileEmacs // ProfileVi exposes the vi key binding profile identifier. ProfileVi = kb.ProfileVi // ProfileReadline exposes the readline key binding profile identifier. ProfileReadline = kb.ProfileReadline // ContextGlobal exposes the global key binding context identifier. ContextGlobal = kb.ContextGlobal // ContextInput exposes the input key binding context identifier. ContextInput = kb.ContextInput // ContextResults exposes the results key binding context identifier. ContextResults = kb.ContextResults // ContextSearch exposes the search key binding context identifier. ContextSearch = kb.ContextSearch )
Variables ¶
var ( // NewKeyBindingResolver constructs a key binding resolver using the keybindings package implementation. NewKeyBindingResolver = kb.NewKeyBindingResolver // RegisterBuiltinProfiles registers builtin profiles in the underlying keybindings package. RegisterBuiltinProfiles = kb.RegisterBuiltinProfiles // DefaultKeyBindingMap provides the default key binding map from the keybindings package. DefaultKeyBindingMap = kb.DefaultKeyBindingMap // DetectPlatform returns the inferred platform from the keybindings package. DetectPlatform = kb.DetectPlatform // DetectTerminal returns the inferred terminal from the keybindings package. DetectTerminal = kb.DetectTerminal // NewContextManager constructs a context manager using the keybindings package. NewContextManager = kb.NewContextManager // NewCtrlKeyStroke creates a control key stroke using the keybindings package implementation. NewCtrlKeyStroke = kb.NewCtrlKeyStroke // NewCharKeyStroke creates a character key stroke using the keybindings package implementation. NewCharKeyStroke = kb.NewCharKeyStroke // NewRawKeyStroke creates a raw key stroke using the keybindings package implementation. NewRawKeyStroke = kb.NewRawKeyStroke // NewEscapeKeyStroke creates an escape key stroke using the keybindings package implementation. NewEscapeKeyStroke = kb.NewEscapeKeyStroke // NewAltKeyStroke creates an alt key stroke using the keybindings package implementation. NewAltKeyStroke = kb.NewAltKeyStroke // NewContextualKeyBindingMap builds a contextual key binding map using the keybindings package implementation. NewContextualKeyBindingMap = kb.NewContextualKeyBindingMap // FormatKeyStrokesForDisplay formats key strokes for human-readable display. FormatKeyStrokesForDisplay = kb.FormatKeyStrokesForDisplay )
var ErrWorkflowCanceled = errors.New("workflow canceled")
ErrWorkflowCanceled indicates the workflow was aborted by the user via soft cancel.
Functions ¶
func Run ¶
func Run(gitClient git.StatusInfoReader) []string
Run executes the incremental search interactive UI with the provided custom git client, and returns the selected command as []string (or nil if nothing is selected).
Types ¶
type ANSIColors ¶
type ANSIColors = uiutil.ANSIColors
ANSIColors is an alias to the shared UI palette definition.
func NewANSIColors ¶
func NewANSIColors() *ANSIColors
NewANSIColors exposes the shared ANSI color palette helper.
type CommandInfo ¶
CommandInfo contains the name and description of the command
type CommandRouter ¶
type CommandRouter interface {
Route(args []string)
}
CommandRouter represents an interface for routing commands
type ContextManager ¶
type ContextManager = kb.ContextManager
ContextManager exposes the kb.ContextManager type to interactive consumers.
type ContextualKeyBindingMap ¶
type ContextualKeyBindingMap = kb.ContextualKeyBindingMap
ContextualKeyBindingMap exposes the kb.ContextualKeyBindingMap type to interactive consumers.
type GitStatus ¶
type GitStatus struct {
Branch string
Modified int
Staged int
Ahead int
Behind int
HasChanges bool
}
GitStatus represents the current Git repository status
type KeyBindingMap ¶
type KeyBindingMap = kb.KeyBindingMap
KeyBindingMap exposes the kb.KeyBindingMap type to interactive consumers.
type KeyBindingResolver ¶
type KeyBindingResolver = kb.KeyBindingResolver
KeyBindingResolver exposes the kb.KeyBindingResolver type to interactive consumers.
type KeyHandler ¶
type KeyHandler struct {
// contains filtered or unexported fields
}
KeyHandler manages keyboard input processing
func (*KeyHandler) GetCurrentKeyMap ¶
func (h *KeyHandler) GetCurrentKeyMap() *KeyBindingMap
GetCurrentKeyMap returns the appropriate keybinding map for the current context
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer handles all terminal rendering operations
type UI ¶
type UI struct {
// contains filtered or unexported fields
}
UI represents the interface for terminal UI operations
func NewUI ¶
func NewUI(gitClient git.StatusInfoReader, router ...CommandRouter) *UI
NewUI creates a new UI with the provided git client and loads keybindings from config
func (*UI) AddToWorkflow ¶
AddToWorkflow adds a command to the workflow
func (*UI) ApplyContextualKeybindings ¶
func (ui *UI) ApplyContextualKeybindings(contextual *ContextualKeyBindingMap)
ApplyContextualKeybindings updates the active keybinding map, satisfying keybindings.ContextualMapApplier.
func (*UI) ClearWorkflow ¶
func (ui *UI) ClearWorkflow()
ClearWorkflow removes all steps from the workflow
func (*UI) ExecuteWorkflow ¶
ExecuteWorkflow executes the current workflow
func (*UI) ResetToSearchMode ¶
ResetToSearchMode clears the interactive search UI back to its default state.
func (*UI) ToggleWorkflowView ¶
func (ui *UI) ToggleWorkflowView()
ToggleWorkflowView toggles between normal command view and workflow view
type UIState ¶
type UIState struct {
// contains filtered or unexported fields
}
UIState holds the current state of the interactive UI
func (*UIState) DeleteToEnd ¶
func (s *UIState) DeleteToEnd()
DeleteToEnd deletes from cursor to end of line (Ctrl+K)
func (*UIState) DeleteWord ¶
func (s *UIState) DeleteWord()
DeleteWord deletes word before cursor (Ctrl+W)
func (*UIState) EnterContext ¶
EnterContext pushes the current context onto the stack and switches to the new context
func (*UIState) ExitContext ¶
func (s *UIState) ExitContext()
ExitContext pops the previous context from the stack
func (*UIState) GetCurrentContext ¶
GetCurrentContext returns the current UI context
func (*UIState) GetSelectedCommand ¶
func (s *UIState) GetSelectedCommand() *CommandInfo
GetSelectedCommand returns the currently selected command
func (*UIState) HasMatches ¶
HasMatches returns true if there are filtered matches
func (*UIState) IsInInputMode ¶
IsInInputMode returns true if currently in input context
func (*UIState) IsInResultsMode ¶
IsInResultsMode returns true if currently in results context
func (*UIState) IsInSearchMode ¶
IsInSearchMode returns true if currently in search context
func (*UIState) MoveToBeginning ¶
func (s *UIState) MoveToBeginning()
MoveToBeginning moves cursor to beginning of line (Ctrl+A)
func (*UIState) MoveToEnd ¶
func (s *UIState) MoveToEnd()
MoveToEnd moves cursor to end of line (Ctrl+E)
func (*UIState) MoveWordLeft ¶
func (s *UIState) MoveWordLeft()
MoveWordLeft moves cursor to the beginning of the previous word
func (*UIState) MoveWordRight ¶
func (s *UIState) MoveWordRight()
MoveWordRight moves cursor to the start of the next word
func (*UIState) RemoveChar ¶
func (s *UIState) RemoveChar()
RemoveChar removes character before cursor (backspace)
func (*UIState) SetContext ¶
SetContext directly sets the context (use with caution)
func (*UIState) UpdateFiltered ¶
func (s *UIState) UpdateFiltered()
UpdateFiltered updates the filtered commands based on current input using fuzzy matching
type Workflow ¶
type Workflow struct {
// contains filtered or unexported fields
}
Workflow manages a sequence of commands to be executed
func (*Workflow) GetSteps ¶
func (w *Workflow) GetSteps() []WorkflowStep
GetSteps returns a copy of all workflow steps
type WorkflowExecutor ¶
type WorkflowExecutor struct {
// contains filtered or unexported fields
}
WorkflowExecutor executes workflow steps sequentially using existing Route mechanism
func NewWorkflowExecutor ¶
func NewWorkflowExecutor(router CommandRouter, ui *UI) *WorkflowExecutor
NewWorkflowExecutor creates a new workflow executor
func (*WorkflowExecutor) Execute ¶
func (we *WorkflowExecutor) Execute(workflow *Workflow) error
Execute runs all steps in the workflow sequentially
type WorkflowStep ¶
type WorkflowStep struct {
ID int `json:"id"`
Command string `json:"command"`
Args []string `json:"args"`
Description string `json:"description"`
}
WorkflowStep represents a single step in a workflow
func (*WorkflowStep) String ¶
func (ws *WorkflowStep) String() string
String returns a string representation of the workflow step