diff options
author | Michael Muré <batolettre@gmail.com> | 2018-10-03 12:51:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-03 12:51:12 +0200 |
commit | 61f16ce15a8d5865675294550f655bada3a5ea53 (patch) | |
tree | add0b95760bb62d18487a3fe4dd941bdc80e2f6a | |
parent | b5025a51a2da8e2a3be86ae3b1ece21d5fc0f789 (diff) | |
parent | 6698acd8cecd81ae7f6cfbd9bc26153d4e7f8b88 (diff) | |
download | git-bug-61f16ce15a8d5865675294550f655bada3a5ea53.tar.gz |
Merge pull request #57 from adamslc/openclose
termui: add the ability to open/close in bug view
-rw-r--r-- | termui/show_bug.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/termui/show_bug.go b/termui/show_bug.go index 32bea95a..4ca987bd 100644 --- a/termui/show_bug.go +++ b/termui/show_bug.go @@ -99,7 +99,7 @@ func (sb *showBug) layout(g *gocui.Gui) error { if sb.isOnSide { fmt.Fprint(v, "[a] Add label [r] Remove label") } else { - fmt.Fprint(v, "[c] Comment [t] Change title") + fmt.Fprint(v, "[o] Toggle open/close [c] Comment [t] Change title") } _, err = g.SetViewOnTop(showBugInstructionView) @@ -171,6 +171,12 @@ func (sb *showBug) keybindings(g *gocui.Gui) error { return err } + // Open/close + if err := g.SetKeybinding(showBugView, 'o', gocui.ModNone, + sb.toggleOpenClose); err != nil { + return err + } + // Title if err := g.SetKeybinding(showBugView, 't', gocui.ModNone, sb.setTitle); err != nil { @@ -603,6 +609,17 @@ func (sb *showBug) setTitle(g *gocui.Gui, v *gocui.View) error { return setTitleWithEditor(sb.bug) } +func (sb *showBug) toggleOpenClose(g *gocui.Gui, v *gocui.View) error { + switch sb.bug.Snapshot().Status { + case bug.OpenStatus: + return sb.bug.Close() + case bug.ClosedStatus: + return sb.bug.Open() + default: + return nil + } +} + func (sb *showBug) addLabel(g *gocui.Gui, v *gocui.View) error { c := ui.inputPopup.Activate("Add labels") |