]> git.sommitrealweird.co.uk Git - curses-crossword.git/commitdiff
add basic movement
authorBrett Parker <iDunno@sommitrealweird.co.uk>
Wed, 1 Jul 2009 15:01:29 +0000 (16:01 +0100)
committerBrett Parker <iDunno@sommitrealweird.co.uk>
Wed, 1 Jul 2009 15:01:29 +0000 (16:01 +0100)
curses-crossword.py

index 5554f3036fd7b68b7b6e101fd3f27ab968965028..75a1a50ae9e8fe04e4a63227e3baf26cae5c3adc 100644 (file)
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import curses
+import curses.ascii
 import locale
 import codecs
 
@@ -156,10 +157,25 @@ def crossword(stdscr, crossworddata):
         curx += 4
     curx -= 1
     stdscr.addch(cury, curx, curses.ACS_LRCORNER)
+    curx = 3
+    cury = 1
+    stdscr.move(1,3)
     while 1:
         c = stdscr.getch()
-        if c == ord('q'):
+        if c == curses.ascii.ESC:
             break
+        if c == curses.KEY_RIGHT:
+            curx += 4
+            stdscr.move(cury, curx)
+        if c == curses.KEY_LEFT:
+            curx -= 4
+            stdscr.move(cury, curx)
+        if c == curses.KEY_UP:
+            cury -= 2
+            stdscr.move(cury, curx)
+        if c == curses.KEY_DOWN:
+            cury += 2
+            stdscr.move(cury, curx)
+
 
 curses.wrapper(crossword, crossworddata)
-print parsecrossword(crossworddata)