gui

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2021 License: MIT Imports: 45 Imported by: 1

Documentation

Index

Constants

View Source
const INFO_SECTION_PADDING = " "
View Source
const MAX_WATCHED_FILES = 50

macs for some bizarre reason cap the number of watchable files to 256. there's no obvious platform agonstic way to check the situation of the user's computer so we're just arbitrarily capping at 200. This isn't so bad because file watching is only really an added bonus for faster refreshing.

View Source
const SEARCH_PREFIX = "search: "
View Source
const StartupPopupVersion = 5
View Source
const UNKNOWN_VIEW_ERROR_MSG = "unknown view"

Variables

View Source
var OverlappingEdges = false

OverlappingEdges determines if panel edges overlap

Functions

func GetKeyDisplay added in v0.12.1

func GetKeyDisplay(key interface{}) string

func NewFileWatcher added in v0.12.1

func NewFileWatcher(log *logrus.Entry) *fileWatcher

func NewRenderStringTask added in v0.27.1

func NewRenderStringTask(str string) *renderStringTask

func NewRenderStringWithoutScrollTask added in v0.27.1

func NewRenderStringWithoutScrollTask(str string) *renderStringWithoutScrollTask

func NewRunCommandTask added in v0.27.1

func NewRunCommandTask(cmd *exec.Cmd) *runCommandTask

func NewRunCommandTaskWithPrefix added in v0.27.1

func NewRunCommandTaskWithPrefix(cmd *exec.Cmd, prefix string) *runCommandTask

func NewRunPtyTask added in v0.27.1

func NewRunPtyTask(cmd *exec.Cmd) *runPtyTask

Types

type BasicContext added in v0.22.0

type BasicContext struct {
	OnFocus         func() error
	OnFocusLost     func() error
	OnRender        func() error
	Kind            ContextKind
	Key             ContextKey
	ViewName        string
	WindowName      string
	OnGetOptionsMap func() map[string]string

	ParentContext Context
	// contains filtered or unexported fields
}

func (*BasicContext) GetKey added in v0.22.0

func (c *BasicContext) GetKey() ContextKey

func (*BasicContext) GetKind added in v0.22.0

func (c *BasicContext) GetKind() ContextKind

func (*BasicContext) GetOptionsMap added in v0.22.0

func (c *BasicContext) GetOptionsMap() map[string]string

func (*BasicContext) GetParentContext added in v0.22.0

func (c *BasicContext) GetParentContext() (Context, bool)

func (*BasicContext) GetViewName added in v0.22.0

func (c *BasicContext) GetViewName() string

func (*BasicContext) GetWindowName added in v0.22.0

func (c *BasicContext) GetWindowName() string

func (*BasicContext) HandleFocus added in v0.22.0

func (c *BasicContext) HandleFocus() error

func (*BasicContext) HandleFocusLost added in v0.22.0

func (c *BasicContext) HandleFocusLost() error

func (*BasicContext) HandleRender added in v0.22.0

func (c *BasicContext) HandleRender() error

func (*BasicContext) SetParentContext added in v0.22.0

func (c *BasicContext) SetParentContext(context Context)

func (*BasicContext) SetWindowName added in v0.22.0

func (c *BasicContext) SetWindowName(windowName string)

type Binding

type Binding struct {
	ViewName    string
	Contexts    []string
	Handler     func() error
	Key         interface{} // FIXME: find out how to get `gocui.Key | rune`
	Modifier    gocui.Modifier
	Description string
	Alternative string
	Tag         string // e.g. 'navigation'. Used for grouping things in the cheatsheet
	OpensMenu   bool
}

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 ""

func (*Binding) GetDisplayStrings added in v0.3.0

func (b *Binding) GetDisplayStrings(isFocused bool) []string

GetDisplayStrings returns the display string of a file

type CherryPicking added in v0.22.0

type CherryPicking struct {
	CherryPickedCommits []*models.Commit

	// we only allow cherry picking from one context at a time, so you can't copy a commit from the local commits context and then also copy a commit in the reflog context
	ContextKey ContextKey
}

func (*CherryPicking) Active added in v0.22.0

func (m *CherryPicking) Active() bool

type Context added in v0.22.0

type Context interface {
	HandleFocus() error
	HandleFocusLost() error
	HandleRender() error
	GetKind() ContextKind
	GetViewName() string
	GetWindowName() string
	SetWindowName(string)
	GetKey() ContextKey
	SetParentContext(Context)

	// we return a bool here to tell us whether or not the returned value just wraps a nil
	GetParentContext() (Context, bool)
	GetOptionsMap() map[string]string
}

type ContextKey added in v0.27.1

type ContextKey string
const (
	STATUS_CONTEXT_KEY              ContextKey = "status"
	FILES_CONTEXT_KEY               ContextKey = "files"
	LOCAL_BRANCHES_CONTEXT_KEY      ContextKey = "localBranches"
	REMOTES_CONTEXT_KEY             ContextKey = "remotes"
	REMOTE_BRANCHES_CONTEXT_KEY     ContextKey = "remoteBranches"
	TAGS_CONTEXT_KEY                ContextKey = "tags"
	BRANCH_COMMITS_CONTEXT_KEY      ContextKey = "commits"
	REFLOG_COMMITS_CONTEXT_KEY      ContextKey = "reflogCommits"
	SUB_COMMITS_CONTEXT_KEY         ContextKey = "subCommits"
	COMMIT_FILES_CONTEXT_KEY        ContextKey = "commitFiles"
	STASH_CONTEXT_KEY               ContextKey = "stash"
	MAIN_NORMAL_CONTEXT_KEY         ContextKey = "normal"
	MAIN_MERGING_CONTEXT_KEY        ContextKey = "merging"
	MAIN_PATCH_BUILDING_CONTEXT_KEY ContextKey = "patchBuilding"
	MAIN_STAGING_CONTEXT_KEY        ContextKey = "staging"
	MENU_CONTEXT_KEY                ContextKey = "menu"
	CREDENTIALS_CONTEXT_KEY         ContextKey = "credentials"
	CONFIRMATION_CONTEXT_KEY        ContextKey = "confirmation"
	SEARCH_CONTEXT_KEY              ContextKey = "search"
	COMMIT_MESSAGE_CONTEXT_KEY      ContextKey = "commitMessage"
	SUBMODULES_CONTEXT_KEY          ContextKey = "submodules"
	SUGGESTIONS_CONTEXT_KEY         ContextKey = "suggestions"
	COMMAND_LOG_CONTEXT_KEY         ContextKey = "cmdLog"
)

type ContextKind added in v0.27.1

type ContextKind int
const (
	SIDE_CONTEXT ContextKind = iota
	MAIN_CONTEXT
	TEMPORARY_POPUP
	PERSISTENT_POPUP
	EXTRAS_CONTEXT
)

type ContextManager added in v0.27.1

type ContextManager struct {
	ContextStack []Context
	sync.RWMutex
}

func NewContextManager added in v0.27.1

func NewContextManager(initialContext Context) ContextManager

type ContextTree added in v0.22.0

type ContextTree struct {
	Status         Context
	Files          *ListContext
	Submodules     *ListContext
	Menu           *ListContext
	Branches       *ListContext
	Remotes        *ListContext
	RemoteBranches *ListContext
	Tags           *ListContext
	BranchCommits  *ListContext
	CommitFiles    *ListContext
	ReflogCommits  *ListContext
	SubCommits     *ListContext
	Stash          *ListContext
	Suggestions    *ListContext
	Normal         Context
	Staging        Context
	PatchBuilding  Context
	Merging        Context
	Credentials    Context
	Confirmation   Context
	CommitMessage  Context
	Search         Context
	CommandLog     Context
}

type CustomCommandObjects added in v0.23.1

type CustomCommandObjects struct {
	SelectedLocalCommit    *models.Commit
	SelectedReflogCommit   *models.Commit
	SelectedSubCommit      *models.Commit
	SelectedFile           *models.File
	SelectedPath           string
	SelectedLocalBranch    *models.Branch
	SelectedRemoteBranch   *models.RemoteBranch
	SelectedRemote         *models.Remote
	SelectedTag            *models.Tag
	SelectedStashEntry     *models.StashEntry
	SelectedCommitFile     *models.CommitFile
	SelectedCommitFilePath string
	CheckedOutBranch       *models.Branch
	PromptResponses        []string
}

type Diffing added in v0.22.0

type Diffing struct {
	Ref     string
	Reverse bool
}

if ref is blank we're not diffing anything

func (*Diffing) Active added in v0.22.0

func (m *Diffing) Active() bool

type Gui

type Gui struct {
	Log        *logrus.Entry
	GitCommand *commands.GitCommand
	OSCommand  *oscommands.OSCommand

	// this is the state of the GUI for the current repo
	State *guiState

	// this is a mapping of repos to gui states, so that we can restore the original
	// gui state when returning from a subrepo
	RepoStateMap map[Repo]*guiState
	Config       config.AppConfigurer
	Tr           *i18n.TranslationSet
	Updater      *updates.Updater

	Mutexes guiMutexes

	// when you enter into a submodule we'll append the superproject's path to this array
	// so that you can return to the superproject
	RepoPathStack []string

	// this tells us whether our views have been initially set up
	ViewsSetup bool

	Views Views

	// if we've suspended the gui (e.g. because we've switched to a subprocess)
	// we typically want to pause some things that are running like background
	// file refreshes
	PauseBackgroundThreads bool

	// Log of the commands that get run, to be displayed to the user.
	CmdLog       []string
	OnRunCommand func(entry oscommands.CmdLogEntry)

	// the extras window contains things like the command log
	ShowExtrasWindow bool
	// contains filtered or unexported fields
}

Gui wraps the gocui Gui object which handles rendering and events

func NewGui

func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *oscommands.OSCommand, tr *i18n.TranslationSet, config config.AppConfigurer, updater *updates.Updater, filterPath string, showRecentRepos bool) (*Gui, error)

for now the split view will always be on NewGui builds a new gui handler

func (*Gui) GetCustomCommandKeybindings added in v0.23.1

func (gui *Gui) GetCustomCommandKeybindings() []*Binding

func (*Gui) GetInitialKeybindings added in v0.7.1

func (gui *Gui) GetInitialKeybindings() []*Binding

GetInitialKeybindings is a function.

func (*Gui) GetOnRunCommand added in v0.28.1

func (gui *Gui) GetOnRunCommand() func(entry oscommands.CmdLogEntry)

func (*Gui) HandlePasteCommits added in v0.7.1

func (gui *Gui) HandlePasteCommits() error

HandlePasteCommits begins a cherry-pick rebase with the commits the user has copied

func (*Gui) RenderCommitLength added in v0.2.2

func (gui *Gui) RenderCommitLength()

RenderCommitLength is a function.

func (*Gui) Run

func (gui *Gui) Run() error

Run setup the gui with keybindings and start the mainloop

func (*Gui) RunAndHandleError added in v0.27.1

func (gui *Gui) RunAndHandleError() error

RunAndHandleError

func (*Gui) WithWaitingStatus added in v0.7.1

func (gui *Gui) WithWaitingStatus(message string, f func() error) error

WithWaitingStatus wraps a function and shows a waiting status while the function is still executing

type IListPanelState added in v0.22.0

type IListPanelState interface {
	SetSelectedLineIdx(int)
	GetSelectedLineIdx() int
}

type LblPanelState added in v0.28.1

type LblPanelState struct {
	*lbl.State
	SecondaryFocused bool // this is for if we show the left or right panel
}

for now the staging panel state, unlike the other panel states, is going to be non-mutative, so that we don't accidentally end up with mismatches of data. We might change this in the future

type ListContext added in v0.22.0

type ListContext struct {
	GetItemsLength      func() int
	GetDisplayStrings   func() [][]string
	OnFocus             func() error
	OnFocusLost         func() error
	OnClickSelectedItem func() error

	// the boolean here tells us whether the item is nil. This is needed because you can't work it out on the calling end once the pointer is wrapped in an interface (unless you want to use reflection)
	SelectedItem  func() (ListItem, bool)
	GetPanelState func() IListPanelState

	Gui                        *Gui
	ResetMainViewOriginOnFocus bool

	*BasicContext
}

func (*ListContext) GetSelectedItem added in v0.22.0

func (lc *ListContext) GetSelectedItem() (ListItem, bool)

func (*ListContext) GetSelectedItemId added in v0.22.0

func (lc *ListContext) GetSelectedItemId() string

func (*ListContext) HandleFocus added in v0.22.0

func (lc *ListContext) HandleFocus() error

func (*ListContext) HandleFocusLost added in v0.22.0

func (lc *ListContext) HandleFocusLost() error

func (*ListContext) HandleRender added in v0.22.0

func (lc *ListContext) HandleRender() error

func (*ListContext) OnRender added in v0.22.0

func (lc *ListContext) OnRender() 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

type ListItem added in v0.22.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 MergingPanelState added in v0.28.1

type MergingPanelState struct {
	*mergeconflicts.State

	// UserScrolling tells us if the user has started scrolling through the file themselves
	// in which case we won't auto-scroll to a conflict.
	UserScrolling bool
}

type Modes added in v0.22.0

type Modes struct {
	Filtering     filtering.Filtering
	CherryPicking CherryPicking
	Diffing       Diffing
}

type PullFilesOptions added in v0.22.0

type PullFilesOptions struct {
	RemoteName string
	BranchName string
	// contains filtered or unexported fields
}

type ReflogActionKind added in v0.27.1

type ReflogActionKind int
const (
	CHECKOUT ReflogActionKind = iota
	COMMIT
	REBASE
	CURRENT_REBASE
)

type RefreshMode added in v0.27.1

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 RefreshableView added in v0.27.1

type RefreshableView int

models/views that we can refresh

const (
	COMMITS RefreshableView = iota
	BRANCHES
	FILES
	STASH
	REFLOG
	TAGS
	REMOTES
	STATUS
	SUBMODULES
)

type Repo added in v0.27.1

type Repo string

type StartupStage added in v0.27.1

type StartupStage int

startup stages so we don't need to load everything at once

const (
	INITIAL StartupStage = iota
	COMPLETE
)

type TaskKind added in v0.27.1

type TaskKind int

constants for updateTask's kind field

const (
	RENDER_STRING TaskKind = iota
	RENDER_STRING_WITHOUT_SCROLL
	RUN_FUNCTION
	RUN_COMMAND
	RUN_PTY
)

type Views added in v0.27.1

type Views struct {
	Status        *gocui.View
	Files         *gocui.View
	Branches      *gocui.View
	Commits       *gocui.View
	Stash         *gocui.View
	Main          *gocui.View
	Secondary     *gocui.View
	Options       *gocui.View
	Confirmation  *gocui.View
	Menu          *gocui.View
	Credentials   *gocui.View
	CommitMessage *gocui.View
	CommitFiles   *gocui.View
	Information   *gocui.View
	AppStatus     *gocui.View
	Search        *gocui.View
	SearchPrefix  *gocui.View
	Limit         *gocui.View
	Suggestions   *gocui.View
	Extras        *gocui.View
}

type WindowMaximisation added in v0.27.1

type WindowMaximisation int

screen sizing determines how much space your selected window takes up (window as in panel, not your terminal's window). Sometimes you want a bit more space to see the contents of a panel, and this keeps track of how much maximisation you've set

const (
	SCREEN_NORMAL WindowMaximisation = iota
	SCREEN_HALF
	SCREEN_FULL
)

Directories

Path Synopsis
modes

Jump to

Keyboard shortcuts

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