author Brett Parker Wed, 1 Jul 2009 17:24:10 +0000 (18:24 +0100) committer Brett Parker Wed, 1 Jul 2009 17:24:10 +0000 (18:24 +0100)

@@ -157,24 +157,85 @@ def crossword(stdscr, crossworddata):
curx += 4
curx -= 1
+    # draw the clues in
+    cury = (len(crossword["grid"]) * 2) + 1
+    curx = 0
+    cury += 1
+    for cluenumber in crossword["across"].keys():
+        stdscr.addstr(cury, curx, "%3s: %s" %(str(cluenumber), crossword["across"][cluenumber]))
+        cury += 1
+
+    cury += 1
+    cury += 1
+    for cluenumber in crossword["down"].keys():
+        stdscr.addstr(cury, curx, "%3s: %s" %(str(cluenumber), crossword["down"][cluenumber]))
+        cury += 1
+
curx = 3
cury = 1
+    gridx = 0
+    gridy = 0
+
stdscr.move(1,3)
while 1:
c = stdscr.getch()
if c == curses.ascii.ESC:
break
if c == curses.KEY_RIGHT:
-            curx += 4
-            stdscr.move(cury, curx)
+            if gridx < (len(crossword["grid"]) - 1):
+                gridx += 1
+                curx += 4
+                while gridx < (len(crossword["grid"]) -1) \
+                    and crossword["grid"][gridy][gridx] == "x":
+                    gridx += 1
+                    curx += 4
+                while crossword["grid"][gridy][gridx] == "x":
+                    gridx -= 1
+                    curx -= 4
+                stdscr.move(cury, curx)
if c == curses.KEY_LEFT:
-            curx -= 4
-            stdscr.move(cury, curx)
+            if gridx > 0:
+                curx -= 4
+                gridx -= 1
+                while gridx > 0 \
+                    and crossword["grid"][gridy][gridx] == "x":
+                        gridx -= 1
+                        curx -= 4
+                while crossword["grid"][gridy][gridx] == "x":
+                    gridx += 1
+                    curx += 4
+                stdscr.move(cury, curx)
if c == curses.KEY_UP:
-            cury -= 2
-            stdscr.move(cury, curx)
+            if gridy > 0:
+                gridy -= 1
+                cury -= 2
+                while gridy > 0 \
+                    and crossword["grid"][gridy][gridx] == "x":
+                        gridy -= 1
+                        cury -= 2
+                while crossword["grid"][gridy][gridx] == "x":
+                    gridy += 1
+                    cury += 2
+                stdscr.move(cury, curx)
if c == curses.KEY_DOWN:
-            cury += 2
+            if gridy < (len(crossword["grid"]) - 1):
+                gridy += 1
+                cury += 2
+                while gridy < (len(crossword["grid"]) - 1) \
+                    and crossword["grid"][gridy][gridx] == "x":
+                    gridy += 1
+                    cury += 2
+                while crossword["grid"][gridy][gridx] == "x":
+                    gridy -= 1
+                    cury -= 2
+                stdscr.move(cury, curx)
+        if curses.ascii.isalpha(c) or c == ord(" "):