package keymapimport ()// menuselectKeys are the default keymaps in menuselect mode.var menuselectKeys = map[string]inputrc.Bind{unescape(`\C-i`): {Action: "menu-complete"},unescape(`\C-N`): {Action: "menu-complete"},unescape(`\C-P`): {Action: "menu-complete-backward"},unescape(`\e[Z`): {Action: "menu-complete-backward"},unescape(`\C-@`): {Action: "accept-and-menu-complete"},unescape(`\C-F`): {Action: "menu-incremental-search"},unescape(`\e[A`): {Action: "menu-complete-backward"},unescape(`\e[B`): {Action: "menu-complete"},unescape(`\e[C`): {Action: "menu-complete"},unescape(`\e[D`): {Action: "menu-complete-backward"},unescape(`\e[1;5A`): {Action: "menu-complete-prev-tag"},unescape(`\e[1;5B`): {Action: "menu-complete-next-tag"},}// isearchCommands is a subset of commands that are valid in incremental-search mode.var isearchCommands = []string{// Edition"abort","backward-delete-char","backward-kill-word","backward-kill-line","unix-line-discard","unix-word-rubout","vi-unix-word-rubout","clear-screen","clear-display","magic-space","vi-movement-mode","yank","self-insert",// History"accept-and-infer-next-history","accept-line","accept-and-hold","operate-and-get-next","history-incremental-search-forward","history-incremental-search-backward","forward-search-history","reverse-search-history","history-search-forward","history-search-backward","history-substring-search-forward","history-substring-search-backward","incremental-forward-search-history","incremental-reverse-search-history",}// nonIsearchCommands is an even more restricted set of commands// that are used when a non-incremental search mode is active.var nonIsearchCommands = []string{"abort","accept-line","backward-delete-char","backward-kill-word","backward-kill-line","unix-line-discard","unix-word-rubout","vi-unix-word-rubout","self-insert",}// getContextBinds is in charge of returning the precise list of binds// that are relevant in a given context (local/main keymap). Some submodes// (like non/incremental search) will further restrict the set of binds.func ( *Engine) ( bool) ( map[string]inputrc.Bind) {// First get the unfiltered list // of binds for the current keymap.if { = .config.Binds[string(.main)] } else { = .config.Binds[string(.local)] }// No filtering possible on the local keymap, or if no binds.if ! || len() == 0 {return }// Then possibly restrict in some submodes.switch {case .Local() == Isearch: = .restrictCommands(.main, isearchCommands)case .nonIncSearch: = .restrictCommands(.main, nonIsearchCommands) }return}func ( *Engine) ( Mode, []string) map[string]inputrc.Bind {iflen() == 0 {return .config.Binds[string()] } := make(map[string]inputrc.Bind)for , := range .config.Binds[string()] {// Widget must be a valid isearch widgetif !isValidCommand(.Action, ) {continue }// Or bind to our temporary isearch keymap [] = }return}func isValidCommand( string, []string) bool {returnslices.Contains(, )}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.