(popup-menu-normalize-position (event-end position)))
(t position)))
+(defcustom tty-menu-open-use-tmm nil
+ "If non-nil, \\[menu-bar-open] on a TTY will invoke `tmm-menubar'.
+
+If nil, \\[menu-bar-open] will drop down the menu corresponding to the
+first (leftmost) menu-bar item; you can select other items by typing
+\\[forward-char], \\[backward-char], \\[right-char] and \\[left-char]."
+ :type '(choice (const :tag "F10 drops down TTY menus" nil)
+ (const :tag "F10 invokes tmm-menubar" t))
+ :group 'display
+ :version "24.4")
+
+(defvar tty-menu--initial-menu-x 1
+ "X coordinate of the first menu-bar menu dropped by F10.
+
+This is meant to be used only for debugging TTY menus.")
+
+(defun menu-bar-open (&optional frame)
+ "Start key navigation of the menu bar in FRAME.
+
+This function decides which method to use to access the menu
+depending on FRAME's terminal device. On X displays, it calls
+`x-menu-bar-open'; on Windows, `w32-menu-bar-open'; otherwise it
+calls either `popup-menu' or `tmm-menubar' depending on whether
+\`tty-menu-open-use-tmm' is nil or not.
+
+If FRAME is nil or not given, use the selected frame."
+ (interactive)
+ (let ((type (framep (or frame (selected-frame)))))
+ (cond
+ ((eq type 'x) (x-menu-bar-open frame))
+ ((eq type 'w32) (w32-menu-bar-open frame))
+ ((and (null tty-menu-open-use-tmm)
+ (not (zerop (or (frame-parameter nil 'menu-bar-lines) 0))))
+ (let* ((x tty-menu--initial-menu-x)
+ (menu (menu-bar-menu-at-x-y x 0 frame)))
+ (popup-menu (or
+ (lookup-key global-map (vector 'menu-bar menu))
+ (lookup-key (current-local-map) (vector 'menu-bar menu)))
+ (posn-at-x-y x 0 nil t) nil t)))
+ (t (with-selected-frame (or frame (selected-frame))
+ (tmm-menubar))))))
+
+(global-set-key [f10] 'menu-bar-open)
+
(defvar tty-menu-navigation-map
(let ((map (make-sparse-keymap)))
;; The next line is disabled because it breaks interpretation of
(next-line . tty-menu-next-item)
(previous-line . tty-menu-prev-item)
(newline . tty-menu-select)
- (newline-and-indent . tty-menu-select)))
+ (newline-and-indent . tty-menu-select)
+ (menu-bar-open . tty-menu-exit)))
(substitute-key-definition (car bind) (cdr bind)
map (current-global-map)))
map)
"Keymap used while processing TTY menus.")
-
-(defcustom tty-menu-open-use-tmm nil
- "If non-nil, \\[menu-bar-open] on a TTY will invoke `tmm-menubar'.
-
-If nil, \\[menu-bar-open] will drop down the menu corresponding to the
-first (leftmost) menu-bar item; you can select other items by typing
-\\[forward-char], \\[backward-char], \\[right-char] and \\[left-char]."
- :type '(choice (const :tag "F10 drops down TTY menus" nil)
- (const :tag "F10 invokes tmm-menubar" t))
- :group 'display
- :version "24.4")
-
-(defvar tty-menu--initial-menu-x 1
- "X coordinate of the first menu-bar menu dropped by F10.
-
-This is meant to be used only for debugging TTY menus.")
-
-(defun menu-bar-open (&optional frame)
- "Start key navigation of the menu bar in FRAME.
-
-This function decides which method to use to access the menu
-depending on FRAME's terminal device. On X displays, it calls
-`x-menu-bar-open'; on Windows, `w32-menu-bar-open'; otherwise it
-calls either `popup-menu' or `tmm-menubar' depending on whether
-\`tty-menu-open-use-tmm' is nil or not.
-
-If FRAME is nil or not given, use the selected frame."
- (interactive)
- (let ((type (framep (or frame (selected-frame)))))
- (cond
- ((eq type 'x) (x-menu-bar-open frame))
- ((eq type 'w32) (w32-menu-bar-open frame))
- ((and (null tty-menu-open-use-tmm)
- (not (zerop (or (frame-parameter nil 'menu-bar-lines) 0))))
- (let* ((x tty-menu--initial-menu-x)
- (menu (menu-bar-menu-at-x-y x 0 frame)))
- (popup-menu (or
- (lookup-key global-map (vector 'menu-bar menu))
- (lookup-key (current-local-map) (vector 'menu-bar menu)))
- (posn-at-x-y x 0 nil t) nil t)))
- (t (with-selected-frame (or frame (selected-frame))
- (tmm-menubar))))))
-
-(global-set-key [f10] 'menu-bar-open)
-
(provide 'menu-bar)
;;; menu-bar.el ends here