-(defvar tty-menu-navigation-map
- (let ((map (make-sparse-keymap)))
- ;; The next line is disabled because it breaks interpretation of
- ;; escape sequences, produced by TTY arrow keys, as tty-menu-*
- ;; commands. Instead, we explicitly bind some keys to
- ;; tty-menu-exit.
- ;;(define-key map [t] 'tty-menu-exit)
-
- ;; The tty-menu-* are just symbols interpreted by term.c, they are
- ;; not real commands.
- (substitute-key-definition 'keyboard-quit 'tty-menu-exit
- map (current-global-map))
- (substitute-key-definition 'keyboard-escape-quit 'tty-menu-exit
- map (current-global-map))
- ;; The bindings of menu-bar items are so that clicking on the menu
- ;; bar when a menu is already shown pops down that menu.
- ;; FIXME: we should iterate over all the visible menu-bar items,
- ;; instead of naming them explicitly here. Also, this doesn't
- ;; include items added by current major mode.
- (substitute-key-definition (lookup-key (current-global-map) [menu-bar file])
- 'tty-menu-exit
- map (current-global-map))
- (substitute-key-definition (lookup-key (current-global-map) [menu-bar edit])
- 'tty-menu-exit
- map (current-global-map))
- (substitute-key-definition (lookup-key (current-global-map) [menu-bar options])
- 'tty-menu-exit
- map (current-global-map))
- (substitute-key-definition (lookup-key (current-global-map) [menu-bar buffer])
- 'tty-menu-exit
- map (current-global-map))
- (substitute-key-definition (lookup-key (current-global-map) [menu-bar tools])
- 'tty-menu-exit
- map (current-global-map))
- (substitute-key-definition (lookup-key (current-global-map) [menu-bar help-menu])
- 'tty-menu-exit
- map (current-global-map))
- (substitute-key-definition 'forward-char 'tty-menu-next-menu
- map (current-global-map))
- (substitute-key-definition 'backward-char 'tty-menu-prev-menu
- map (current-global-map))
- ;; The following two will need to be revised if we ever support
- ;; a right-to-left menu bar.
- (substitute-key-definition 'right-char 'tty-menu-next-menu
- map (current-global-map))
- (substitute-key-definition 'left-char 'tty-menu-prev-menu
- map (current-global-map))
- (substitute-key-definition 'next-line 'tty-menu-next-item
- map (current-global-map))
- (substitute-key-definition 'previous-line 'tty-menu-prev-item
- map (current-global-map))
- (substitute-key-definition 'newline 'tty-menu-select
- map (current-global-map))
- (substitute-key-definition 'newline-and-indent 'tty-menu-select
- map (current-global-map))
- (define-key map [?\C-r] 'tty-menu-select)
- (define-key map [?\C-j] 'tty-menu-select)
- (define-key map [return] 'tty-menu-select)
- (define-key map [linefeed] 'tty-menu-select)
- (define-key map [down-mouse-1] 'tty-menu-select)
- (define-key map [drag-mouse-1] 'tty-menu-select)
- (define-key map [mode-line drag-mouse-1] 'tty-menu-select)
- (define-key map [mode-line down-mouse-1] 'tty-menu-select)
- (define-key map [header-line mouse-1] 'tty-menu-select)
- (define-key map [header-line drag-mouse-1] 'tty-menu-select)
- (define-key map [header-line down-mouse-1] 'tty-menu-select)
- (define-key map [mode-line mouse-1] 'tty-menu-ignore)
- (define-key map [mode-line mouse-2] 'tty-menu-ignore)
- (define-key map [mode-line mouse-3] 'tty-menu-ignore)
- (define-key map [mode-line C-mouse-1] 'tty-menu-ignore)
- (define-key map [mode-line C-mouse-2] 'tty-menu-ignore)
- (define-key map [mode-line C-mouse-3] 'tty-menu-ignore)
- ;; The mouse events must be bound to tty-menu-ignore, otherwise
- ;; the initial mouse click will select and immediately pop down
- ;; the menu.
- (define-key map [mouse-1] 'tty-menu-ignore)
- (define-key map [C-mouse-1] 'tty-menu-ignore)
- (define-key map [C-mouse-2] 'tty-menu-ignore)
- (define-key map [C-mouse-3] 'tty-menu-ignore)
- (define-key map [mouse-movement] 'tty-menu-mouse-movement)
- map)
- "Keymap used while processing TTY menus.")
-