aboutsummaryrefslogtreecommitdiffstats
path: root/termui/label_select.go
diff options
context:
space:
mode:
authorLuke Adams <lukeclydeadams@gmail.com>2018-10-16 15:27:07 -0600
committerLuke Adams <lukeclydeadams@gmail.com>2018-10-16 15:27:07 -0600
commit4cb43815d01332e566f53988b5c2333ed63da5a7 (patch)
treef1d4f45223a078818ad43467f35707eba3a99e27 /termui/label_select.go
parent803fc6a8d0e09b8b918b9ca5b7963672d8b13517 (diff)
downloadgit-bug-4cb43815d01332e566f53988b5c2333ed63da5a7.tar.gz
Fix label select scrolling
This also sort of breaks the focus-on-add mechanism, but I can't think of a good way to implement it.
Diffstat (limited to 'termui/label_select.go')
-rw-r--r--termui/label_select.go37
1 files changed, 6 insertions, 31 deletions
diff --git a/termui/label_select.go b/termui/label_select.go
index c4bf833d..b5a91d9f 100644
--- a/termui/label_select.go
+++ b/termui/label_select.go
@@ -5,7 +5,6 @@ import (
"github.com/jroimartin/gocui"
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/util/colors"
)
const labelSelectView = "labelSelectView"
const labelSelectInstructionsView = "labelSelectInstructionsView"
@@ -101,21 +100,9 @@ func (ls *labelSelect) layout(g *gocui.Gui) error {
}
width += 10
x0 := 1
- y0 := 2 - ls.scroll
+ y0 := 0 - ls.scroll
- v, err := g.SetView("labelTitleView", x0, 0, x0 + width, 2)
- if err != nil {
- if err != gocui.ErrUnknownView {
- return err
- }
-
- v.Frame = false
- }
- ls.childViews = append(ls.childViews, "labelTitleView")
- v.Clear()
- fmt.Fprint(v, " ", colors.Bold("Add Labels"))
-
- v, err = g.SetView(labelSelectView, x0, 2, x0+width, maxY-2)
+ v, err := g.SetView(labelSelectView, x0, 0, x0+width, maxY-2)
if err != nil {
if err != gocui.ErrUnknownView {
return err
@@ -151,7 +138,7 @@ func (ls *labelSelect) layout(g *gocui.Gui) error {
v.BgColor = gocui.ColorBlue
}
v.Clear()
- fmt.Fprint(v, "[q] Save and close [↓↑,jk] Nav [a] Add item")
+ fmt.Fprint(v, "[q] Save and close [↓↑,jk] Nav [a] Add item", " - ", ls.scroll, " - ", ls.selected)
if _, err = g.SetViewOnTop(labelSelectInstructionsView); err != nil {
return err
}
@@ -242,32 +229,20 @@ func (ls *labelSelect) addItem(g *gocui.Gui, v *gocui.View) error {
ls.labelSelect[i] = true
ls.selected = i
- if err := ls.focusView(g); err != nil {
- panic(err)
- }
-
g.Update(func(gui *gocui.Gui) error {
- return nil
+ return ls.focusView(g)
})
return
}
}
- // Add new label, make it selected, and move frame
+ // Add new label, make it selected, and focus
ls.labels = append(ls.labels, bug.Label(input))
ls.labelSelect = append(ls.labelSelect, true)
ls.selected = len(ls.labels) - 1
- if err := ls.layout(g); err != nil {
- panic(err)
- }
-
- if err := ls.focusView(g); err != nil {
- panic(err)
- }
-
- g.Update(func(gui *gocui.Gui) error {
+ g.Update(func(g *gocui.Gui) error {
return nil
})
}()