diff options
author | Stefan Kangas <stefankangas@gmail.com> | 2019-10-17 18:49:33 +0200 |
---|---|---|
committer | Stefan Kangas <stefankangas@gmail.com> | 2019-10-17 18:49:33 +0200 |
commit | dc0a218f62cab2eea245b1d577e1edc8e474364e (patch) | |
tree | 06d346ec124c92c1c99cb365b6bb5cb194b484a3 /lisp/play/tetris.el | |
parent | 96f959521996399b7d75132d9f913577ba59cfb5 (diff) | |
download | emacs-dc0a218f62cab2eea245b1d577e1edc8e474364e.tar.gz |
Port tetris menu to Emacs
* lisp/play/tetris.el (tetris--menu-def): New constant.
(tetris-mode-menu, tetris-null-menu): Add a menu.
(tetris-mode): Remove XEmacs compat code.
(tetris-null-map, tetris-mode-map): Add docstring.
Diffstat (limited to 'lisp/play/tetris.el')
-rw-r--r-- | lisp/play/tetris.el | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/lisp/play/tetris.el b/lisp/play/tetris.el index a797a26d597..b5b77721ece 100644 --- a/lisp/play/tetris.el +++ b/lisp/play/tetris.el @@ -272,13 +272,40 @@ each one of its four blocks.") (define-key map [right] 'tetris-move-right) (define-key map [up] 'tetris-rotate-prev) (define-key map [down] 'tetris-move-down) - map)) + map) + "Keymap for Tetris games.") (defvar tetris-null-map (let ((map (make-sparse-keymap 'tetris-null-map))) (define-key map "n" 'tetris-start-game) (define-key map "q" 'quit-window) - map)) + map) + "Keymap for finished Tetris games.") + +(defconst tetris--menu-def + '("Tetris" + ["Start new game" tetris-start-game + :help "Start a new Tetris game"] + ["End game" tetris-end-game + :active (tetris-active-p) + :help "End the current Tetris game"] + ["Pause" tetris-pause-game + :active (and (tetris-active-p) (not tetris-paused)) + :help "Pause running Tetris game"] + ["Resume" tetris-pause-game + :active (and (tetris-active-p) tetris-paused) + :help "Resume paused Tetris game"]) + "Menu for `tetris'. Used to initialize menus.") + +(easy-menu-define + tetris-mode-menu tetris-mode-map + "Menu for running Tetris games." + tetris--menu-def) + +(easy-menu-define + tetris-null-menu tetris-null-map + "Menu for finished Tetris games." + tetris--menu-def) ;; ;;;;;;;;;;;;;;;; game functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -599,17 +626,6 @@ Drops the shape one square, testing for collision." (use-local-map tetris-null-map) - (unless (featurep 'emacs) - (setq mode-popup-menu - '("Tetris Commands" - ["Start new game" tetris-start-game] - ["End game" tetris-end-game - (tetris-active-p)] - ["Pause" tetris-pause-game - (and (tetris-active-p) (not tetris-paused))] - ["Resume" tetris-pause-game - (and (tetris-active-p) tetris-paused)]))) - (setq show-trailing-whitespace nil) (setq gamegrid-use-glyphs tetris-use-glyphs) |