func prevView(g *gocui.Gui, v *gocui.View) error { curView = getCurrentChannelIndex() next := curView - 1 if next < 0 { next = len(Server.Channels) - 1 } logger.Logger.Printf("PREV INDEX %d\n", next) if newView, err := g.View(Server.Channels[next].Name); err != nil { return err } else { newView.Autoscroll = true g.SetViewOnTop(newView.Name()) g.SetViewOnTop("header") } if _, err := g.SetCurrentView(Server.Channels[next].Name); err != nil { return err } // logger.Logger.Printf("Set Current View %d\n", Server.Channels[next].Name) Server.CurrentChannel = Server.Channels[next].Name Server.Channels[next].Unread = false ui.UpdateMenuView(g) FocusInputView(g, v) curView = next return nil }
func reloadMenu(g *gocui.Gui) error { v, err := g.View("menu") if err != nil { return err } v.Clear() PrintMenu(v) if cmdMode { prefix := fmt.Sprintf(cmdPrefix, cTubes.Selected) if err = v.SetCursor(len(prefix), 0); err != nil { return err } } _, err = g.SetViewOnTop("menu") return err }
func keybindings(g *gocui.Gui) error { err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, func(g *gocui.Gui, v *gocui.View) error { return gocui.ErrQuit }) if err != nil { return err } err = g.SetKeybinding("", '1', gocui.ModNone, func(g *gocui.Gui, v *gocui.View) error { _, err := g.SetViewOnTop("v1") return err }) if err != nil { return err } err = g.SetKeybinding("", '2', gocui.ModNone, func(g *gocui.Gui, v *gocui.View) error { _, err := g.SetViewOnTop("v2") return err }) if err != nil { return err } err = g.SetKeybinding("", '3', gocui.ModNone, func(g *gocui.Gui, v *gocui.View) error { _, err := g.SetViewOnTop("v3") return err }) if err != nil { return err } return nil }
func UpdateHeaderView(g *gocui.Gui) { Server.Exec("header", func(g *gocui.Gui, v *gocui.View, s *client.Server) error { v.Clear() v.SetCursor(0, 0) g.SetViewOnTop(v.Name()) channel := Server.GetCurrentChannel() if channel.Name != client.StatusChannel { if len(channel.Name) <= 0 { fmt.Fprintf(v, "⣿ %s", "Loading...") } else { fmt.Fprintf(v, "⣿ %s", channel.Topic) } } else if channel.Name == client.StatusChannel { fmt.Fprintf(v, "⣿ %s", client.StatusChannel) } else { fmt.Fprintf(v, "⣿ %s", "Loading...") } return nil }) }
func setCurrentViewOnTop(g *gocui.Gui, name string) (*gocui.View, error) { if _, err := g.SetCurrentView(name); err != nil { return nil, err } return g.SetViewOnTop(name) }
func ontop(g *gocui.Gui, v *gocui.View) error { _, err := g.SetViewOnTop(views[curView]) return err }