From ba07cb6773791956123fa752f5c4613cdefe322f Mon Sep 17 00:00:00 2001 From: Gregory Rudolph Date: Wed, 9 Oct 2019 08:55:20 -0400 Subject: [PATCH 1/3] Changes to main for debugging awesome-gocui --- main.go | 57 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/main.go b/main.go index 98adadf..8d96c2b 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "github.com/jroimartin/gocui" + "github.com/awesome-gocui/gocui" "samhofi.us/x/keybase" ) @@ -24,29 +24,39 @@ var lastMessage keybase.ChatAPI var g *gocui.Gui func main() { + fmt.Println("Checking login") if !k.LoggedIn { fmt.Println("You are not logged in.") return } - kbtui, err := gocui.NewGui(gocui.OutputNormal) + fmt.Println("Creating err") + var err error + fmt.Println("creating kbtui") + g, err = gocui.NewGui(gocui.OutputNormal, false) if err != nil { - log.Printf("%+v", err) + fmt.Println("Err wasn't nil") + fmt.Printf("%+v", err) } - defer kbtui.Close() - kbtui.SetManagerFunc(layout) - g = kbtui + fmt.Println("defer g.Close()") + defer g.Close() + fmt.Println("SetManagerFunc") + g.SetManagerFunc(layout) + fmt.Println("Population") go populateList() go updateChatWindow() + fmt.Println("Args") if len(os.Args) > 1 { os.Args[0] = "join" RunCommand(os.Args...) } + fmt.Println("initKeybindings") if err := initKeybindings(); err != nil { - log.Printf("%+v", err) + fmt.Printf("%+v", err) } - if err := kbtui.MainLoop(); err != nil && err != gocui.ErrQuit { - log.Printf("%+v", err) + fmt.Println("Mainloop start") + if err := g.MainLoop(); err != nil && !gocui.IsQuit(err) { + fmt.Printf("%+v", err) } } func populateChat() { @@ -196,7 +206,7 @@ func printToView(viewName string, message string) { func layout(g *gocui.Gui) error { maxX, maxY := g.Size() - if feedView, err := g.SetView("Feed", maxX/2-maxX/3, 0, maxX-1, maxY/5); err != nil { + if feedView, err := g.SetView("Feed", maxX/2-maxX/3, 0, maxX-1, maxY/5, 0); err != nil { if err != gocui.ErrUnknownView { return err } @@ -204,7 +214,7 @@ func layout(g *gocui.Gui) error { feedView.Wrap = true fmt.Fprintln(feedView, "Feed Window - If you are mentioned or receive a PM it will show here") } - if chatView, err2 := g.SetView("Chat", maxX/2-maxX/3, maxY/5+1, maxX-1, maxY-5); err2 != nil { + if chatView, err2 := g.SetView("Chat", maxX/2-maxX/3, maxY/5+1, maxX-1, maxY-5, 0); err2 != nil { if err2 != gocui.ErrUnknownView { return err2 } @@ -213,7 +223,7 @@ func layout(g *gocui.Gui) error { fmt.Fprintf(chatView, "Welcome %s!\n\nYour chats will appear here.\nSupported commands are as follows:\n\n", k.Username) RunCommand("help") } - if inputView, err3 := g.SetView("Input", maxX/2-maxX/3, maxY-4, maxX-1, maxY-1); err3 != nil { + if inputView, err3 := g.SetView("Input", maxX/2-maxX/3, maxY-4, maxX-1, maxY-1, 0); err3 != nil { if err3 != gocui.ErrUnknownView { return err3 } @@ -224,7 +234,7 @@ func layout(g *gocui.Gui) error { inputView.Wrap = true g.Cursor = true } - if listView, err4 := g.SetView("List", 0, 0, maxX/2-maxX/3-1, maxY-1); err4 != nil { + if listView, err4 := g.SetView("List", 0, 0, maxX/2-maxX/3-1, maxY-1, 0); err4 != nil { if err4 != gocui.ErrUnknownView { return err4 } @@ -232,6 +242,27 @@ func layout(g *gocui.Gui) error { } return nil } +func layout2(g *gocui.Gui) error { + maxX, maxY := g.Size() + if feedView, err := g.SetView("Feed2", maxX/2-maxX/3, 0, maxX-1, maxY/5, 0); err != nil { + if err != gocui.ErrUnknownView { + return err + } + feedView.Autoscroll = true + feedView.Wrap = true + fmt.Fprintln(feedView, "Feed Window - If you are mentioned or receive a PM it will show here") + } + if chatView, err2 := g.SetView("Chat2", maxX/2-maxX/3, maxY/5+1, maxX-1, maxY-5, 0); err2 != nil { + if err2 != gocui.ErrUnknownView { + return err2 + } + chatView.Autoscroll = true + chatView.Wrap = true + fmt.Fprintf(chatView, "Welcome %s!\n\nYour chats will appear here.\nSupported commands are as follows:\n\n", k.Username) + RunCommand("help") + } + return nil +} func getInputString() (string, error) { inputView, _ := g.View("Input") From 3abf2e023585ab60a383e5e083e056b5bdbb3789 Mon Sep 17 00:00:00 2001 From: Gregory Rudolph Date: Wed, 9 Oct 2019 08:55:33 -0400 Subject: [PATCH 2/3] Import awesome-gocui --- cmdEdit.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmdEdit.go b/cmdEdit.go index dbfc766..66d370f 100644 --- a/cmdEdit.go +++ b/cmdEdit.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/jroimartin/gocui" + "github.com/awesome-gocui/gocui" ) func init() { From 7552d2bbbed2ab65f2b686fce40ff2284eb9caa9 Mon Sep 17 00:00:00 2001 From: mjarkk Date: Wed, 9 Oct 2019 20:18:33 +0200 Subject: [PATCH 3/3] Changed the unknown view check --- main.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 8d96c2b..742f934 100644 --- a/main.go +++ b/main.go @@ -207,7 +207,7 @@ func printToView(viewName string, message string) { func layout(g *gocui.Gui) error { maxX, maxY := g.Size() if feedView, err := g.SetView("Feed", maxX/2-maxX/3, 0, maxX-1, maxY/5, 0); err != nil { - if err != gocui.ErrUnknownView { + if !gocui.IsUnknownView(err) { return err } feedView.Autoscroll = true @@ -215,7 +215,7 @@ func layout(g *gocui.Gui) error { fmt.Fprintln(feedView, "Feed Window - If you are mentioned or receive a PM it will show here") } if chatView, err2 := g.SetView("Chat", maxX/2-maxX/3, maxY/5+1, maxX-1, maxY-5, 0); err2 != nil { - if err2 != gocui.ErrUnknownView { + if !gocui.IsUnknownView(err2) { return err2 } chatView.Autoscroll = true @@ -224,7 +224,7 @@ func layout(g *gocui.Gui) error { RunCommand("help") } if inputView, err3 := g.SetView("Input", maxX/2-maxX/3, maxY-4, maxX-1, maxY-1, 0); err3 != nil { - if err3 != gocui.ErrUnknownView { + if !gocui.IsUnknownView(err3) { return err3 } if _, err := g.SetCurrentView("Input"); err != nil { @@ -235,7 +235,7 @@ func layout(g *gocui.Gui) error { g.Cursor = true } if listView, err4 := g.SetView("List", 0, 0, maxX/2-maxX/3-1, maxY-1, 0); err4 != nil { - if err4 != gocui.ErrUnknownView { + if !gocui.IsUnknownView(err4) { return err4 } fmt.Fprintf(listView, "Lists\nWindow\nTo view\n activity") @@ -245,7 +245,7 @@ func layout(g *gocui.Gui) error { func layout2(g *gocui.Gui) error { maxX, maxY := g.Size() if feedView, err := g.SetView("Feed2", maxX/2-maxX/3, 0, maxX-1, maxY/5, 0); err != nil { - if err != gocui.ErrUnknownView { + if !gocui.IsUnknownView(err) { return err } feedView.Autoscroll = true @@ -253,7 +253,7 @@ func layout2(g *gocui.Gui) error { fmt.Fprintln(feedView, "Feed Window - If you are mentioned or receive a PM it will show here") } if chatView, err2 := g.SetView("Chat2", maxX/2-maxX/3, maxY/5+1, maxX-1, maxY-5, 0); err2 != nil { - if err2 != gocui.ErrUnknownView { + if !gocui.IsUnknownView(err2) { return err2 } chatView.Autoscroll = true