summaryrefslogtreecommitdiffstats
path: root/pkg/gui/files_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-02-14 22:07:56 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-02-15 08:47:36 +1100
commit814a0ea36f9f2e2d438ccb43a76402fe0479421b (patch)
treeaf332966e36e807f10242b5a6a05a0e8ceb0ac28 /pkg/gui/files_panel.go
parent71e018a3dd01af4cb12c18b2e73ed34d6ce3b010 (diff)
begin refactor of menu panel
Diffstat (limited to 'pkg/gui/files_panel.go')
-rw-r--r--pkg/gui/files_panel.go61
1 files changed, 0 insertions, 61 deletions
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go
index d7a5466cb..c2f3b9206 100644
--- a/pkg/gui/files_panel.go
+++ b/pkg/gui/files_panel.go
@@ -540,67 +540,6 @@ func (gui *Gui) anyFilesWithMergeConflicts() bool {
return false
}
-type discardOption struct {
- handler func(fileName *commands.File) error
- description string
-}
-
-// GetDisplayStrings is a function.
-func (r *discardOption) GetDisplayStrings(isFocused bool) []string {
- return []string{r.description}
-}
-
-func (gui *Gui) handleCreateDiscardMenu(g *gocui.Gui, v *gocui.View) error {
- file, err := gui.getSelectedFile(g)
- if err != nil {
- if err != gui.Errors.ErrNoFiles {
- return err
- }
- return nil
- }
-
- options := []*discardOption{
- {
- description: gui.Tr.SLocalize("discardAllChanges"),
- handler: func(file *commands.File) error {
- return gui.GitCommand.DiscardAllFileChanges(file)
- },
- },
- {
- description: gui.Tr.SLocalize("cancel"),
- handler: func(file *commands.File) error {
- return nil
- },
- },
- }
-
- if file.HasStagedChanges && file.HasUnstagedChanges {
- discardUnstagedChanges := &discardOption{
- description: gui.Tr.SLocalize("discardUnstagedChanges"),
- handler: func(file *commands.File) error {
- return gui.GitCommand.DiscardUnstagedFileChanges(file)
- },
- }
-
- options = append(options[:1], append([]*discardOption{discardUnstagedChanges}, options[1:]...)...)
- }
-
- handleMenuPress := func(index int) error {
- file, err := gui.getSelectedFile(g)
- if err != nil {
- return err
- }
-
- if err := options[index].handler(file); err != nil {
- return err
- }
-
- return gui.refreshFiles()
- }
-
- return gui.createMenu(file.Name, options, len(options), handleMenuPress)
-}
-
func (gui *Gui) handleCustomCommand(g *gocui.Gui, v *gocui.View) error {
return gui.createPromptPanel(g, v, gui.Tr.SLocalize("CustomCommand"), "", func(g *gocui.Gui, v *gocui.View) error {
command := gui.trimmedContent(v)