mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-15 10:12:06 +03:00
termui: make the help visually easier to parse
This commit is contained in:
parent
88c28db998
commit
9ce84fc1a3
@ -23,6 +23,16 @@ const bugTableInstructionView = "bugTableInstructionView"
|
|||||||
const defaultRemote = "origin"
|
const defaultRemote = "origin"
|
||||||
const defaultQuery = "status:open"
|
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 {
|
type bugTable struct {
|
||||||
repo *cache.RepoCache
|
repo *cache.RepoCache
|
||||||
queryStr string
|
queryStr string
|
||||||
@ -117,9 +127,8 @@ func (bt *bugTable) layout(g *gocui.Gui) error {
|
|||||||
|
|
||||||
v.Frame = false
|
v.Frame = false
|
||||||
v.FgColor = gocui.ColorWhite
|
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())
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = g.SetCurrentView(bugTableView)
|
_, err = g.SetCurrentView(bugTableView)
|
||||||
|
24
termui/help_bar.go
Normal file
24
termui/help_bar.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package termui
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/MichaelMure/git-bug/util/colors"
|
||||||
|
)
|
||||||
|
|
||||||
|
type helpBar []struct {
|
||||||
|
keys string
|
||||||
|
text string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (hb helpBar) Render() string {
|
||||||
|
var builder strings.Builder
|
||||||
|
for i, entry := range hb {
|
||||||
|
if i != 0 {
|
||||||
|
builder.WriteByte(' ')
|
||||||
|
}
|
||||||
|
builder.WriteString(colors.BlueBg(fmt.Sprintf("[%s] %s", entry.keys, entry.text)))
|
||||||
|
}
|
||||||
|
return builder.String()
|
||||||
|
}
|
@ -13,6 +13,12 @@ import (
|
|||||||
const labelSelectView = "labelSelectView"
|
const labelSelectView = "labelSelectView"
|
||||||
const labelSelectInstructionsView = "labelSelectInstructionsView"
|
const labelSelectInstructionsView = "labelSelectInstructionsView"
|
||||||
|
|
||||||
|
var labelSelectHelp = helpBar{
|
||||||
|
{"q", "Save and close"},
|
||||||
|
{"↓↑,jk", "Nav"},
|
||||||
|
{"a", "Add item"},
|
||||||
|
}
|
||||||
|
|
||||||
type labelSelect struct {
|
type labelSelect struct {
|
||||||
cache *cache.RepoCache
|
cache *cache.RepoCache
|
||||||
bug *cache.BugCache
|
bug *cache.BugCache
|
||||||
@ -132,7 +138,7 @@ func (ls *labelSelect) layout(g *gocui.Gui) error {
|
|||||||
lc := label.Color()
|
lc := label.Color()
|
||||||
lc256 := lc.Term256()
|
lc256 := lc.Term256()
|
||||||
labelStr := lc256.Escape() + "◼ " + lc256.Unescape() + label.String()
|
labelStr := lc256.Escape() + "◼ " + lc256.Unescape() + label.String()
|
||||||
fmt.Fprint(v, selectBox, labelStr)
|
_, _ = fmt.Fprint(v, selectBox, labelStr)
|
||||||
|
|
||||||
y0 += 2
|
y0 += 2
|
||||||
}
|
}
|
||||||
@ -145,10 +151,9 @@ func (ls *labelSelect) layout(g *gocui.Gui) error {
|
|||||||
}
|
}
|
||||||
v.Frame = false
|
v.Frame = false
|
||||||
v.FgColor = gocui.ColorWhite
|
v.FgColor = gocui.ColorWhite
|
||||||
v.BgColor = gocui.ColorBlue
|
|
||||||
}
|
}
|
||||||
v.Clear()
|
v.Clear()
|
||||||
fmt.Fprint(v, "[q] Save and close [↓↑,jk] Nav [a] Add item")
|
_, _ = fmt.Fprint(v, labelSelectHelp.Render())
|
||||||
if _, err = g.SetViewOnTop(labelSelectInstructionsView); err != nil {
|
if _, err = g.SetViewOnTop(labelSelectInstructionsView); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,15 @@ const showBugHeaderView = "showBugHeaderView"
|
|||||||
|
|
||||||
const timeLayout = "Jan 2 2006"
|
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 {
|
type showBug struct {
|
||||||
cache *cache.RepoCache
|
cache *cache.RepoCache
|
||||||
bug *cache.BugCache
|
bug *cache.BugCache
|
||||||
@ -93,11 +102,10 @@ func (sb *showBug) layout(g *gocui.Gui) error {
|
|||||||
sb.childViews = append(sb.childViews, showBugInstructionView)
|
sb.childViews = append(sb.childViews, showBugInstructionView)
|
||||||
v.Frame = false
|
v.Frame = false
|
||||||
v.FgColor = gocui.ColorWhite
|
v.FgColor = gocui.ColorWhite
|
||||||
v.BgColor = gocui.ColorBlue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
v.Clear()
|
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())
|
||||||
|
|
||||||
_, err = g.SetViewOnTop(showBugInstructionView)
|
_, err = g.SetViewOnTop(showBugInstructionView)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user