Documentation
¶
Index ¶
- type Binding
- type CheckoutRefOptions
- type ConfirmOpts
- type Context
- type ContextKey
- type ContextKind
- type CreateMenuOptions
- type CreatePopupPanelOpts
- type Guard
- type HasKeybindings
- type HelperCommon
- type IBaseContext
- type IController
- type IGuiCommon
- type IList
- type IListContext
- type IListCursor
- type IListPanelState
- type IPatchExplorerContext
- type IPopupHandler
- type IViewTrait
- type Key
- type KeybindingGuards
- type KeybindingsFn
- type KeybindingsOpts
- type ListItem
- type MainContextPair
- type MainViewPairs
- type MenuItem
- type Model
- type Modes
- type MouseKeybindingsFn
- type Mutexes
- type OnFocusLostOpts
- type OnFocusOpts
- type ParentContexter
- type PromptOpts
- type Ref
- type RefreshMainOpts
- type RefreshMode
- type RefreshOptions
- type RefreshableView
- type RenderStringTask
- type RenderStringWithScrollTask
- type RenderStringWithoutScrollTask
- type RunCommandTask
- type RunPtyTask
- type Suggestion
- type UpdateTask
- type ViewUpdateOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Binding ¶ added in v0.35.0
type Binding struct { ViewName string Handler func() error Key Key Modifier gocui.Modifier Description string Alternative string Tag string // e.g. 'navigation'. Used for grouping things in the cheatsheet OpensMenu bool // to be displayed if the keybinding is highlighted from within a menu Tooltip string }
Binding - a keybinding mapping a key and modifier to a handler. The keypress is only handled if the given view has focus, or handled globally if the view is ""
type CheckoutRefOptions ¶ added in v0.35.0
type ConfirmOpts ¶ added in v0.35.0
type Context ¶ added in v0.35.0
type Context interface { IBaseContext HandleFocus(opts OnFocusOpts) error HandleFocusLost(opts OnFocusLostOpts) error HandleRender() error HandleRenderToMain() error }
type ContextKey ¶ added in v0.35.0
type ContextKey string
type ContextKind ¶ added in v0.35.0
type ContextKind int
const ( // this is your files, branches, commits, contexts etc. They're all on the left hand side // and you can cycle through them. SIDE_CONTEXT ContextKind = iota // This is either the left or right 'main' contexts that appear to the right of the side contexts MAIN_CONTEXT // A persistent popup is one that has its own identity e.g. the commit message context. // When you open a popup over it, we'll let you return to it upon pressing escape PERSISTENT_POPUP // A temporary popup is one that could be used for various things (e.g. a generic menu or confirmation popup). // Because we re-use these contexts, they're temporary in that you can't return to them after you've switched from them // to some other context, because the context you switched to might actually be the same context but rendering different content. // We should really be able to spawn new contexts for menus/prompts so that we can actually return to old ones. TEMPORARY_POPUP // This contains the command log, underneath the main contexts. EXTRAS_CONTEXT // only used by the one global context, purely for the sake of defining keybindings globally GLOBAL_CONTEXT // a display context only renders a view. It has no keybindings associated and // it cannot receive focus. DISPLAY_CONTEXT )
type CreateMenuOptions ¶ added in v0.35.0
type CreatePopupPanelOpts ¶ added in v0.35.0
type Guard ¶ added in v0.35.0
A guard is a decorator which checks something before executing a handler and potentially early-exits if some precondition hasn't been met.
type HasKeybindings ¶ added in v0.35.0
type HasKeybindings interface { GetKeybindings(opts KeybindingsOpts) []*Binding GetMouseKeybindings(opts KeybindingsOpts) []*gocui.ViewMouseBinding GetOnClick() func() error }
type HelperCommon ¶ added in v0.35.0
type HelperCommon struct { *common.Common IGuiCommon }
type IBaseContext ¶ added in v0.35.0
type IBaseContext interface { HasKeybindings ParentContexter GetKind() ContextKind GetViewName() string GetView() *gocui.View GetViewTrait() IViewTrait GetWindowName() string SetWindowName(string) GetKey() ContextKey IsFocusable() bool // if a context is transient, then it only appears via some keybinding on another // context. Until we add support for having multiple of the same context, no two // of the same transient context can appear at once meaning one might be 'stolen' // from another window. IsTransient() bool // this tells us if the view's bounds are determined by its window or if they're // determined independently. HasControlledBounds() bool // returns the desired title for the view upon activation. If there is no desired title (returns empty string), then // no title will be set Title() string GetOptionsMap() map[string]string AddKeybindingsFn(KeybindingsFn) AddMouseKeybindingsFn(MouseKeybindingsFn) // This is a bit of a hack at the moment: we currently only set an onclick function so that // our list controller can come along and wrap it in a list-specific click handler. // We'll need to think of a better way to do this. AddOnClickFn(func() error) }
type IController ¶ added in v0.35.0
type IController interface { HasKeybindings Context() Context }
type IGuiCommon ¶ added in v0.35.0
type IGuiCommon interface { IPopupHandler LogAction(action string) LogCommand(cmdStr string, isCommandLine bool) // we call this when we want to refetch some models and render the result. Internally calls PostRefreshUpdate Refresh(RefreshOptions) error // we call this when we've changed something in the view model but not the actual model, // e.g. expanding or collapsing a folder in a file view. Calling 'Refresh' in this // case would be overkill, although refresh will internally call 'PostRefreshUpdate' PostRefreshUpdate(Context) error // this just re-renders the screen Render() // allows rendering to main views (i.e. the ones to the right of the side panel) // in such a way that avoids concurrency issues when there are slow commands // to display the output of RenderToMainViews(opts RefreshMainOpts) error // used purely for the sake of RenderToMainViews to provide the pair of main views we want to render to MainViewPairs() MainViewPairs // returns true if command completed successfully RunSubprocess(cmdObj oscommands.ICmdObj) (bool, error) RunSubprocessAndRefresh(oscommands.ICmdObj) error PushContext(context Context, opts ...OnFocusOpts) error PopContext() error CurrentContext() Context CurrentStaticContext() Context IsCurrentContext(Context) bool // enters search mode for the current view OpenSearch() GetAppState() *config.AppState SaveAppState() error // Runs the given function on the UI thread (this is for things like showing a popup asking a user for input). // Only necessary to call if you're not already on the UI thread i.e. you're inside a goroutine. // All controller handlers are executed on the UI thread. OnUIThread(f func() error) }
type IList ¶ added in v0.35.0
type IList interface { IListCursor Len() int }
type IListContext ¶ added in v0.35.0
type IListCursor ¶ added in v0.35.0
type IListPanelState ¶ added in v0.35.0
type IPatchExplorerContext ¶ added in v0.36.0
type IPopupHandler ¶ added in v0.35.0
type IPopupHandler interface { // Shows a popup with a (localized) "Error" caption and the given error message (in red). // // This is a convenience wrapper around Alert(). ErrorMsg(message string) error Error(err error) error // Shows a notification popup with the given title and message to the user. // // This is a convenience wrapper around Confirm(), thus the popup can be closed using both 'Enter' and 'ESC'. Alert(title string, message string) error // Shows a popup asking the user for confirmation. Confirm(opts ConfirmOpts) error // Shows a popup prompting the user for input. Prompt(opts PromptOpts) error WithLoaderPanel(message string, f func() error) error WithWaitingStatus(message string, f func() error) error Menu(opts CreateMenuOptions) error Toast(message string) GetPromptInput() string }
type IViewTrait ¶ added in v0.35.0
type KeybindingGuards ¶ added in v0.35.0
type KeybindingsFn ¶ added in v0.35.0
type KeybindingsFn func(opts KeybindingsOpts) []*Binding
type KeybindingsOpts ¶ added in v0.35.0
type KeybindingsOpts struct { GetKey func(key string) Key Config config.KeybindingConfig Guards KeybindingGuards }
type ListItem ¶ added in v0.35.0
type ListItem interface { // ID is a SHA when the item is a commit, a filename when the item is a file, 'stash@{4}' when it's a stash entry, 'my_branch' when it's a branch ID() string // Description is something we would show in a message e.g. '123as14: push blah' for a commit Description() string }
type MainContextPair ¶ added in v0.36.0
func NewMainContextPair ¶ added in v0.36.0
func NewMainContextPair(main Context, secondary Context) MainContextPair
type MainViewPairs ¶ added in v0.36.0
type MainViewPairs struct { Normal MainContextPair MergeConflicts MainContextPair Staging MainContextPair PatchBuilding MainContextPair }
type MenuItem ¶ added in v0.35.0
type MenuItem struct { Label string // alternative to Label. Allows specifying columns which will be auto-aligned LabelColumns []string OnPress func() error // Only applies when Label is used OpensMenu bool // If Key is defined it allows the user to press the key to invoke the menu // item, as opposed to having to navigate to it Key Key // The tooltip will be displayed upon highlighting the menu item Tooltip string }
type Model ¶ added in v0.35.0
type Model struct { CommitFiles []*models.CommitFile Files []*models.File Submodules []*models.SubmoduleConfig Branches []*models.Branch Commits []*models.Commit StashEntries []*models.StashEntry SubCommits []*models.Commit Remotes []*models.Remote // FilteredReflogCommits are the ones that appear in the reflog panel. // when in filtering mode we only include the ones that match the given path FilteredReflogCommits []*models.Commit // ReflogCommits are the ones used by the branches panel to obtain recency values // if we're not in filtering mode, CommitFiles and FilteredReflogCommits will be // one and the same ReflogCommits []*models.Commit BisectInfo *git_commands.BisectInfo RemoteBranches []*models.RemoteBranch Tags []*models.Tag // for displaying suggestions while typing in a file name FilesTrie *patricia.Trie }
type Modes ¶ added in v0.35.0
type Modes struct { Filtering filtering.Filtering CherryPicking *cherrypicking.CherryPicking Diffing diffing.Diffing }
type MouseKeybindingsFn ¶ added in v0.35.0
type MouseKeybindingsFn func(opts KeybindingsOpts) []*gocui.ViewMouseBinding
type Mutexes ¶ added in v0.36.0
type Mutexes struct { RefreshingFilesMutex *deadlock.Mutex RefreshingStatusMutex *deadlock.Mutex SyncMutex *deadlock.Mutex LocalCommitsMutex *deadlock.Mutex SubprocessMutex *deadlock.Mutex PopupMutex *deadlock.Mutex PtyMutex *deadlock.Mutex }
if you add a new mutex here be sure to instantiate it. We're using pointers to mutexes so that we can pass the mutexes to controllers.
type OnFocusLostOpts ¶ added in v0.36.0
type OnFocusLostOpts struct {
NewContextKey ContextKey
}
type OnFocusOpts ¶ added in v0.35.0
type ParentContexter ¶ added in v0.35.0
type PromptOpts ¶ added in v0.35.0
type RefreshMainOpts ¶ added in v0.36.0
type RefreshMainOpts struct { Pair MainContextPair Main *ViewUpdateOpts Secondary *ViewUpdateOpts }
type RefreshMode ¶ added in v0.35.0
type RefreshMode int
const ( SYNC RefreshMode = iota // wait until everything is done before returning ASYNC // return immediately, allowing each independent thing to update itself BLOCK_UI // wrap code in an update call to ensure UI updates all at once and keybindings aren't executed till complete )
type RefreshOptions ¶ added in v0.35.0
type RefreshOptions struct { Then func() Scope []RefreshableView // e.g. []int{COMMITS, BRANCHES}. Leave empty to refresh everything Mode RefreshMode // one of SYNC (default), ASYNC, and BLOCK_UI }
type RefreshableView ¶ added in v0.35.0
type RefreshableView int
models/views that we can refresh
const ( COMMITS RefreshableView = iota REBASE_COMMITS BRANCHES FILES STASH REFLOG TAGS REMOTES STATUS SUBMODULES STAGING PATCH_BUILDING MERGE_CONFLICTS COMMIT_FILES // not actually a view. Will refactor this later BISECT_INFO )
type RenderStringTask ¶ added in v0.36.0
type RenderStringTask struct {
Str string
}
func NewRenderStringTask ¶ added in v0.36.0
func NewRenderStringTask(str string) *RenderStringTask
func (*RenderStringTask) IsUpdateTask ¶ added in v0.36.0
func (t *RenderStringTask) IsUpdateTask()
type RenderStringWithScrollTask ¶ added in v0.36.0
func NewRenderStringWithScrollTask ¶ added in v0.36.0
func NewRenderStringWithScrollTask(str string, originX int, originY int) *RenderStringWithScrollTask
func (*RenderStringWithScrollTask) IsUpdateTask ¶ added in v0.36.0
func (t *RenderStringWithScrollTask) IsUpdateTask()
type RenderStringWithoutScrollTask ¶ added in v0.36.0
type RenderStringWithoutScrollTask struct {
Str string
}
func NewRenderStringWithoutScrollTask ¶ added in v0.36.0
func NewRenderStringWithoutScrollTask(str string) *RenderStringWithoutScrollTask
func (*RenderStringWithoutScrollTask) IsUpdateTask ¶ added in v0.36.0
func (t *RenderStringWithoutScrollTask) IsUpdateTask()
type RunCommandTask ¶ added in v0.36.0
func NewRunCommandTask ¶ added in v0.36.0
func NewRunCommandTask(cmd *exec.Cmd) *RunCommandTask
func NewRunCommandTaskWithPrefix ¶ added in v0.36.0
func NewRunCommandTaskWithPrefix(cmd *exec.Cmd, prefix string) *RunCommandTask
func (*RunCommandTask) IsUpdateTask ¶ added in v0.36.0
func (t *RunCommandTask) IsUpdateTask()
type RunPtyTask ¶ added in v0.36.0
func NewRunPtyTask ¶ added in v0.36.0
func NewRunPtyTask(cmd *exec.Cmd) *RunPtyTask
func (*RunPtyTask) IsUpdateTask ¶ added in v0.36.0
func (t *RunPtyTask) IsUpdateTask()
type Suggestion ¶
type UpdateTask ¶ added in v0.36.0
type UpdateTask interface {
IsUpdateTask()
}
type ViewUpdateOpts ¶ added in v0.36.0
type ViewUpdateOpts struct { Title string Task UpdateTask }
Click to show internal directories.
Click to hide internal directories.