context

package
v0.35.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	GLOBAL_CONTEXT_KEY              types.ContextKey = "global"
	STATUS_CONTEXT_KEY              types.ContextKey = "status"
	FILES_CONTEXT_KEY               types.ContextKey = "files"
	LOCAL_BRANCHES_CONTEXT_KEY      types.ContextKey = "localBranches"
	REMOTES_CONTEXT_KEY             types.ContextKey = "remotes"
	REMOTE_BRANCHES_CONTEXT_KEY     types.ContextKey = "remoteBranches"
	TAGS_CONTEXT_KEY                types.ContextKey = "tags"
	LOCAL_COMMITS_CONTEXT_KEY       types.ContextKey = "commits"
	REFLOG_COMMITS_CONTEXT_KEY      types.ContextKey = "reflogCommits"
	SUB_COMMITS_CONTEXT_KEY         types.ContextKey = "subCommits"
	COMMIT_FILES_CONTEXT_KEY        types.ContextKey = "commitFiles"
	STASH_CONTEXT_KEY               types.ContextKey = "stash"
	MAIN_NORMAL_CONTEXT_KEY         types.ContextKey = "normal"
	MAIN_MERGING_CONTEXT_KEY        types.ContextKey = "merging"
	MAIN_PATCH_BUILDING_CONTEXT_KEY types.ContextKey = "patchBuilding"
	MAIN_STAGING_CONTEXT_KEY        types.ContextKey = "staging"
	MENU_CONTEXT_KEY                types.ContextKey = "menu"
	CONFIRMATION_CONTEXT_KEY        types.ContextKey = "confirmation"
	SEARCH_CONTEXT_KEY              types.ContextKey = "search"
	COMMIT_MESSAGE_CONTEXT_KEY      types.ContextKey = "commitMessage"
	SUBMODULES_CONTEXT_KEY          types.ContextKey = "submodules"
	SUGGESTIONS_CONTEXT_KEY         types.ContextKey = "suggestions"
	COMMAND_LOG_CONTEXT_KEY         types.ContextKey = "cmdLog"
)
View Source
const HORIZONTAL_SCROLL_FACTOR = 3

Variables

Functions

func Zero

func Zero[T any]() T

Types

type BaseContext

type BaseContext struct {
	ViewName string

	*ParentContextMgr
	// contains filtered or unexported fields
}

func NewBaseContext

func NewBaseContext(opts NewBaseContextOpts) *BaseContext

func (*BaseContext) AddKeybindingsFn

func (self *BaseContext) AddKeybindingsFn(fn types.KeybindingsFn)

func (*BaseContext) AddMouseKeybindingsFn

func (self *BaseContext) AddMouseKeybindingsFn(fn types.MouseKeybindingsFn)

func (*BaseContext) AddOnClickFn

func (self *BaseContext) AddOnClickFn(fn func() error)

func (*BaseContext) GetKey

func (self *BaseContext) GetKey() types.ContextKey

func (*BaseContext) GetKeybindings

func (self *BaseContext) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding

func (*BaseContext) GetKind

func (self *BaseContext) GetKind() types.ContextKind

func (*BaseContext) GetMouseKeybindings

func (self *BaseContext) GetMouseKeybindings(opts types.KeybindingsOpts) []*gocui.ViewMouseBinding

func (*BaseContext) GetOnClick

func (self *BaseContext) GetOnClick() func() error

func (*BaseContext) GetOptionsMap

func (self *BaseContext) GetOptionsMap() map[string]string

func (*BaseContext) GetViewName

func (self *BaseContext) GetViewName() string

func (*BaseContext) GetWindowName

func (self *BaseContext) GetWindowName() string

func (*BaseContext) IsFocusable

func (self *BaseContext) IsFocusable() bool

func (*BaseContext) IsTransient

func (self *BaseContext) IsTransient() bool

func (*BaseContext) SetWindowName

func (self *BaseContext) SetWindowName(windowName string)

func (*BaseContext) Title

func (self *BaseContext) Title() string

type BasicViewModel

type BasicViewModel[T any] struct {
	*traits.ListCursor
	// contains filtered or unexported fields
}

func NewBasicViewModel

func NewBasicViewModel[T any](getModel func() []T) *BasicViewModel[T]

func (*BasicViewModel[T]) GetSelected

func (self *BasicViewModel[T]) GetSelected() T

func (*BasicViewModel[T]) Len

func (self *BasicViewModel[T]) Len() int

type BranchesContext

type BranchesContext struct {
	*BasicViewModel[*models.Branch]
	*ListContextTrait
}

func NewBranchesContext

func NewBranchesContext(
	getModel func() []*models.Branch,
	view *gocui.View,
	getDisplayStrings func(startIdx int, length int) [][]string,

	onFocus func(...types.OnFocusOpts) error,
	onRenderToMain func(...types.OnFocusOpts) error,
	onFocusLost func() error,

	c *types.HelperCommon,
) *BranchesContext

func (*BranchesContext) GetSelectedItemId

func (self *BranchesContext) GetSelectedItemId() string

func (*BranchesContext) GetSelectedRef

func (self *BranchesContext) GetSelectedRef() types.Ref

type CommitFilesContext

func NewCommitFilesContext

func NewCommitFilesContext(
	getModel func() []*models.CommitFile,
	view *gocui.View,
	getDisplayStrings func(startIdx int, length int) [][]string,

	onFocus func(...types.OnFocusOpts) error,
	onRenderToMain func(...types.OnFocusOpts) error,
	onFocusLost func() error,

	c *types.HelperCommon,
) *CommitFilesContext

func (*CommitFilesContext) GetSelectedItemId

func (self *CommitFilesContext) GetSelectedItemId() string

type ContextCallbackOpts

type ContextCallbackOpts struct {
	OnFocus     func(opts ...types.OnFocusOpts) error
	OnFocusLost func() error
	OnRender    func() error
	// this is for pushing some content to the main view
	OnRenderToMain func(opts ...types.OnFocusOpts) error
}

type ContextTree

type ContextTree struct {
	Global         types.Context
	Status         types.Context
	Files          *WorkingTreeContext
	Menu           *MenuContext
	Branches       *BranchesContext
	Tags           *TagsContext
	LocalCommits   *LocalCommitsContext
	CommitFiles    *CommitFilesContext
	Remotes        *RemotesContext
	Submodules     *SubmodulesContext
	RemoteBranches *RemoteBranchesContext
	ReflogCommits  *ReflogCommitsContext
	SubCommits     *SubCommitsContext
	Stash          *StashContext
	Suggestions    *SuggestionsContext
	Normal         types.Context
	Staging        types.Context
	PatchBuilding  types.Context
	Merging        types.Context
	Confirmation   types.Context
	CommitMessage  types.Context
	Search         types.Context
	CommandLog     types.Context
}

func (*ContextTree) Flatten

func (self *ContextTree) Flatten() []types.Context

type DynamicTitleBuilder

type DynamicTitleBuilder struct {
	// contains filtered or unexported fields
}

func NewDynamicTitleBuilder

func NewDynamicTitleBuilder(formatStr string) *DynamicTitleBuilder

func (*DynamicTitleBuilder) SetTitleRef

func (self *DynamicTitleBuilder) SetTitleRef(titleRef string)

func (*DynamicTitleBuilder) Title

func (self *DynamicTitleBuilder) Title() string

type ListContextTrait

type ListContextTrait struct {
	types.Context
	// contains filtered or unexported fields
}

func (*ListContextTrait) FocusLine

func (self *ListContextTrait) FocusLine()

func (*ListContextTrait) GetList

func (self *ListContextTrait) GetList() types.IList

func (*ListContextTrait) GetViewTrait

func (self *ListContextTrait) GetViewTrait() types.IViewTrait

func (*ListContextTrait) HandleFocus

func (self *ListContextTrait) HandleFocus(opts ...types.OnFocusOpts) error

func (*ListContextTrait) HandleFocusLost

func (self *ListContextTrait) HandleFocusLost() error

func (*ListContextTrait) HandleRender

func (self *ListContextTrait) HandleRender() error

OnFocus assumes that the content of the context has already been rendered to the view. OnRender is the function which actually renders the content to the view

func (*ListContextTrait) OnSearchSelect

func (self *ListContextTrait) OnSearchSelect(selectedLineIdx int) error

type LocalCommitsContext

type LocalCommitsContext struct {
	*LocalCommitsViewModel
	*ViewportListContextTrait
}

func NewLocalCommitsContext

func NewLocalCommitsContext(
	getModel func() []*models.Commit,
	view *gocui.View,
	getDisplayStrings func(startIdx int, length int) [][]string,

	onFocus func(...types.OnFocusOpts) error,
	onRenderToMain func(...types.OnFocusOpts) error,
	onFocusLost func() error,

	c *types.HelperCommon,
) *LocalCommitsContext

func (*LocalCommitsContext) CanRebase

func (self *LocalCommitsContext) CanRebase() bool

func (*LocalCommitsContext) GetSelectedItemId

func (self *LocalCommitsContext) GetSelectedItemId() string

func (*LocalCommitsContext) GetSelectedRef

func (self *LocalCommitsContext) GetSelectedRef() types.Ref

type LocalCommitsViewModel

type LocalCommitsViewModel struct {
	*BasicViewModel[*models.Commit]
	// contains filtered or unexported fields
}

func NewLocalCommitsViewModel

func NewLocalCommitsViewModel(getModel func() []*models.Commit, c *types.HelperCommon) *LocalCommitsViewModel

func (*LocalCommitsViewModel) GetCommits

func (self *LocalCommitsViewModel) GetCommits() []*models.Commit

func (*LocalCommitsViewModel) GetLimitCommits

func (self *LocalCommitsViewModel) GetLimitCommits() bool

func (*LocalCommitsViewModel) GetShowWholeGitGraph

func (self *LocalCommitsViewModel) GetShowWholeGitGraph() bool

func (*LocalCommitsViewModel) SetLimitCommits

func (self *LocalCommitsViewModel) SetLimitCommits(value bool)

func (*LocalCommitsViewModel) SetShowWholeGitGraph

func (self *LocalCommitsViewModel) SetShowWholeGitGraph(value bool)
type MenuContext struct {
	*MenuViewModel
	*ListContextTrait
}

func NewMenuContext

func NewMenuContext(
	view *gocui.View,

	c *types.HelperCommon,
	getOptionsMap func() map[string]string,
	renderToDescriptionView func(string),
) *MenuContext
func (self *MenuContext) GetKeybindings(opts types.KeybindingsOpts) []*types.Binding
func (self *MenuContext) GetSelectedItemId() string

TODO: remove this thing.

func (self *MenuContext) OnMenuPress(selectedItem *types.MenuItem) error
type MenuViewModel struct {
	*BasicViewModel[*types.MenuItem]
	// contains filtered or unexported fields
}

func NewMenuViewModel

func NewMenuViewModel() *MenuViewModel
func (self *MenuViewModel) GetDisplayStrings(_startIdx int, _length int) [][]string

TODO: move into presentation package

func (self *MenuViewModel) SetMenuItems(items []*types.MenuItem)

type NewBaseContextOpts

type NewBaseContextOpts struct {
	Kind       types.ContextKind
	Key        types.ContextKey
	ViewName   string
	WindowName string
	Focusable  bool
	Transient  bool

	OnGetOptionsMap func() map[string]string
}

type ParentContextMgr

type ParentContextMgr struct {
	ParentContext types.Context
	// contains filtered or unexported fields
}

func (*ParentContextMgr) GetParentContext

func (self *ParentContextMgr) GetParentContext() (types.Context, bool)

func (*ParentContextMgr) SetParentContext

func (self *ParentContextMgr) SetParentContext(context types.Context)

type ReflogCommitsContext

type ReflogCommitsContext struct {
	*BasicViewModel[*models.Commit]
	*ListContextTrait
}

func NewReflogCommitsContext

func NewReflogCommitsContext(
	getModel func() []*models.Commit,
	view *gocui.View,
	getDisplayStrings func(startIdx int, length int) [][]string,

	onFocus func(...types.OnFocusOpts) error,
	onRenderToMain func(...types.OnFocusOpts) error,
	onFocusLost func() error,

	c *types.HelperCommon,
) *ReflogCommitsContext

func (*ReflogCommitsContext) CanRebase

func (self *ReflogCommitsContext) CanRebase() bool

func (*ReflogCommitsContext) GetCommits

func (self *ReflogCommitsContext) GetCommits() []*models.Commit

func (*ReflogCommitsContext) GetSelectedItemId

func (self *ReflogCommitsContext) GetSelectedItemId() string

func (*ReflogCommitsContext) GetSelectedRef

func (self *ReflogCommitsContext) GetSelectedRef() types.Ref

type RemoteBranchesContext

type RemoteBranchesContext struct {
	*BasicViewModel[*models.RemoteBranch]
	*ListContextTrait
	*DynamicTitleBuilder
}

func NewRemoteBranchesContext

func NewRemoteBranchesContext(
	getModel func() []*models.RemoteBranch,
	view *gocui.View,
	getDisplayStrings func(startIdx int, length int) [][]string,

	onFocus func(...types.OnFocusOpts) error,
	onRenderToMain func(...types.OnFocusOpts) error,
	onFocusLost func() error,

	c *types.HelperCommon,
) *RemoteBranchesContext

func (*RemoteBranchesContext) GetSelectedItemId

func (self *RemoteBranchesContext) GetSelectedItemId() string

func (*RemoteBranchesContext) GetSelectedRef

func (self *RemoteBranchesContext) GetSelectedRef() types.Ref

type RemotesContext

type RemotesContext struct {
	*BasicViewModel[*models.Remote]
	*ListContextTrait
}

func NewRemotesContext

func NewRemotesContext(
	getModel func() []*models.Remote,
	view *gocui.View,
	getDisplayStrings func(startIdx int, length int) [][]string,

	onFocus func(...types.OnFocusOpts) error,
	onRenderToMain func(...types.OnFocusOpts) error,
	onFocusLost func() error,

	c *types.HelperCommon,
) *RemotesContext

func (*RemotesContext) GetSelectedItemId

func (self *RemotesContext) GetSelectedItemId() string

type SimpleContext

type SimpleContext struct {
	OnFocus     func(opts ...types.OnFocusOpts) error
	OnFocusLost func() error
	OnRender    func() error
	// this is for pushing some content to the main view
	OnRenderToMain func(opts ...types.OnFocusOpts) error

	*BaseContext
}

func NewSimpleContext

func NewSimpleContext(baseContext *BaseContext, opts ContextCallbackOpts) *SimpleContext

func (*SimpleContext) HandleFocus

func (self *SimpleContext) HandleFocus(opts ...types.OnFocusOpts) error

func (*SimpleContext) HandleFocusLost

func (self *SimpleContext) HandleFocusLost() error

func (*SimpleContext) HandleRender

func (self *SimpleContext) HandleRender() error

func (*SimpleContext) HandleRenderToMain

func (self *SimpleContext) HandleRenderToMain() error

type StashContext

type StashContext struct {
	*BasicViewModel[*models.StashEntry]
	*ListContextTrait
}

func NewStashContext

func NewStashContext(
	getModel func() []*models.StashEntry,
	view *gocui.View,
	getDisplayStrings func(startIdx int, length int) [][]string,

	onFocus func(...types.OnFocusOpts) error,
	onRenderToMain func(...types.OnFocusOpts) error,
	onFocusLost func() error,

	c *types.HelperCommon,
) *StashContext

func (*StashContext) CanRebase

func (self *StashContext) CanRebase() bool

func (*StashContext) GetSelectedItemId

func (self *StashContext) GetSelectedItemId() string

func (*StashContext) GetSelectedRef

func (self *StashContext) GetSelectedRef() types.Ref

type SubCommitsContext

func NewSubCommitsContext

func NewSubCommitsContext(
	getModel func() []*models.Commit,
	view *gocui.View,
	getDisplayStrings func(startIdx int, length int) [][]string,

	onFocus func(...types.OnFocusOpts) error,
	onRenderToMain func(...types.OnFocusOpts) error,
	onFocusLost func() error,

	c *types.HelperCommon,
) *SubCommitsContext

func (*SubCommitsContext) CanRebase

func (self *SubCommitsContext) CanRebase() bool

func (*SubCommitsContext) GetCommits

func (self *SubCommitsContext) GetCommits() []*models.Commit

func (*SubCommitsContext) GetSelectedItemId

func (self *SubCommitsContext) GetSelectedItemId() string

func (*SubCommitsContext) GetSelectedRef

func (self *SubCommitsContext) GetSelectedRef() types.Ref

func (*SubCommitsContext) Title

func (self *SubCommitsContext) Title() string

type SubCommitsViewModel

type SubCommitsViewModel struct {
	*BasicViewModel[*models.Commit]
	// contains filtered or unexported fields
}

func (*SubCommitsViewModel) SetRefName

func (self *SubCommitsViewModel) SetRefName(refName string)

type SubmodulesContext

type SubmodulesContext struct {
	*BasicViewModel[*models.SubmoduleConfig]
	*ListContextTrait
}

func NewSubmodulesContext

func NewSubmodulesContext(
	getModel func() []*models.SubmoduleConfig,
	view *gocui.View,
	getDisplayStrings func(startIdx int, length int) [][]string,

	onFocus func(...types.OnFocusOpts) error,
	onRenderToMain func(...types.OnFocusOpts) error,
	onFocusLost func() error,

	c *types.HelperCommon,
) *SubmodulesContext

func (*SubmodulesContext) GetSelectedItemId

func (self *SubmodulesContext) GetSelectedItemId() string

type SuggestionsContext

type SuggestionsContext struct {
	*BasicViewModel[*types.Suggestion]
	*ListContextTrait
}

func NewSuggestionsContext

func NewSuggestionsContext(
	getModel func() []*types.Suggestion,
	view *gocui.View,
	getDisplayStrings func(startIdx int, length int) [][]string,

	onFocus func(...types.OnFocusOpts) error,
	onRenderToMain func(...types.OnFocusOpts) error,
	onFocusLost func() error,

	c *types.HelperCommon,
) *SuggestionsContext

func (*SuggestionsContext) GetSelectedItemId

func (self *SuggestionsContext) GetSelectedItemId() string

type TabContext

type TabContext struct {
	Tab     string
	Context types.Context
}

type TagsContext

type TagsContext struct {
	*BasicViewModel[*models.Tag]
	*ListContextTrait
}

func NewTagsContext

func NewTagsContext(
	getModel func() []*models.Tag,
	view *gocui.View,
	getDisplayStrings func(startIdx int, length int) [][]string,

	onFocus func(...types.OnFocusOpts) error,
	onRenderToMain func(...types.OnFocusOpts) error,
	onFocusLost func() error,

	c *types.HelperCommon,
) *TagsContext

func (*TagsContext) GetSelectedItemId

func (self *TagsContext) GetSelectedItemId() string

func (*TagsContext) GetSelectedRef

func (self *TagsContext) GetSelectedRef() types.Ref

type ViewContextMap

type ViewContextMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewViewContextMap

func NewViewContextMap() *ViewContextMap

func (*ViewContextMap) Entries

func (self *ViewContextMap) Entries() map[string]types.Context

func (*ViewContextMap) Get

func (self *ViewContextMap) Get(viewName string) types.Context

func (*ViewContextMap) Set

func (self *ViewContextMap) Set(viewName string, context types.Context)

type ViewTrait

type ViewTrait struct {
	// contains filtered or unexported fields
}

func NewViewTrait

func NewViewTrait(view *gocui.View) *ViewTrait

func (*ViewTrait) FocusPoint

func (self *ViewTrait) FocusPoint(yIdx int)

func (*ViewTrait) PageDelta

func (self *ViewTrait) PageDelta() int

this returns the amount we'll scroll if we want to scroll by a page.

func (*ViewTrait) ScrollDown

func (self *ViewTrait) ScrollDown()

func (*ViewTrait) ScrollLeft

func (self *ViewTrait) ScrollLeft()

func (*ViewTrait) ScrollRight

func (self *ViewTrait) ScrollRight()

func (*ViewTrait) ScrollUp

func (self *ViewTrait) ScrollUp()

func (*ViewTrait) SelectedLineIdx

func (self *ViewTrait) SelectedLineIdx() int

func (*ViewTrait) SetContent

func (self *ViewTrait) SetContent(content string)

func (*ViewTrait) SetFooter

func (self *ViewTrait) SetFooter(value string)

func (*ViewTrait) SetHighlight

func (self *ViewTrait) SetHighlight(highlight bool)

func (*ViewTrait) SetOriginX

func (self *ViewTrait) SetOriginX(value int)

func (*ViewTrait) SetViewPortContent

func (self *ViewTrait) SetViewPortContent(content string)

func (*ViewTrait) ViewPortYBounds

func (self *ViewTrait) ViewPortYBounds() (int, int)

tells us the start of line indexes shown in the view currently as well as the capacity of lines shown in the viewport.

type ViewportListContextTrait

type ViewportListContextTrait struct {
	*ListContextTrait
}

func (*ViewportListContextTrait) FocusLine

func (self *ViewportListContextTrait) FocusLine()

type WorkingTreeContext

type WorkingTreeContext struct {
	*filetree.FileTreeViewModel
	*ListContextTrait
}

func NewWorkingTreeContext

func NewWorkingTreeContext(
	getModel func() []*models.File,
	view *gocui.View,
	getDisplayStrings func(startIdx int, length int) [][]string,

	onFocus func(...types.OnFocusOpts) error,
	onRenderToMain func(...types.OnFocusOpts) error,
	onFocusLost func() error,

	c *types.HelperCommon,
) *WorkingTreeContext

func (*WorkingTreeContext) GetSelectedItemId

func (self *WorkingTreeContext) GetSelectedItemId() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL