[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master dc0a218: Port tetris menu to Emacs
From: |
Stefan Kangas |
Subject: |
[Emacs-diffs] master dc0a218: Port tetris menu to Emacs |
Date: |
Thu, 17 Oct 2019 12:49:48 -0400 (EDT) |
branch: master
commit dc0a218f62cab2eea245b1d577e1edc8e474364e
Author: Stefan Kangas <address@hidden>
Commit: Stefan Kangas <address@hidden>
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.
---
lisp/play/tetris.el | 42 +++++++++++++++++++++++++++++-------------
1 file changed, 29 insertions(+), 13 deletions(-)
diff --git a/lisp/play/tetris.el b/lisp/play/tetris.el
index a797a26..b5b7772 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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master dc0a218: Port tetris menu to Emacs,
Stefan Kangas <=