Merge lp:~joshbrown/snakes-game/esc-key into lp:~snakes-game/snakes-game/trunk

Proposed by Josh Brown
Status: Merged
Merged at revision: 33
Proposed branch: lp:~joshbrown/snakes-game/esc-key
Merge into: lp:~snakes-game/snakes-game/trunk
Diff against target: 22 lines (+7/-0)
1 file modified
snakes (+7/-0)
To merge this branch: bzr merge lp:~joshbrown/snakes-game/esc-key
Reviewer Review Type Date Requested Status
Tom Bell Approve
Josh Brown Approve
Review via email: mp+35030@code.launchpad.net

Commit message

Stop escape key from pausing game

Description of the change

Stopped the escape key from pausing the game as per bug #631804.

To post a comment you must log in.
Revision history for this message
Josh Brown (joshbrown) wrote :

Works for me, just worried that doing something like this may be erroneous/unportable.

review: Approve
Revision history for this message
Tom Bell (bushbaby2511) wrote :

I have a feeling python will mangle the output on different systems. I read something about that on the 'os' module so it should be portable. One thing i'd add is to revert the change back to the default of 1000ms after we exit for uses in other applications. Otherwise it looks good to me

review: Needs Fixing
lp:~joshbrown/snakes-game/esc-key updated
34. By Josh Brown

Revert to original ESCDELAY when program ends

Revision history for this message
Tom Bell (bushbaby2511) wrote :

This looks fine to me if it hasn't be already merged

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snakes'
2--- snakes 2010-09-08 18:27:46 +0000
3+++ snakes 2010-09-09 21:01:01 +0000
4@@ -2,6 +2,7 @@
5 import curses
6 from random import randint
7 from time import sleep
8+from os import environ
9
10 # Variables that may never change:
11 UP = (-1, 0)
12@@ -165,4 +166,10 @@
13 sleep(SPEED)
14 quit()
15
16+try: _orig_ESCDELAY = environ['ESCDELAY']
17+except KeyError: pass
18+environ['ESCDELAY'] = str(0) # Stop escape key from pausing game
19+
20 curses.wrapper(main)
21+
22+environ['ESCDELAY'] = _orig_ESCDELAY # Revert to original ESCDELAY

Subscribers

People subscribed via source and target branches

to all changes: