diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/commands/patch/patch_parser.go | 8 | ||||
-rw-r--r-- | pkg/gui/boxlayout/boxlayout.go | 10 | ||||
-rw-r--r-- | pkg/gui/boxlayout/boxlayout_test.go | 4 | ||||
-rw-r--r-- | pkg/gui/branches_panel.go | 4 | ||||
-rw-r--r-- | pkg/gui/commits_panel.go | 8 | ||||
-rw-r--r-- | pkg/gui/context.go | 10 | ||||
-rw-r--r-- | pkg/gui/discard_changes_menu_panel.go | 8 | ||||
-rw-r--r-- | pkg/gui/errors.go | 42 | ||||
-rw-r--r-- | pkg/gui/file_watching.go | 2 | ||||
-rw-r--r-- | pkg/gui/files_panel.go | 10 | ||||
-rw-r--r-- | pkg/gui/global_handlers.go | 32 | ||||
-rw-r--r-- | pkg/gui/gui.go | 59 | ||||
-rw-r--r-- | pkg/gui/line_by_line_panel.go | 4 | ||||
-rw-r--r-- | pkg/gui/list_context.go | 4 | ||||
-rw-r--r-- | pkg/gui/main_panels.go | 16 | ||||
-rw-r--r-- | pkg/gui/merge_panel.go | 4 | ||||
-rw-r--r-- | pkg/gui/remote_branches_panel.go | 4 | ||||
-rw-r--r-- | pkg/gui/remotes_panel.go | 8 | ||||
-rw-r--r-- | pkg/gui/reset_menu_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/staging_panel.go | 2 | ||||
-rw-r--r-- | pkg/gui/stash_panel.go | 4 | ||||
-rw-r--r-- | pkg/gui/submodules_panel.go | 20 | ||||
-rw-r--r-- | pkg/gui/tags_panel.go | 4 | ||||
-rw-r--r-- | pkg/gui/undoing.go | 6 | ||||
-rw-r--r-- | pkg/gui/view_helpers.go | 32 | ||||
-rw-r--r-- | pkg/gui/workspace_reset_options_panel.go | 12 |
26 files changed, 185 insertions, 134 deletions
diff --git a/pkg/commands/patch/patch_parser.go b/pkg/commands/patch/patch_parser.go index 55554fec3..00eafd995 100644 --- a/pkg/commands/patch/patch_parser.go +++ b/pkg/commands/patch/patch_parser.go @@ -10,8 +10,10 @@ import ( "github.com/sirupsen/logrus" ) +type PatchLineKind int + const ( - PATCH_HEADER = iota + PATCH_HEADER PatchLineKind = iota COMMIT_SHA COMMIT_DESCRIPTION HUNK_HEADER @@ -24,7 +26,7 @@ const ( // the job of this file is to parse a diff, find out where the hunks begin and end, which lines are stageable, and how to find the next hunk from the current position or the next stageable line from the current position. type PatchLine struct { - Kind int + Kind PatchLineKind Content string // something like '+ hello' (note the first character is not removed) } @@ -144,7 +146,7 @@ func parsePatch(patch string) ([]int, []int, []*PatchLine, error) { pastFirstHunkHeader := false pastCommitDescription := true patchLines := make([]*PatchLine, len(lines)) - var lineKind int + var lineKind PatchLineKind var firstChar string for index, line := range lines { firstChar = " " diff --git a/pkg/gui/boxlayout/boxlayout.go b/pkg/gui/boxlayout/boxlayout.go index b5d78faea..ac077becd 100644 --- a/pkg/gui/boxlayout/boxlayout.go +++ b/pkg/gui/boxlayout/boxlayout.go @@ -9,8 +9,10 @@ type Dimensions struct { Y1 int } +type Direction int + const ( - ROW = iota + ROW Direction = iota COLUMN ) @@ -26,10 +28,10 @@ const ( type Box struct { // Direction decides how the children boxes are laid out. ROW means the children will each form a row i.e. that they will be stacked on top of eachother. - Direction int // ROW or COLUMN + Direction Direction // function which takes the width and height assigned to the box and decides which orientation it will have - ConditionalDirection func(width int, height int) int + ConditionalDirection func(width int, height int) Direction Children []*Box @@ -120,7 +122,7 @@ func (b *Box) isStatic() bool { return b.Size > 0 } -func (b *Box) getDirection(width int, height int) int { +func (b *Box) getDirection(width int, height int) Direction { if b.ConditionalDirection != nil { return b.ConditionalDirection(width, height) } diff --git a/pkg/gui/boxlayout/boxlayout_test.go b/pkg/gui/boxlayout/boxlayout_test.go index 9a50ff9d2..6f06379a3 100644 --- a/pkg/gui/boxlayout/boxlayout_test.go +++ b/pkg/gui/boxlayout/boxlayout_test.go @@ -87,7 +87,7 @@ func TestArrangeWindows(t *testing.T) { }, { "Box with COLUMN direction only on wide boxes with narrow box", - &Box{ConditionalDirection: func(width int, height int) int { + &Box{ConditionalDirection: func(width int, height int) Direction { if width > 4 { return COLUMN } else { @@ -111,7 +111,7 @@ func TestArrangeWindows(t *testing.T) { }, { "Box with COLUMN direction only on wide boxes with wide box", - &Box{ConditionalDirection: func(width int, height int) int { + &Box{ConditionalDirection: func(width int, height int) Direction { if width > 4 { return COLUMN } else { diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index 9dd5438cc..e94ed7700 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -293,7 +293,7 @@ func (gui *Gui) deleteNamedBranch(selectedBranch *models.Branch, force bool) err } return gui.createErrorPanel(errMessage) } - return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{BRANCHES}}) + return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{BRANCHES}}) }, }) } @@ -408,7 +408,7 @@ func (gui *Gui) handleFastForward(g *gocui.Gui, v *gocui.View) error { } else { err := gui.GitCommand.FastForward(branch.Name, remoteName, remoteBranchName, gui.promptUserForCredential) gui.handleCredentialsPopup(err) - _ = gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{BRANCHES}}) + _ = gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{BRANCHES}}) } }) return nil diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 6be372f2e..1ad295763 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -437,7 +437,7 @@ func (gui *Gui) handleCommitRevert(g *gocui.Gui, v *gocui.View) error { return gui.surfaceError(err) } gui.State.Panels.Commits.SelectedLineIdx++ - return gui.refreshSidePanels(refreshOptions{mode: BLOCK_UI, scope: []int{COMMITS, BRANCHES}}) + return gui.refreshSidePanels(refreshOptions{mode: BLOCK_UI, scope: []RefreshableView{COMMITS, BRANCHES}}) } func (gui *Gui) handleViewCommitFiles() error { @@ -527,7 +527,7 @@ func (gui *Gui) handleCreateLightweightTag(commitSha string) error { if err := gui.GitCommand.CreateLightweightTag(response, commitSha); err != nil { return gui.surfaceError(err) } - return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{COMMITS, TAGS}}) + return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{COMMITS, TAGS}}) }, }) } @@ -560,7 +560,7 @@ func (gui *Gui) handleOpenSearchForCommitsPanel(g *gocui.Gui, v *gocui.View) err // we usually lazyload these commits but now that we're searching we need to load them now if gui.State.Panels.Commits.LimitCommits { gui.State.Panels.Commits.LimitCommits = false - if err := gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{COMMITS}}); err != nil { + if err := gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{COMMITS}}); err != nil { return err } } @@ -572,7 +572,7 @@ func (gui *Gui) handleGotoBottomForCommitsPanel(g *gocui.Gui, v *gocui.View) err // we usually lazyload these commits but now that we're searching we need to load them now if gui.State.Panels.Commits.LimitCommits { gui.State.Panels.Commits.LimitCommits = false - if err := gui.refreshSidePanels(refreshOptions{mode: SYNC, scope: []int{COMMITS}}); err != nil { + if err := gui.refreshSidePanels(refreshOptions{mode: SYNC, scope: []RefreshableView{COMMITS}}); err != nil { return err } } diff --git a/pkg/gui/context.go b/pkg/gui/context.go index c28fc9efc..91ec00fb1 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -6,8 +6,10 @@ import ( "github.com/jesseduffield/gocui" ) +type ContextKind int + const ( - SIDE_CONTEXT int = iota + SIDE_CONTEXT ContextKind = iota MAIN_CONTEXT TEMPORARY_POPUP PERSISTENT_POPUP @@ -126,7 +128,7 @@ type Context interface { HandleFocus() error HandleFocusLost() error HandleRender() error - GetKind() int + GetKind() ContextKind GetViewName() string GetWindowName() string SetWindowName(string) @@ -143,7 +145,7 @@ type BasicContext struct { OnFocusLost func() error OnRender func() error OnGetOptionsMap func() map[string]string - Kind int + Kind ContextKind Key string ViewName string } @@ -194,7 +196,7 @@ func (c BasicContext) HandleFocusLost() error { return nil } -func (c BasicContext) GetKind() int { +func (c BasicContext) GetKind() ContextKind { return c.Kind } diff --git a/pkg/gui/discard_changes_menu_panel.go b/pkg/gui/discard_changes_menu_panel.go index daa2d76d8..71f9e6d96 100644 --- a/pkg/gui/discard_changes_menu_panel.go +++ b/pkg/gui/discard_changes_menu_panel.go @@ -15,7 +15,7 @@ func (gui *Gui) handleCreateDiscardMenu() error { if err := gui.GitCommand.DiscardAllDirChanges(node); err != nil { return gui.surfaceError(err) } - return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{FILES}}) + return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{FILES}}) }, }, } @@ -28,7 +28,7 @@ func (gui *Gui) handleCreateDiscardMenu() error { return gui.surfaceError(err) } - return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{FILES}}) + return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{FILES}}) }, }) } @@ -55,7 +55,7 @@ func (gui *Gui) handleCreateDiscardMenu() error { if err := gui.GitCommand.DiscardAllFileChanges(file); err != nil { return gui.surfaceError(err) } - return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{FILES}}) + return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{FILES}}) }, }, } @@ -68,7 +68,7 @@ func (gui *Gui) handleCreateDiscardMenu() error { return gui.surfaceError(err) } - return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{FILES}}) + return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{FILES}}) }, }) } diff --git a/pkg/gui/errors.go b/pkg/gui/errors.go new file mode 100644 index 000000000..d8aa7530d --- /dev/null +++ b/pkg/gui/errors.go @@ -0,0 +1,42 @@ +package gui + +import "github.com/go-errors/errors" + +// SentinelErrors are the errors that have special meaning and need to be checked +// by calling functions. The less of these, the better +type SentinelErrors struct { + ErrSubProcess error + ErrNoFiles error + ErrSwitchRepo error + ErrRestart error +} + +const UNKNOWN_VIEW_ERROR_MSG = "unknown view" + +// GenerateSentinelErrors makes the sentinel errors for the gui. We're defining it here +// because we can't do package-scoped errors with localization, and also because +// it seems like package-scoped variables are bad in general +// https://dave.cheney.net/2017/06/11/go-without-package-scoped-variables +// In the future it would be good to implement some of the recommendations of +// that article. For now, if we don't need an error to be a sentinel, we will just +// define it inline. This has implications for error messages that pop up everywhere +// in that we'll be duplicating the default values. We may need to look at +// having a default localisation bundle defined, and just using keys-only when +// localising things in the code. +func (gui *Gui) GenerateSentinelErrors() { + gui.Errors = SentinelErrors{ + ErrSubProcess: errors.New(gui.Tr.RunningSubprocess), + ErrNoFiles: errors.New(gui.Tr.NoChangedFiles), + ErrSwitchRepo: errors.New("switching repo"), + ErrRestart: errors.New("restarting"), + } +} + +func (gui *Gui) sentinelErrorsArr() []error { + return []error{ + gui.Errors.ErrSubProcess, + gui.Errors.ErrNoFiles, + gui.Errors.ErrSwitchRepo, + gui.Errors.ErrRestart, + } +} diff --git a/pkg/gui/file_watching.go b/pkg/gui/file_watching.go index f7617e559..607aa6eec 100644 --- a/pkg/gui/file_watching.go +++ b/pkg/gui/file_watching.go @@ -117,7 +117,7 @@ func (gui *Gui) watchFilesForChanges() { } // only refresh if we're not already if !gui.State.IsRefreshingFiles { - _ = gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{FILES}}) + _ = gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{FILES}}) } // watch for errors diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index c6fcb07d9..b9477ea1a 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -256,7 +256,7 @@ func (gui *Gui) handleFilePress() error { } } - if err := gui.refreshSidePanels(refreshOptions{scope: []int{FILES}}); err != nil { + if err := gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{FILES}}); err != nil { return err } @@ -287,7 +287,7 @@ func (gui *Gui) handleStageAll(g *gocui.Gui, v *gocui.View) error { _ = gui.surfaceError(err) } - if err := gui.refreshSidePanels(refreshOptions{scope: []int{FILES}}); err != nil { + if err := gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{FILES}}); err != nil { return err } @@ -333,7 +333,7 @@ func (gui *Gui) handleIgnoreFile() error { if err := gui.GitCommand.Ignore(node.GetPath()); err != nil { return err } - return gui.refreshSidePanels(refreshOptions{scope: []int{FILES}}) + return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{FILES}}) }, }) } @@ -346,7 +346,7 @@ func (gui *Gui) handleIgnoreFile() error { return gui.surfaceError(err) } - return gui.refreshSidePanels(refreshOptions{scope: []int{FILES}}) + return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{FILES}}) } func (gui *Gui) handleWIPCommitPress(g *gocui.Gui, filesView *gocui.View) error { @@ -522,7 +522,7 @@ func (gui *Gui) handleFileOpen(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) handleRefreshFiles(g *gocui.Gui, v *gocui.View) error { - return gui.refreshSidePanels(refreshOptions{scope: []int{FILES}}) + return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{FILES}}) } func (gui *Gui) refreshStateFiles() error { diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go index d0c357df0..2db37e5d4 100644 --- a/pkg/gui/global_handlers.go +++ b/pkg/gui/global_handlers.go @@ -22,14 +22,40 @@ func (gui *Gui) rerenderViewsWithScreenModeDependentContent() error { return nil } +// TODO: GENERICS +func nextIntInCycle(sl []WindowMaximisation, current WindowMaximisation) WindowMaximisation { + for i, val := range sl { + if val == current { + if i == len(sl)-1 { + return sl[0] + } + return sl[i+1] + } + } + return sl[0] +} + +// TODO: GENERICS +func prevIntInCycle(sl []WindowMaximisation, current WindowMaximisation) WindowMaximisation { + for i, val := range sl { + if val == current { + if i > 0 { + return sl[i-1] + } + return sl[len(sl)-1] + } + } + return sl[len(sl)-1] +} + func (gui *Gui) nextScreenMode(g *gocui.Gui, v *gocui.View) error { - gui.State.ScreenMode = utils.NextIntInCycle([]int{SCREEN_NORMAL, SCREEN_HALF, SCREEN_FULL}, gui.State.ScreenMode) + gui.State.ScreenMode = nextIntInCycle([]WindowMaximisation{SCREEN_NORMAL, SCREEN_HALF, SCREEN_FULL}, gui.State.ScreenMode) return gui.rerenderViewsWithScreenModeDependentContent() } func (gui *Gui) prevScreenMode(g *gocui.Gui, v *gocui.View) error { - gui.State.ScreenMode = utils.PrevIntInCycle([]int{SCREEN_NORMAL, SCREEN_HALF, SCREEN_FULL}, gui.State.ScreenMode) + gui.State.ScreenMode = prevIntInCycle([]WindowMaximisation{SCREEN_NORMAL, SCREEN_HALF, SCREEN_FULL}, gui.State.ScreenMode) return gui.rerenderViewsWithScreenModeDependentContent() } @@ -179,7 +205,7 @@ func (gui *Gui) fetch(canPromptForCredentials bool) (err error) { _ = gui.createErrorPanel(gui.Tr.PassUnameWrong) } - _ = gui.refreshSidePanels(refreshOptions{scope: []int{BRANCHES, COMMITS, REMOTES, TAGS}, mode: ASYNC}) + _ = gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{BRANCHES, COMMITS, REMOTES, TAGS}, mode: ASYNC}) return err } diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index a5d66153f..671321d54 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -11,8 +11,6 @@ import ( "strings" "time" - "github.com/go-errors/errors" - "github.com/fatih/color" "github.com/golang-collections/collections/stack" "github.com/jesseduffield/gocui" @@ -33,8 +31,14 @@ import ( "github.com/sirupsen/logrus" ) +// 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 +type WindowMaximisation int + const ( - SCREEN_NORMAL int = iota + SCREEN_NORMAL WindowMaximisation = iota SCREEN_HALF SCREEN_FULL ) @@ -44,45 +48,6 @@ const StartupPopupVersion = 3 // OverlappingEdges determines if panel edges overlap var OverlappingEdges = false -// SentinelErrors are the errors that have special meaning and need to be checked -// by calling functions. The less of these, the better -type SentinelErrors struct { - ErrSubProcess error - ErrNoFiles error - ErrSwitchRepo error - ErrRestart error -} - -const UNKNOWN_VIEW_ERROR_MSG = "unknown view" - -// GenerateSentinelErrors makes the sentinel errors for the gui. We're defining it here -// because we can't do package-scoped errors with localization, and also because -// it seems like package-scoped variables are bad in general -// https://dave.cheney.net/2017/06/11/go-without-package-scoped-variables -// In the future it would be good to implement some of the recommendations of -// that article. For now, if we don't need an error to be a sentinel, we will just -// define it inline. This has implications for error messages that pop up everywhere -// in that we'll be duplicating the default values. We may need to look at -// having a default localisation bundle defined, and just using keys-only when -// localising things in the code. -func (gui *Gui) GenerateSentinelErrors() { - gui.Errors = SentinelErrors{ - ErrSubProcess: errors.New(gui.Tr.RunningSubprocess), - ErrNoFiles: errors.New(gui.Tr.NoChangedFiles), - ErrSwitchRepo: errors.New("switching repo"), - ErrRestart: errors.New("restarting"), - } -} - -func (gui *Gui) sentinelErrorsArr() []error { - return []error{ - gui.Errors.ErrSubProcess, - gui.Errors.ErrNoFiles, - gui.Errors.ErrSwitchRepo, - gui.Errors.ErrRestart, - } -} - // Gui wraps the gocui Gui object which handles rendering and events type Gui struct { g *gocui.Gui @@ -151,7 +116,7 @@ type lBlPanelState struct { LastLineIdx int Diff string PatchParser *patch.PatchParser - SelectMode int // one of LINE, HUNK, or RANGE + SelectMode SelectMode SecondaryFocused bool // this is for if we show the left or right panel } @@ -255,8 +220,10 @@ type searchingState struct { } // startup stages so we don't need to load everything at once +type StartupStage int + const ( - INITIAL = iota + INITIAL StartupStage = iota COMPLETE ) @@ -331,13 +298,13 @@ type guiState struct { RetainOriginalDir bool IsRefreshingFiles bool Searching searchingState - ScreenMode int + ScreenMode WindowMaximisation SideView *gocui.View Ptmx *os.File PrevMainWidth int PrevMainHeight int OldInformation string - StartupStage int // one of INITIAL and COMPLETE. Allows us to not load everything at once + StartupStage StartupStage // Allows us to not load everything at once Modes Modes diff --git a/pkg/gui/line_by_line_panel.go b/pkg/gui/line_by_line_panel.go index 230e9027e..4f35aa499 100644 --- a/pkg/gui/line_by_line_panel.go +++ b/pkg/gui/line_by_line_panel.go @@ -16,8 +16,10 @@ import ( // use cases // these represent what select mode we're in +type SelectMode int + const ( - LINE = iota + LINE SelectMode = iota RANGE HUNK ) diff --git a/pkg/gui/list_context.go b/pkg/gui/list_context.go index 2bbcaee55..39fa8f6bf 100644 --- a/pkg/gui/list_context.go +++ b/pkg/gui/list_context.go @@ -23,7 +23,7 @@ type ListContext struct { Gui *Gui ResetMainViewOriginOnFocus bool - Kind int + Kind ContextKind ParentContext Context // we can't know on the calling end whether a Context is actually a nil value without reflection, so we're storing this flag here to tell us. There has got to be a better way around this. hasParent bool @@ -102,7 +102,7 @@ func (lc *ListContext) GetKey() string { return lc.ContextKey } -func (lc *ListContext) GetKind() int { +func (lc *ListContext) GetKind() ContextKind { return lc.Kind } diff --git a/pkg/gui/main_panels.go b/pkg/gui/main_panels.go index b0098f5e9..8a34ddfa5 100644 --- a/pkg/gui/main_panels.go +++ b/pkg/gui/main_panels.go @@ -20,8 +20,10 @@ type refreshMainOpts struct { } // constants for updateTask's kind field +type TaskKind int + const ( - RENDER_STRING = iota + RENDER_STRING TaskKind = iota RENDER_STRING_WITHOUT_SCROLL RUN_FUNCTION RUN_COMMAND @@ -29,14 +31,14 @@ const ( ) type updateTask interface { - GetKind() int + GetKind() TaskKind } type renderStringTask struct { str string } -func (t *renderStringTask) GetKind() int { +func (t *renderStringTask) GetKind() TaskKind { return RENDER_STRING } @@ -48,7 +50,7 @@ type renderStringWithoutScrollTask struct { str string } -func (t *renderStringWithoutScrollTask) GetKind() int { +func (t *renderStringWithoutScrollTask) GetKind() TaskKind { return RENDER_STRING_WITHOUT_SCROLL } @@ -61,7 +63,7 @@ type runCommandTask struct { prefix string } -func (t *runCommandTask) GetKind() int { +func (t *runCommandTask) GetKind() TaskKind { return RUN_COMMAND } @@ -78,7 +80,7 @@ type runPtyTask struct { prefix string } -func (t *runPtyTask) GetKind() int { +func (t *runPtyTask) GetKind() TaskKind { return RUN_PTY } @@ -95,7 +97,7 @@ type runFunctionTask struct { f func(chan struct{}) error } -func (t *runFunctionTask) GetKind() int { +func (t *runFunctionTask) GetKind() TaskKind { return RUN_FUNCTION } diff --git a/pkg/gui/merge_panel.go b/pkg/gui/merge_panel.go index 60ce4d560..5ae0ec9b6 100644 --- a/pkg/gui/merge_panel.go +++ b/pkg/gui/merge_panel.go @@ -303,7 +303,7 @@ func (gui *Gui) handleEscapeMerge() error { gui.takeOverScrolling() gui.State.Panels.Merging.EditHistory = stack.New() - if err := gui.refreshSidePanels(refreshOptions{scope: []int{FILES}}); err != nil { + if err := gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{FILES}}); err != nil { return err } // it's possible this method won't be called from the merging view so we need to @@ -318,7 +318,7 @@ func (gui *Gui) handleCompleteMerge() error { if err := gui.stageSelectedFile(); err != nil { return err } - if err := gui.refreshSidePanels(refreshOptions{scope: []int{FILES}}); err != nil { + if err := gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{FILES}}); err != nil { return err } // if we got conflicts after unstashing, we don't want to call any git diff --git a/pkg/gui/remote_branches_panel.go b/pkg/gui/remote_branches_panel.go index 68d5b50ff..a2363b491 100644 --- a/pkg/gui/remote_branches_panel.go +++ b/pkg/gui/remote_branches_panel.go @@ -63,7 +63,7 @@ func (gui *Gui) handleDeleteRemoteBranch(g *gocui.Gui, v *gocui.View) error { err := gui.GitCommand.DeleteRemoteBranch(remoteBranch.RemoteName, remoteBranch.Name, gui.promptUserForCredential) gui.handleCredentialsPopup(err) - return gui.refreshSidePanels(refreshOptions{scope: []int{BRANCHES, REMOTES}}) + return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{BRANCHES, REMOTES}}) }) }, }) @@ -94,7 +94,7 @@ func (gui *Gui) handleSetBranchUpstream(g *gocui.Gui, v *gocui.View) error { return err } - return gui.refreshSidePanels(refreshOptions{scope: []int{BRANCHES, REMOTES}}) + return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{BRANCHES, REMOTES}}) }, }) } diff --git a/pkg/gui/remotes_panel.go b/pkg/gui/remotes_panel.go index 2426c817a..d99bcbb08 100644 --- a/pkg/gui/remotes_panel.go +++ b/pkg/gui/remotes_panel.go @@ -94,7 +94,7 @@ func (gui *Gui) handleAddRemote(g *gocui.Gui, v *gocui.View) error { if err := gui.GitCommand.AddRemote(remoteName, remoteUrl); err != nil { return err } - return gui.refreshSidePanels(refreshOptions{scope: []int{REMOTES}}) + return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{REMOTES}}) }, }) }, @@ -116,7 +116,7 @@ func (gui *Gui) handleRemoveRemote(g *gocui.Gui, v *gocui.View) error { return gui.surfaceError(err) } - return gui.refreshSidePanels(refreshOptions{scope: []int{BRA |