mirror of https://github.com/jroimartin/gocui.git
Extend _examples/delete.go to test *Gui.SetViewOnTop
This commit is contained in:
parent
28abcdb8e4
commit
a09a166064
|
@ -42,7 +42,7 @@ func main() {
|
|||
|
||||
func layout(g *gocui.Gui) error {
|
||||
maxX, _ := g.Size()
|
||||
v, err := g.SetView("legend", maxX-25, 0, maxX-1, 7)
|
||||
v, err := g.SetView("legend", maxX-25, 0, maxX-1, 8)
|
||||
if err != nil {
|
||||
if err != gocui.ErrUnknownView {
|
||||
return err
|
||||
|
@ -52,6 +52,7 @@ func layout(g *gocui.Gui) error {
|
|||
fmt.Fprintln(v, "Tab: Next View")
|
||||
fmt.Fprintln(v, "← ↑ → ↓: Move View")
|
||||
fmt.Fprintln(v, "Backspace: Delete View")
|
||||
fmt.Fprintln(v, "t: Set view on top")
|
||||
fmt.Fprintln(v, "^C: Exit")
|
||||
}
|
||||
return nil
|
||||
|
@ -103,6 +104,9 @@ func initKeybindings(g *gocui.Gui) error {
|
|||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := g.SetKeybinding("", 't', gocui.ModNone, ontop); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -191,3 +195,8 @@ 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