|
|
|
@ -7,7 +7,7 @@ import (
@@ -7,7 +7,7 @@ import (
|
|
|
|
|
"strings" |
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
"github.com/jroimartin/gocui" |
|
|
|
|
"github.com/awesome-gocui/gocui" |
|
|
|
|
"samhofi.us/x/keybase" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -28,13 +28,13 @@ func main() {
@@ -28,13 +28,13 @@ func main() {
|
|
|
|
|
fmt.Println("You are not logged in.") |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
kbtui, err := gocui.NewGui(gocui.OutputNormal) |
|
|
|
|
var err error |
|
|
|
|
g, err = gocui.NewGui(gocui.OutputNormal, false) |
|
|
|
|
if err != nil { |
|
|
|
|
log.Printf("%+v", err) |
|
|
|
|
fmt.Printf("%+v", err) |
|
|
|
|
} |
|
|
|
|
defer kbtui.Close() |
|
|
|
|
kbtui.SetManagerFunc(layout) |
|
|
|
|
g = kbtui |
|
|
|
|
defer g.Close() |
|
|
|
|
g.SetManagerFunc(layout) |
|
|
|
|
go populateList() |
|
|
|
|
go updateChatWindow() |
|
|
|
|
if len(os.Args) > 1 { |
|
|
|
@ -42,11 +42,12 @@ func main() {
@@ -42,11 +42,12 @@ func main() {
|
|
|
|
|
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) |
|
|
|
|
if err := g.MainLoop(); err != nil && !gocui.IsQuit(err) { |
|
|
|
|
fmt.Printf("%+v", err) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -230,16 +231,16 @@ func printToView(viewName string, message string) {
@@ -230,16 +231,16 @@ func printToView(viewName string, message string) {
|
|
|
|
|
|
|
|
|
|
func layout(g *gocui.Gui) error { |
|
|
|
|
maxX, maxY := g.Size() |
|
|
|
|
if editView, err := g.SetView("Edit", maxX/2-maxX/3+1, maxY/2, maxX-2, maxY/2+10); err != nil { |
|
|
|
|
if err != gocui.ErrUnknownView { |
|
|
|
|
if editView, err := g.SetView("Edit", maxX/2-maxX/3+1, maxY/2, maxX-2, maxY/2+10, 0); err != nil { |
|
|
|
|
if !gocui.IsUnknownView(err) { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
editView.Editable = true |
|
|
|
|
editView.Wrap = true |
|
|
|
|
fmt.Fprintln(editView, "Edit window. Should disappear") |
|
|
|
|
} |
|
|
|
|
if feedView, err := g.SetView("Feed", maxX/2-maxX/3, 0, maxX-1, maxY/5); err != nil { |
|
|
|
|
if err != gocui.ErrUnknownView { |
|
|
|
|
if feedView, err := g.SetView("Feed", maxX/2-maxX/3, 0, maxX-1, maxY/5, 0); err != nil { |
|
|
|
|
if !gocui.IsUnknownView(err) { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
feedView.Autoscroll = true |
|
|
|
@ -247,8 +248,8 @@ func layout(g *gocui.Gui) error {
@@ -247,8 +248,8 @@ func layout(g *gocui.Gui) error {
|
|
|
|
|
feedView.Title = "Feed Window" |
|
|
|
|
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 err2 != gocui.ErrUnknownView { |
|
|
|
|
if chatView, err2 := g.SetView("Chat", maxX/2-maxX/3, maxY/5+1, maxX-1, maxY-5, 0); err2 != nil { |
|
|
|
|
if !gocui.IsUnknownView(err2) { |
|
|
|
|
return err2 |
|
|
|
|
} |
|
|
|
|
chatView.Autoscroll = true |
|
|
|
@ -256,8 +257,8 @@ func layout(g *gocui.Gui) error {
@@ -256,8 +257,8 @@ 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 err3 != gocui.ErrUnknownView { |
|
|
|
|
if inputView, err3 := g.SetView("Input", maxX/2-maxX/3, maxY-4, maxX-1, maxY-1, 0); err3 != nil { |
|
|
|
|
if !gocui.IsUnknownView(err3) { |
|
|
|
|
return err3 |
|
|
|
|
} |
|
|
|
|
if _, err := g.SetCurrentView("Input"); err != nil { |
|
|
|
@ -268,8 +269,8 @@ func layout(g *gocui.Gui) error {
@@ -268,8 +269,8 @@ func layout(g *gocui.Gui) error {
|
|
|
|
|
inputView.Title = " Not in a chat /j to join" |
|
|
|
|
g.Cursor = true |
|
|
|
|
} |
|
|
|
|
if listView, err4 := g.SetView("List", 0, 0, maxX/2-maxX/3-1, maxY-1); err4 != nil { |
|
|
|
|
if err4 != gocui.ErrUnknownView { |
|
|
|
|
if listView, err4 := g.SetView("List", 0, 0, maxX/2-maxX/3-1, maxY-1, 0); err4 != nil { |
|
|
|
|
if !gocui.IsUnknownView(err4) { |
|
|
|
|
return err4 |
|
|
|
|
} |
|
|
|
|
listView.Title = "Channels" |
|
|
|
@ -277,6 +278,27 @@ func layout(g *gocui.Gui) error {
@@ -277,6 +278,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 !gocui.IsUnknownView(err) { |
|
|
|
|
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 !gocui.IsUnknownView(err2) { |
|
|
|
|
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(viewName string) (string, error) { |
|
|
|
|
inputView, _ := g.View(viewName) |
|
|
|
|