diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-02-25 07:17:49 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-02-25 07:19:46 +1100 |
commit | 52b5a6410c33557f754c4a6cd3ce0c69220dc780 (patch) | |
tree | aa4383636b5202bd03015693875d32dfba78798a /vendor | |
parent | 0034cfef5cb29937c8ac7daf65a5b5bfd1925331 (diff) |
show item counts in frames
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/github.com/jesseduffield/gocui/gui.go | 34 | ||||
-rw-r--r-- | vendor/github.com/jesseduffield/gocui/view.go | 3 | ||||
-rw-r--r-- | vendor/modules.txt | 2 |
3 files changed, 38 insertions, 1 deletions
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 |