]> git.sommitrealweird.co.uk Git - curses-crossword.git/commitdiff
Put the clues in to a scrollable pad so that we can see scroll them
authorBrett Parker <iDunno@sommitrealweird.co.uk>
Mon, 20 Jul 2009 00:10:52 +0000 (01:10 +0100)
committerBrett Parker <iDunno@sommitrealweird.co.uk>
Mon, 20 Jul 2009 00:10:52 +0000 (01:10 +0100)
curses_crossword.py

index 75643761cf91cbf06b7b58d538bf1510c2429b35..88db74ee7cec571f2a3d3ee731df24ceb13f529a 100755 (executable)
@@ -203,21 +203,31 @@ def crossword(stdscr, crossworddata):
         curx += 4
     curx -= 1
     stdscr.addch(cury, curx, curses.ACS_LRCORNER)
         curx += 4
     curx -= 1
     stdscr.addch(cury, curx, curses.ACS_LRCORNER)
-    # draw the clues in
+    # draw the clues in (in their own pad)
+    cluespad = curses.newpad( \
+        len(crossword["across"].keys()) \
+        + len(crossword["down"].keys()) \
+        + 3, stdscr.getmaxyx()[1])
     cury = (len(crossword["grid"]) * 2) + 1
     curx = 0
     cury = (len(crossword["grid"]) * 2) + 1
     curx = 0
-    stdscr.addstr(cury, curx, "Across")
+    padtlx = curx
+    padtly = cury
+
+    (padbry, padbrx) = stdscr.getmaxyx()
+    sys.stderr.write("Pady, padx, max bits: %dx%d, %dx%d\n" %(padtly, padtlx, padbry, padbrx))
+    cury = 0
+    cluespad.addstr(cury, curx, "Across")
     cury += 1
     for cluenumber in crossword["across"].keys():
     cury += 1
     for cluenumber in crossword["across"].keys():
-        stdscr.addstr(cury, curx, "%3s: %s" \
+        cluespad.addstr(cury, curx, "%3s: %s" \
             %(str(cluenumber), crossword["across"][cluenumber]))
         cury += 1
 
     cury += 1
             %(str(cluenumber), crossword["across"][cluenumber]))
         cury += 1
 
     cury += 1
-    stdscr.addstr(cury, curx, "Down")
+    cluespad.addstr(cury, curx, "Down")
     cury += 1
     for cluenumber in crossword["down"].keys():
     cury += 1
     for cluenumber in crossword["down"].keys():
-        stdscr.addstr(cury, curx, "%3s: %s" \
+        cluespad.addstr(cury, curx, "%3s: %s" \
             %(str(cluenumber), crossword["down"][cluenumber]))
         cury += 1
 
             %(str(cluenumber), crossword["down"][cluenumber]))
         cury += 1
 
@@ -231,11 +241,24 @@ def crossword(stdscr, crossworddata):
         gridx += 1
 
     stdscr.move(cury, curx)
         gridx += 1
 
     stdscr.move(cury, curx)
+    cluescury = 0
+
+    cluespad.refresh(cluescury, 0, padtly, padtlx, padbry - 1, padbrx - 1)
+    cluespad.overlay(stdscr, cluescury, 0, padtly, padtlx, padbry - 1, padbrx - 1)
+
 
     while 1:
         inch = stdscr.getch()
         if inch == curses.ascii.ESC:
             break
 
     while 1:
         inch = stdscr.getch()
         if inch == curses.ascii.ESC:
             break
+        if inch == curses.KEY_NPAGE:
+            if cluescury < cluespad.getmaxyx()[0] - (padbry - padtly):
+                cluescury += 1
+            cluespad.refresh(cluescury, 0, padtly, padtlx, padbry - 1, padbrx - 1)
+        if inch == curses.KEY_PPAGE:
+            if cluescury > 0:
+                cluescury -= 1
+            cluespad.refresh(cluescury, 0, padtly, padtlx, padbry - 1, padbrx - 1)
         if inch == curses.KEY_RIGHT:
             if gridx < (len(crossword["grid"][0]) - 1):
                 gridx += 1
         if inch == curses.KEY_RIGHT:
             if gridx < (len(crossword["grid"][0]) - 1):
                 gridx += 1