github.com/kolbycrouch/elvish@v0.14.1-0.20210614162631-215b9ac1c423/cmd/examples/nav/main.go (about) 1 // Command nav runs the navigation mode of the line editor. 2 package main 3 4 import ( 5 "fmt" 6 7 "src.elv.sh/pkg/cli" 8 "src.elv.sh/pkg/cli/mode" 9 "src.elv.sh/pkg/cli/term" 10 "src.elv.sh/pkg/cli/tk" 11 ) 12 13 func main() { 14 app := cli.NewApp(cli.AppSpec{}) 15 w := mode.NewNavigation(app, mode.NavigationSpec{ 16 Bindings: tk.MapBindings{ 17 term.K('x'): func(tk.Widget) { app.CommitCode() }, 18 }, 19 }) 20 app.SetAddon(w, false) 21 22 code, err := app.ReadCode() 23 fmt.Println("code:", code) 24 if err != nil { 25 fmt.Println("err", err) 26 } 27 }