diff --git a/go.mod b/go.mod index 85dbc1939..0b5aae9b8 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/golang/protobuf v1.3.2 // indirect github.com/google/go-cmp v0.3.1 // indirect github.com/integrii/flaggy v1.4.0 - github.com/jesseduffield/gocui v0.3.1-0.20200223105115-3e1f0f7c3efe + github.com/jesseduffield/gocui v0.3.1-0.20200224201655-5024a02682ed github.com/jesseduffield/pty v1.2.1 github.com/jesseduffield/rollrus v0.0.0-20190701125922-dd028cb0bfd7 // indirect github.com/jesseduffield/termbox-go v0.0.0-20200130214842-1d31d1faa3c9 // indirect diff --git a/go.sum b/go.sum index c88f65216..9d2b42318 100644 --- a/go.sum +++ b/go.sum @@ -89,6 +89,8 @@ github.com/jesseduffield/gocui v0.3.1-0.20200201013258-57fdcf23edc5 h1:tE0w3tuL/ github.com/jesseduffield/gocui v0.3.1-0.20200201013258-57fdcf23edc5/go.mod h1:2RtZznzYKt8RLRwvFiSkXjU0Ei8WwHdubgnlaYH47dw= github.com/jesseduffield/gocui v0.3.1-0.20200223105115-3e1f0f7c3efe h1:UQyebauOcBzbGq32kTXwEyuJaqp3BkI8JoCrGs2jijU= github.com/jesseduffield/gocui v0.3.1-0.20200223105115-3e1f0f7c3efe/go.mod h1:2RtZznzYKt8RLRwvFiSkXjU0Ei8WwHdubgnlaYH47dw= +github.com/jesseduffield/gocui v0.3.1-0.20200224201655-5024a02682ed h1:glGs+mzPZOl1iHiUsBW3918WeFwqsbQQ/jtLkkQXDi4= +github.com/jesseduffield/gocui v0.3.1-0.20200224201655-5024a02682ed/go.mod h1:2RtZznzYKt8RLRwvFiSkXjU0Ei8WwHdubgnlaYH47dw= github.com/jesseduffield/pty v1.2.1 h1:7xYBiwNH0PpWqC8JmvrPq1a/ksNqyCavzWu9pbBGYWI= github.com/jesseduffield/pty v1.2.1/go.mod h1:7jlS40+UhOqkZJDIG1B/H21xnuET/+fvbbnHCa8wSIo= github.com/jesseduffield/roll v0.0.0-20190629104057-695be2e62b00 h1:+JaOkfBNYQYlGD7dgru8mCwYNEc5tRRI8mThlVANhSM= diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 0090e6c92..0a0dbe204 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -555,6 +555,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { filesView.Highlight = true filesView.Title = gui.Tr.SLocalize("FilesTitle") filesView.SetOnSelectItem(gui.onSelectItemWrapper(gui.onFilesPanelSearchSelect)) + filesView.ContainsList = true } branchesView, err := g.SetViewBeneath("branches", "files", vHeights["branches"]) @@ -566,6 +567,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { branchesView.Tabs = []string{"Local Branches", "Remotes", "Tags"} branchesView.FgColor = textColor branchesView.SetOnSelectItem(gui.onSelectItemWrapper(gui.onBranchesPanelSearchSelect)) + branchesView.ContainsList = true } if v, err := g.SetViewBeneath("commitFiles", "branches", vHeights["commits"]); err != nil { @@ -586,6 +588,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { commitsView.Tabs = []string{"Commits", "Reflog"} commitsView.FgColor = textColor commitsView.SetOnSelectItem(gui.onSelectItemWrapper(gui.onCommitsPanelSearchSelect)) + commitsView.ContainsList = true } stashView, err := g.SetViewBeneath("stash", "commits", vHeights["stash"]) @@ -596,6 +599,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { stashView.Title = gui.Tr.SLocalize("StashTitle") stashView.FgColor = textColor stashView.SetOnSelectItem(gui.onSelectItemWrapper(gui.onStashPanelSearchSelect)) + stashView.ContainsList = true } if v, err := g.SetView("options", appStatusOptionsBoundary-1, height-2, optionsVersionBoundary-1, height, 0); err != nil { diff --git a/pkg/gui/menu_panel.go b/pkg/gui/menu_panel.go index 335b298b3..da511f6b2 100644 --- a/pkg/gui/menu_panel.go +++ b/pkg/gui/menu_panel.go @@ -76,6 +76,7 @@ func (gui *Gui) createMenu(title string, items []*menuItem, createMenuOptions cr menuView, _ := gui.g.SetView("menu", x0, y0, x1, y1, 0) menuView.Title = title menuView.FgColor = theme.GocuiDefaultTextColor + menuView.ContainsList = true menuView.Clear() fmt.Fprint(menuView, list) gui.State.Panels.Menu.SelectedLine = 0 diff --git a/vendor/github.com/jesseduffield/gocui/gui.go b/vendor/github.com/jesseduffield/gocui/gui.go index 93f7606b0..8ddacb5fa 100644 --- a/vendor/github.com/jesseduffield/gocui/gui.go +++ b/vendor/github.com/jesseduffield/gocui/gui.go @@ -6,6 +6,7 @@ package gocui import ( standardErrors "errors" + "fmt" "strings" "sync" "time" @@ -542,6 +543,11 @@ func (g *Gui) flush() error { return err } } + if v.ContainsList { + if err := g.drawListFooter(v, fgColor, bgColor); err != nil { + return err + } + } } if err := g.draw(v); err != nil { return err @@ -729,6 +735,34 @@ func (g *Gui) drawSubtitle(v *View, fgColor, bgColor Attribute) error { return nil } +// drawListFooter draws the footer of a list view, showing something like '1 of 10' +func (g *Gui) drawListFooter(v *View, fgColor, bgColor Attribute) error { + if len(v.lines) == 0 { + return nil + } + + message := fmt.Sprintf("%d of %d", v.cy+v.oy+1, len(v.lines)) + + if v.y1 < 0 || v.y1 >= g.maxY { + return nil + } + + start := v.x1 - 1 - len(message) + if start < v.x0 { + return nil + } + for i, ch := range message { + x := start + i + if x >= v.x1 { + break + } + if err := g.SetRune(x, v.y1, ch, fgColor, bgColor); err != nil { + return err + } + } + return nil +} + // draw manages the cursor and calls the draw function of a view. func (g *Gui) draw(v *View) error { if g.Cursor { diff --git a/vendor/github.com/jesseduffield/gocui/view.go b/vendor/github.com/jesseduffield/gocui/view.go index 1277e3c51..fb3b1e54d 100644 --- a/vendor/github.com/jesseduffield/gocui/view.go +++ b/vendor/github.com/jesseduffield/gocui/view.go @@ -107,6 +107,9 @@ type View struct { Context string // this is for assigning keybindings to a view only in certain contexts searcher *searcher + + // when ContainsList is true, we show the current index and total count in the view + ContainsList bool } type searcher struct { diff --git a/vendor/modules.txt b/vendor/modules.txt index b90da203a..7d0a7f51f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -32,7 +32,7 @@ github.com/hashicorp/hcl/json/token github.com/integrii/flaggy # github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 github.com/jbenet/go-context/io -# github.com/jesseduffield/gocui v0.3.1-0.20200223105115-3e1f0f7c3efe +# github.com/jesseduffield/gocui v0.3.1-0.20200224201655-5024a02682ed github.com/jesseduffield/gocui # github.com/jesseduffield/pty v1.2.1 github.com/jesseduffield/pty