func layout(g *gocui.Gui) error { maxX, maxY := g.Size() if v, err := g.SetView("contacts", 1, 1, 60, maxY-1); err != nil { if err != gocui.ErrorUnkView { return err } v.Highlight = true } if v, err := g.SetView("main", 60, 1, maxX-1, maxY-3); err != nil { if err != gocui.ErrorUnkView { return err } v.Wrap = true v.WrapPrefix = " " } if v, err := g.SetView("input", 60, maxY-3, maxX-1, maxY-1); err != nil { if err != gocui.ErrorUnkView { return err } v.Editable = true if err := g.SetCurrentView("input"); err != nil { return err } } return nil }
func MenuView(g *gocui.Gui, maxX, maxY int) error { if v, err := g.SetView("menu", -1, maxY-4, maxX, maxY+3); err != nil { if err != gocui.ErrUnknownView { return err } _, err := g.SetCurrentView("menu") if err != nil { return err } // v.FgColor = gocui.ColorGreen v.BgColor = gocui.ColorDefault v.Autoscroll = false v.Editable = false v.Wrap = false v.Frame = false go func() { for range time.Tick(time.Millisecond * 200) { UpdateMenuView(g) } }() UpdateMenuView(g) } return nil }
func (runner *appRunner) layout(g *gocui.Gui) error { maxX, maxY := g.Size() view, _ := g.SetView("mainControls", -1, -1, maxX/2, maxY) _, originY := view.Origin() _, cursorY := view.Cursor() view.Clear() runner.mainControlLines = 0 runner.highlightedTexter = nil if g.CurrentView() == nil { g.SetCurrentView("mainControls") } view.Highlight = g.CurrentView() == view runner.rootTexter.TextMain(func(label, line string, texter ViewModelNodeTexter) { paddedLabel := fmt.Sprintf("%20s", label) fmt.Fprintf(view, "%s %v\n", paddedLabel[len(paddedLabel)-20:len(paddedLabel)], line) if (originY + cursorY) == runner.mainControlLines { runner.highlightedTexter = texter } runner.mainControlLines++ }) return nil }
func InputView(g *gocui.Gui, x, y, maxX, maxY int) error { if v, err := g.SetView("input", x, y, maxX, maxY); err != nil { if err != gocui.ErrUnknownView { return err } _, err := g.SetCurrentView("input") if err != nil { return err } logger.Logger.Println(" CHANGE:", "input", x, y, maxX, maxY) v.Editor = Editor // v.FgColor = gocui.ColorGreen v.BgColor = gocui.ColorDefault v.Autoscroll = false v.Editable = true v.Wrap = false v.Frame = false } return nil }
func setView(g *gocui.Gui, s string) error { if err := g.SetCurrentView(s); err != nil { return err } return nil }
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 layout(g *gocui.Gui) error { theSizeX, theSizeY := 12, 6 maxX, maxY := g.Size() centerX, centerY := maxX/2, maxY/2 topLeftX, topLeftY := centerX-theSizeX, centerY-theSizeY bottomRightX, bottomRightY := centerX+theSizeX, centerY+theSizeY if v, err := g.SetView("yo", topLeftX, topLeftY, bottomRightX, bottomRightY); err != nil { if err != gocui.ErrUnknownView { return err } v.Editable = true v.Wrap = true fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9") fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9") fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9") fmt.Fprintln(v, " ---------------------") fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9") fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9") fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9") fmt.Fprintln(v, " ---------------------") fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9") fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9") fmt.Fprintln(v, " 1 2 3 | 4 5 6 | 7 8 9") } if err := g.SetCurrentView("yo"); err != nil { return err } return nil }
func layout(g *gocui.Gui) error { maxX, maxY := g.Size() if v, err := g.SetView("side", -1, -1, 30, maxY); err != nil { if err != gocui.ErrorUnkView { return err } v.Highlight = true fmt.Fprintln(v, "Item 1") fmt.Fprintln(v, "Item 2") fmt.Fprintln(v, "Item 3") fmt.Fprintln(v, "Item 4") } if v, err := g.SetView("main", 30, -1, maxX, maxY); err != nil { if err != gocui.ErrorUnkView { return err } b, err := ioutil.ReadFile("Mark.Twain-Tom.Sawyer.txt") if err != nil { panic(err) } fmt.Fprintf(v, "%s", b) v.Editable = true if err := g.SetCurrentView("main"); err != nil { return err } } return nil }
func layout(g *ui.Gui) error { x, y := g.Size() size := len(cli.Nodes) if v, err := g.SetView("nodes-cursor", 0, 0, 6, size+1); err != nil { if err != ui.ErrUnknownView { return err } v.Highlight = true v.Frame = false } if v, err := g.SetView("nodes", 2, 0, 20, size+1); err != nil { if err != ui.ErrUnknownView { return err } v.Frame = false printNodes() } if v, err := g.SetView("node", 16, 0, x, y-1); err != nil { if err != ui.ErrUnknownView { return err } v.Frame = false v.Editable = true printNode(g) } return g.SetCurrentView(current) }
func layout(g *gocui.Gui) error { maxX, _ := g.Size() if v, err := g.SetView("legend", maxX-23, 0, maxX-1, 5); err != nil { if err != gocui.ErrUnknownView { return err } fmt.Fprintln(v, "KEYBINDINGS") fmt.Fprintln(v, "↑ ↓: Seek input") fmt.Fprintln(v, "A: Enable autoscroll") fmt.Fprintln(v, "^C: Exit") } if v, err := g.SetView("stdin", 0, 0, 80, 35); err != nil { if err != gocui.ErrUnknownView { return err } if _, err := g.SetCurrentView("stdin"); err != nil { return err } dumper := hex.Dumper(v) if _, err := io.Copy(dumper, os.Stdin); err != nil { return err } v.Wrap = true } return nil }
func layout(g *gocui.Gui) error { maxX, maxY := g.Size() if v, err := g.SetView("side", -1, -1, 30, maxY); err != nil { if err != gocui.ErrUnknownView { return err } v.Highlight = true v.SelBgColor = gocui.ColorGreen v.SelFgColor = gocui.ColorBlack fmt.Fprintln(v, "Item 1") fmt.Fprintln(v, "Item 2") fmt.Fprintln(v, "Item 3") fmt.Fprint(v, "\rWill be") fmt.Fprint(v, "deleted\rItem 4\nItem 5") } if v, err := g.SetView("main", 30, -1, maxX, maxY); err != nil { if err != gocui.ErrUnknownView { return err } b, err := ioutil.ReadFile("Mark.Twain-Tom.Sawyer.txt") if err != nil { panic(err) } fmt.Fprintf(v, "%s", b) v.Editable = true v.Wrap = true if _, err := g.SetCurrentView("main"); err != nil { return err } } return nil }
func nextView(g *gocui.Gui, v *gocui.View) error { currentView := g.CurrentView() if currentView == nil || currentView.Name() == "contacts" { return g.SetCurrentView("input") } return g.SetCurrentView("contacts") }
func nextView(g *gocui.Gui, disableCurrent bool) error { next := curView + 1 if next > len(views)-1 { next = 0 } nv, err := g.View(views[next]) if err != nil { return err } if err := g.SetCurrentView(views[next]); err != nil { return err } nv.BgColor = gocui.ColorRed if disableCurrent && len(views) > 1 { cv, err := g.View(views[curView]) if err != nil { return err } cv.BgColor = g.BgColor } curView = next return nil }
func newView(g *gocui.Gui) error { maxX, maxY := g.Size() name := fmt.Sprintf("v%v", idxView) v, err := g.SetView(name, maxX/2-5, maxY/2-5, maxX/2+5, maxY/2+5) if err != nil { if err != gocui.ErrorUnkView { return err } v.Wrap = true fmt.Fprintln(v, strings.Repeat(name+" ", 30)) } if err := g.SetCurrentView(name); err != nil { return err } v.BgColor = gocui.ColorRed if curView >= 0 { cv, err := g.View(views[curView]) if err != nil { return err } cv.BgColor = g.BgColor } views = append(views, name) curView = len(views) - 1 idxView += 1 return nil }
func codeComplete(g *gocui.Gui, v *gocui.View) error { if v != nil { ox, oy := v.Origin() cx, cy := v.Cursor() x, y := ox+cx, oy+cy f := proj.GetFile("test.go") off := f.GetOffset(x, y) cands := codecomplete.Complete(proj, f, off) maxX, maxY := g.Size() maxY = maxY/2 - (len(cands) / 2) if v, err := g.SetView("msg", maxX/2-30, maxY, maxX/2+30, maxY+len(cands)+2); err != nil { if err != gocui.ErrorUnkView { return err } fmt.Fprintln(v, x, y, off) for _, c := range cands { fmt.Fprintln(v, c.Name, c.Perc) } if err := g.SetCurrentView("msg"); err != nil { return err } } } return nil }
func getLine(g *gocui.Gui, v *gocui.View) error { var l string var err error _, cy := v.Cursor() if l, err = v.Line(cy); err != nil { l = "" } maxX, maxY := g.Size() if v, err := g.SetView("msg", maxX/2-30, maxY/2, maxX/2+30, maxY/2+2); err != nil { if err != gocui.ErrorUnkView { return err } fmt.Fprintln(v, l) if err := g.SetCurrentView("msg"); err != nil { return err } } if v, err := g.View("main"); err != nil { if err != gocui.ErrorUnkView { return err } f := proj.GetFile(l) if f != nil { v.Clear() fmt.Fprintf(v, "%s", f.GetBody()) } v.Editable = true v.Wrap = true } return nil }
func layout(g *gocui.Gui) error { maxX, maxY := g.Size() if v, err := g.SetView("side", -1, -1, 30, maxY); err != nil { if err != gocui.ErrorUnkView { return err } v.Highlight = true list := proj.GetFileList() for _, f := range list { fmt.Fprintln(v, filepath.Base(f.GetPath())) } } if v, err := g.SetView("main", 30, -1, maxX, maxY); err != nil { if err != gocui.ErrorUnkView { return err } f := proj.GetFile("test.go") if f != nil { fmt.Fprintf(v, "%s", f.GetBody()) } v.Editable = true v.Wrap = false if err := g.SetCurrentView("main"); err != nil { return err } } return nil }
func layout(g *gocui.Gui) error { maxX, maxY := g.Size() if v, err := g.SetView("help", maxX-23, 0, maxX-1, 3); err != nil { if err != gocui.ErrUnknownView { return err } v.Title = "Keybindings" fmt.Fprintln(v, "^a: Set mask") fmt.Fprintln(v, "^c: Exit") } if v, err := g.SetView("input", 0, 0, maxX-24, maxY-1); err != nil { if err != gocui.ErrUnknownView { return err } if _, err := g.SetCurrentView("input"); err != nil { return err } v.Editable = true v.Wrap = true } return nil }
func nextView(g *gocui.Gui, v *gocui.View) error { currentView := g.CurrentView() if currentView == nil || currentView.Name() == "side" { return g.SetCurrentView("main") } return g.SetCurrentView("side") }
func nextView(g *gocui.Gui, v *gocui.View) error { if v == nil || v.Name() == "side" { _, err := g.SetCurrentView("main") return err } _, err := g.SetCurrentView("side") return err }
func toggleButton(g *gocui.Gui, v *gocui.View) error { nextview := "butdown" if v != nil && v.Name() == "butdown" { nextview = "butup" } _, err := g.SetCurrentView(nextview) return err }
func hideMatched(g *gocui.Gui, v *gocui.View) error { if err := g.DeleteView("matched"); err != nil { return err } if err := g.SetCurrentView("background"); err != nil { return err } return nil }
func layout(g *gocui.Gui) error { maxX, maxY := g.Size() if _, err := g.SetView("main", -1, -1, maxX, maxY); err != nil { if err := g.SetCurrentView("main"); err != nil { return err } } return nil }
func delMsg(g *gocui.Gui, v *gocui.View) error { if err := g.DeleteView("msg"); err != nil { return err } if _, err := g.SetCurrentView("side"); err != nil { return err } return nil }
func setContact(g *gocui.Gui, v *gocui.View) error { _, cy := v.Cursor() jid := viewJids[cy] g.View("main").Clear() io.Copy(g.View("main"), bytes.NewReader(jidBuffs[jid])) g.SetCurrentView("input") return nil }
func FocusStatusView(g *gocui.Gui, v *gocui.View) error { v.Autoscroll = true if _, err := g.SetCurrentView(client.StatusChannel); err != nil { return err } return nil }
func FocusInputView(g *gocui.Gui, v *gocui.View) error { v.SetCursor(len(v.Buffer()+"")-1, 0) if _, err := g.SetCurrentView("input"); err != nil { return err } return nil }
func delMsg(g *gocui.Gui, v *gocui.View) error { if err := g.DeleteView(vMessage); err != nil { return err } top(g, "Select target platform, source transcript and destination.") if err := g.SetCurrentView(vPlatforms); err != nil { return err } return nil }
func nextView(g *gocui.Gui, disableCurrent bool) error { next := curView + 1 if next > len(views)-1 { next = 0 } if _, err := g.SetCurrentView(views[next]); err != nil { return err } curView = next return nil }
func showMatched(g *gocui.Gui, v *gocui.View) error { maxX, maxY := g.Size() if v, err := g.SetView("matched", maxX/2-8, maxY/2, maxX/2+8, maxY/2+2); err != nil { if err != gocui.ErrorUnkView { return err } fmt.Fprintln(v, "Matched!") if err := g.SetCurrentView("matched"); err != nil { return err } } return nil }