mirror of https://github.com/jroimartin/gocui.git
Update dynamic.go to add SetViewOnBottom
This commit is contained in:
parent
a984617410
commit
c48e902a26
|
@ -46,7 +46,7 @@ func main() {
|
|||
|
||||
func layout(g *gocui.Gui) error {
|
||||
maxX, _ := g.Size()
|
||||
v, err := g.SetView("help", maxX-25, 0, maxX-1, 8)
|
||||
v, err := g.SetView("help", maxX-25, 0, maxX-1, 9)
|
||||
if err != nil {
|
||||
if err != gocui.ErrUnknownView {
|
||||
return err
|
||||
|
@ -57,13 +57,17 @@ func layout(g *gocui.Gui) error {
|
|||
fmt.Fprintln(v, "← ↑ → ↓: Move View")
|
||||
fmt.Fprintln(v, "Backspace: Delete View")
|
||||
fmt.Fprintln(v, "t: Set view on top")
|
||||
fmt.Fprintln(v, "b: Set view on bottom")
|
||||
fmt.Fprintln(v, "^C: Exit")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func initKeybindings(g *gocui.Gui) error {
|
||||
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
|
||||
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone,
|
||||
func(g *gocui.Gui, v *gocui.View) error {
|
||||
return gocui.ErrQuit
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("", gocui.KeySpace, gocui.ModNone,
|
||||
|
@ -108,16 +112,23 @@ func initKeybindings(g *gocui.Gui) error {
|
|||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("", 't', gocui.ModNone, ontop); err != nil {
|
||||
if err := g.SetKeybinding("", 't', gocui.ModNone,
|
||||
func(g *gocui.Gui, v *gocui.View) error {
|
||||
_, err := g.SetViewOnTop(views[curView])
|
||||
return err
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("", 'b', gocui.ModNone,
|
||||
func(g *gocui.Gui, v *gocui.View) error {
|
||||
_, err := g.SetViewOnBottom(views[curView])
|
||||
return err
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func quit(g *gocui.Gui, v *gocui.View) error {
|
||||
return gocui.ErrQuit
|
||||
}
|
||||
|
||||
func newView(g *gocui.Gui) error {
|
||||
maxX, maxY := g.Size()
|
||||
name := fmt.Sprintf("v%v", idxView)
|
||||
|
@ -177,8 +188,3 @@ func moveView(g *gocui.Gui, v *gocui.View, dx, dy int) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ontop(g *gocui.Gui, v *gocui.View) error {
|
||||
_, err := g.SetViewOnTop(views[curView])
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue