Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions termui/bug_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ const bugTableInstructionView = "bugTableInstructionView"
const defaultRemote = "origin"
const defaultQuery = "status:open"

var bugTableHelp = helpBar{
{"q", "Quit"},
{"s", "Search"},
{"←↓↑→,hjkl", "Navigation"},
{"↵", "Open bug"},
{"n", "New bug"},
{"i", "Pull"},
{"o", "Push"},
}

type bugTable struct {
repo *cache.RepoCache
queryStr string
Expand Down Expand Up @@ -117,9 +127,8 @@ func (bt *bugTable) layout(g *gocui.Gui) error {

v.Frame = false
v.FgColor = gocui.ColorWhite
v.BgColor = gocui.ColorBlue

_, _ = fmt.Fprintf(v, "[q] Quit [s] Search [←↓↑→,hjkl] Navigation [↵] Open bug [n] New bug [i] Pull [o] Push")
_, _ = fmt.Fprint(v, bugTableHelp.Render(maxX))
}

_, err = g.SetCurrentView(bugTableView)
Expand Down
30 changes: 30 additions & 0 deletions termui/help_bar.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package termui

import (
"fmt"
"strings"

text "github.com/MichaelMure/go-term-text"

"github.com/MichaelMure/git-bug/util/colors"
)

type helpBar []struct {
keys string
text string
}

func (hb helpBar) Render(maxX int) string {
var builder strings.Builder
for _, entry := range hb {
builder.WriteString(colors.BlueBg(fmt.Sprintf("[%s] %s", entry.keys, entry.text)))
builder.WriteByte(' ')
}

l := text.Len(builder.String())
if l < maxX {
builder.WriteString(colors.BlueBg(strings.Repeat(" ", maxX-l)))
}

return builder.String()
}
11 changes: 8 additions & 3 deletions termui/label_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import (
const labelSelectView = "labelSelectView"
const labelSelectInstructionsView = "labelSelectInstructionsView"

var labelSelectHelp = helpBar{
{"q", "Save and close"},
{"↓↑,jk", "Nav"},
{"a", "Add item"},
}

type labelSelect struct {
cache *cache.RepoCache
bug *cache.BugCache
Expand Down Expand Up @@ -132,7 +138,7 @@ func (ls *labelSelect) layout(g *gocui.Gui) error {
lc := label.Color()
lc256 := lc.Term256()
labelStr := lc256.Escape() + "◼ " + lc256.Unescape() + label.String()
fmt.Fprint(v, selectBox, labelStr)
_, _ = fmt.Fprint(v, selectBox, labelStr)

y0 += 2
}
Expand All @@ -145,10 +151,9 @@ func (ls *labelSelect) layout(g *gocui.Gui) error {
}
v.Frame = false
v.FgColor = gocui.ColorWhite
v.BgColor = gocui.ColorBlue
}
v.Clear()
fmt.Fprint(v, "[q] Save and close [↓↑,jk] Nav [a] Add item")
_, _ = fmt.Fprint(v, labelSelectHelp.Render(maxX))
if _, err = g.SetViewOnTop(labelSelectInstructionsView); err != nil {
return err
}
Expand Down
12 changes: 10 additions & 2 deletions termui/show_bug.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ const showBugHeaderView = "showBugHeaderView"

const timeLayout = "Jan 2 2006"

var showBugHelp = helpBar{
{"q", "Save and return"},
{"←↓↑→,hjkl", "Navigation"},
{"o", "Toggle open/close"},
{"e", "Edit"},
{"c", "Comment"},
{"t", "Change title"},
}

type showBug struct {
cache *cache.RepoCache
bug *cache.BugCache
Expand Down Expand Up @@ -93,11 +102,10 @@ func (sb *showBug) layout(g *gocui.Gui) error {
sb.childViews = append(sb.childViews, showBugInstructionView)
v.Frame = false
v.FgColor = gocui.ColorWhite
v.BgColor = gocui.ColorBlue
}

v.Clear()
_, _ = fmt.Fprintf(v, "[q] Save and return [←↓↑→,hjkl] Navigation [o] Toggle open/close [e] Edit [c] Comment [t] Change title")
_, _ = fmt.Fprint(v, showBugHelp.Render(maxX))

_, err = g.SetViewOnTop(showBugInstructionView)
if err != nil {
Expand Down