aboutsummaryrefslogtreecommitdiffstats
path: root/termui
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-11-03 20:47:29 +0100
committerMichael Muré <batolettre@gmail.com>2019-11-03 20:47:29 +0100
commitcb8236c9c22007eb622b7219c58d3342f1f53d50 (patch)
treee232e5362486065d9b28bb55b9791690efb50c08 /termui
parent163ea9c93306c387f84ff0b85c2d8fca4c01e449 (diff)
downloadgit-bug-cb8236c9c22007eb622b7219c58d3342f1f53d50.tar.gz
termui: migrate to awesome-gocui instead of the old fork I had
Diffstat (limited to 'termui')
-rw-r--r--termui/bug_table.go26
-rw-r--r--termui/input_popup.go6
-rw-r--r--termui/label_select.go16
-rw-r--r--termui/msg_popup.go6
-rw-r--r--termui/show_bug.go24
-rw-r--r--termui/termui.go10
6 files changed, 46 insertions, 42 deletions
diff --git a/termui/bug_table.go b/termui/bug_table.go
index c432c94a..ee02a167 100644
--- a/termui/bug_table.go
+++ b/termui/bug_table.go
@@ -7,7 +7,7 @@ import (
"time"
"github.com/MichaelMure/go-term-text"
- "github.com/MichaelMure/gocui"
+ "github.com/awesome-gocui/gocui"
"github.com/dustin/go-humanize"
"github.com/MichaelMure/git-bug/cache"
@@ -56,10 +56,10 @@ func (bt *bugTable) layout(g *gocui.Gui) error {
return nil
}
- v, err := g.SetView(bugTableHeaderView, -1, -1, maxX, 3)
+ v, err := g.SetView(bugTableHeaderView, -1, -1, maxX, 3, 0)
if err != nil {
- if err != gocui.ErrUnknownView {
+ if !gocui.IsUnknownView(err) {
return err
}
@@ -69,10 +69,10 @@ func (bt *bugTable) layout(g *gocui.Gui) error {
v.Clear()
bt.renderHeader(v, maxX)
- v, err = g.SetView(bugTableView, -1, 1, maxX, maxY-3)
+ v, err = g.SetView(bugTableView, -1, 1, maxX, maxY-3, 0)
if err != nil {
- if err != gocui.ErrUnknownView {
+ if !gocui.IsUnknownView(err) {
return err
}
@@ -100,10 +100,10 @@ func (bt *bugTable) layout(g *gocui.Gui) error {
v.Clear()
bt.render(v, maxX)
- v, err = g.SetView(bugTableFooterView, -1, maxY-4, maxX, maxY)
+ v, err = g.SetView(bugTableFooterView, -1, maxY-4, maxX, maxY, 0)
if err != nil {
- if err != gocui.ErrUnknownView {
+ if !gocui.IsUnknownView(err) {
return err
}
@@ -113,10 +113,10 @@ func (bt *bugTable) layout(g *gocui.Gui) error {
v.Clear()
bt.renderFooter(v, maxX)
- v, err = g.SetView(bugTableInstructionView, -1, maxY-2, maxX, maxY)
+ v, err = g.SetView(bugTableInstructionView, -1, maxY-2, maxX, maxY, 0)
if err != nil {
- if err != gocui.ErrUnknownView {
+ if !gocui.IsUnknownView(err) {
return err
}
@@ -216,16 +216,16 @@ func (bt *bugTable) keybindings(g *gocui.Gui) error {
}
func (bt *bugTable) disable(g *gocui.Gui) error {
- if err := g.DeleteView(bugTableView); err != nil && err != gocui.ErrUnknownView {
+ if err := g.DeleteView(bugTableView); err != nil && !gocui.IsUnknownView(err) {
return err
}
- if err := g.DeleteView(bugTableHeaderView); err != nil && err != gocui.ErrUnknownView {
+ if err := g.DeleteView(bugTableHeaderView); err != nil && !gocui.IsUnknownView(err) {
return err
}
- if err := g.DeleteView(bugTableFooterView); err != nil && err != gocui.ErrUnknownView {
+ if err := g.DeleteView(bugTableFooterView); err != nil && !gocui.IsUnknownView(err) {
return err
}
- if err := g.DeleteView(bugTableInstructionView); err != nil && err != gocui.ErrUnknownView {
+ if err := g.DeleteView(bugTableInstructionView); err != nil && !gocui.IsUnknownView(err) {
return err
}
return nil
diff --git a/termui/input_popup.go b/termui/input_popup.go
index 3576ba2f..3ff9b5bf 100644
--- a/termui/input_popup.go
+++ b/termui/input_popup.go
@@ -3,7 +3,7 @@ package termui
import (
"io/ioutil"
- "github.com/MichaelMure/gocui"
+ "github.com/awesome-gocui/gocui"
)
const inputPopupView = "inputPopupView"
@@ -46,9 +46,9 @@ func (ip *inputPopup) layout(g *gocui.Gui) error {
x0 := (maxX - width) / 2
y0 := (maxY - height) / 2
- v, err := g.SetView(inputPopupView, x0, y0, x0+width, y0+height)
+ v, err := g.SetView(inputPopupView, x0, y0, x0+width, y0+height, 0)
if err != nil {
- if err != gocui.ErrUnknownView {
+ if !gocui.IsUnknownView(err) {
return err
}
diff --git a/termui/label_select.go b/termui/label_select.go
index 39edbdb1..a05d9c8b 100644
--- a/termui/label_select.go
+++ b/termui/label_select.go
@@ -4,7 +4,7 @@ import (
"fmt"
"strings"
- "github.com/MichaelMure/gocui"
+ "github.com/awesome-gocui/gocui"
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
@@ -106,9 +106,9 @@ func (ls *labelSelect) layout(g *gocui.Gui) error {
x0 := 1
y0 := 0 - ls.scroll
- v, err := g.SetView(labelSelectView, x0, 0, x0+width, maxY-2)
+ v, err := g.SetView(labelSelectView, x0, 0, x0+width, maxY-2, 0)
if err != nil {
- if err != gocui.ErrUnknownView {
+ if !gocui.IsUnknownView(err) {
return err
}
@@ -117,8 +117,8 @@ func (ls *labelSelect) layout(g *gocui.Gui) error {
for i, label := range ls.labels {
viewname := fmt.Sprintf("view%d", i)
- v, err := g.SetView(viewname, x0+2, y0, x0+width-2, y0+2)
- if err != nil && err != gocui.ErrUnknownView {
+ v, err := g.SetView(viewname, x0+2, y0, x0+width-2, y0+2, 0)
+ if err != nil && !gocui.IsUnknownView(err) {
return err
}
ls.childViews = append(ls.childViews, viewname)
@@ -137,10 +137,10 @@ func (ls *labelSelect) layout(g *gocui.Gui) error {
y0 += 2
}
- v, err = g.SetView(labelSelectInstructionsView, -1, maxY-2, maxX, maxY)
+ v, err = g.SetView(labelSelectInstructionsView, -1, maxY-2, maxX, maxY, 0)
ls.childViews = append(ls.childViews, labelSelectInstructionsView)
if err != nil {
- if err != gocui.ErrUnknownView {
+ if !gocui.IsUnknownView(err) {
return err
}
v.Frame = false
@@ -159,7 +159,7 @@ func (ls *labelSelect) layout(g *gocui.Gui) error {
func (ls *labelSelect) disable(g *gocui.Gui) error {
for _, view := range ls.childViews {
- if err := g.DeleteView(view); err != nil && err != gocui.ErrUnknownView {
+ if err := g.DeleteView(view); err != nil && !gocui.IsUnknownView(err) {
return err
}
}
diff --git a/termui/msg_popup.go b/termui/msg_popup.go
index 99180c99..236c16a2 100644
--- a/termui/msg_popup.go
+++ b/termui/msg_popup.go
@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/MichaelMure/go-term-text"
- "github.com/MichaelMure/gocui"
+ "github.com/awesome-gocui/gocui"
)
const msgPopupView = "msgPopupView"
@@ -50,9 +50,9 @@ func (ep *msgPopup) layout(g *gocui.Gui) error {
x0 := (maxX - width) / 2
y0 := (maxY - height) / 2
- v, err := g.SetView(msgPopupView, x0, y0, x0+width, y0+height)
+ v, err := g.SetView(msgPopupView, x0, y0, x0+width, y0+height, 0)
if err != nil {
- if err != gocui.ErrUnknownView {
+ if !gocui.IsUnknownView(err) {
return err
}
diff --git a/termui/show_bug.go b/termui/show_bug.go
index 50478b8f..6c7163ac 100644
--- a/termui/show_bug.go
+++ b/termui/show_bug.go
@@ -6,7 +6,7 @@ import (
"strings"
"github.com/MichaelMure/go-term-text"
- "github.com/MichaelMure/gocui"
+ "github.com/awesome-gocui/gocui"
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
@@ -49,10 +49,10 @@ func (sb *showBug) layout(g *gocui.Gui) error {
maxX, maxY := g.Size()
sb.childViews = nil
- v, err := g.SetView(showBugView, 0, 0, maxX*2/3, maxY-2)
+ v, err := g.SetView(showBugView, 0, 0, maxX*2/3, maxY-2, 0)
if err != nil {
- if err != gocui.ErrUnknownView {
+ if !gocui.IsUnknownView(err) {
return err
}
@@ -66,10 +66,10 @@ func (sb *showBug) layout(g *gocui.Gui) error {
return err
}
- v, err = g.SetView(showBugSidebarView, maxX*2/3+1, 0, maxX-1, maxY-2)
+ v, err = g.SetView(showBugSidebarView, maxX*2/3+1, 0, maxX-1, maxY-2, 0)
if err != nil {
- if err != gocui.ErrUnknownView {
+ if !gocui.IsUnknownView(err) {
return err
}
@@ -83,10 +83,10 @@ func (sb *showBug) layout(g *gocui.Gui) error {
return err
}
- v, err = g.SetView(showBugInstructionView, -1, maxY-2, maxX, maxY)
+ v, err = g.SetView(showBugInstructionView, -1, maxY-2, maxX, maxY, 0)
if err != nil {
- if err != gocui.ErrUnknownView {
+ if !gocui.IsUnknownView(err) {
return err
}
@@ -190,7 +190,7 @@ func (sb *showBug) keybindings(g *gocui.Gui) error {
func (sb *showBug) disable(g *gocui.Gui) error {
for _, view := range sb.childViews {
- if err := g.DeleteView(view); err != nil && err != gocui.ErrUnknownView {
+ if err := g.DeleteView(view); err != nil && !gocui.IsUnknownView(err) {
return err
}
}
@@ -383,9 +383,9 @@ func emptyMessagePlaceholder() string {
}
func (sb *showBug) createOpView(g *gocui.Gui, name string, x0 int, y0 int, maxX int, height int, selectable bool) (*gocui.View, error) {
- v, err := g.SetView(name, x0, y0, maxX, y0+height+1)
+ v, err := g.SetView(name, x0, y0, maxX, y0+height+1, 0)
- if err != nil && err != gocui.ErrUnknownView {
+ if err != nil && !gocui.IsUnknownView(err) {
return nil, err
}
@@ -403,9 +403,9 @@ func (sb *showBug) createOpView(g *gocui.Gui, name string, x0 int, y0 int, maxX
}
func (sb *showBug) createSideView(g *gocui.Gui, name string, x0 int, y0 int, maxX int, height int) (*gocui.View, error) {
- v, err := g.SetView(name, x0, y0, maxX, y0+height+1)
+ v, err := g.SetView(name, x0, y0, maxX, y0+height+1, 0)
- if err != nil && err != gocui.ErrUnknownView {
+ if err != nil && !gocui.IsUnknownView(err) {
return nil, err
}
diff --git a/termui/termui.go b/termui/termui.go
index 8aece020..67f91280 100644
--- a/termui/termui.go
+++ b/termui/termui.go
@@ -2,9 +2,13 @@
package termui
import (
- "github.com/MichaelMure/gocui"
+ "fmt"
+
+ "github.com/awesome-gocui/gocui"
"github.com/pkg/errors"
+ errors2 "github.com/go-errors/errors"
+
"github.com/MichaelMure/git-bug/cache"
"github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/input"
@@ -63,15 +67,15 @@ func Run(cache *cache.RepoCache) error {
err := <-ui.gError
if err != nil && err != gocui.ErrQuit {
+ fmt.Println(err.(*errors2.Error).ErrorStack())
return err
}
-
return nil
}
func initGui(action func(ui *termUI) error) {
- g, err := gocui.NewGui(gocui.Output256)
+ g, err := gocui.NewGui(gocui.Output256, false)
if err != nil {
ui.gError <- err