From: Brett Parker Date: Wed, 1 Jul 2009 15:01:29 +0000 (+0100) Subject: add basic movement X-Git-Url: https://git.sommitrealweird.co.uk/curses-crossword.git/commitdiff_plain/4c1990607e531c5591201ef4ce1b6631504a796d add basic movement --- diff --git a/curses-crossword.py b/curses-crossword.py index 5554f30..75a1a50 100644 --- a/curses-crossword.py +++ b/curses-crossword.py @@ -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)