|
|
@ -5,6 +5,17 @@ import curses |
|
|
|
from curses import wrapper |
|
|
|
field = Field() |
|
|
|
|
|
|
|
def generate_source(): |
|
|
|
source = [] |
|
|
|
|
|
|
|
source.add('byte frame[8][12] =i {') |
|
|
|
for line in range(len(0,field.frame)): |
|
|
|
curline = field.frame[line] |
|
|
|
sourceline = '{' |
|
|
|
for col in range(0,len(curline)): |
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
def print_field(): |
|
|
|
for line in range(0,len(field)): |
|
|
|
curline = field[line] |
|
|
@ -19,7 +30,7 @@ def print_field(): |
|
|
|
def inputLoop(stdscr): |
|
|
|
exitPrg = False |
|
|
|
curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK) |
|
|
|
curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLUE) |
|
|
|
curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_CYAN) |
|
|
|
curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK) |
|
|
|
curses.noecho() |
|
|
|
curses.cbreak() |
|
|
@ -29,27 +40,30 @@ def inputLoop(stdscr): |
|
|
|
field.print_field(stdscr) |
|
|
|
key = stdscr.getkey() |
|
|
|
|
|
|
|
field.message = str(key) |
|
|
|
match key: |
|
|
|
case 'q': |
|
|
|
exitPrg = True |
|
|
|
case ' ': |
|
|
|
field.toggleCurrent() |
|
|
|
field.togglePixel() |
|
|
|
case '^L': |
|
|
|
field.print_field(stdscr) |
|
|
|
case 'KEY_DOWN': |
|
|
|
if field.cursor[0] < len(field.field)-1: |
|
|
|
if field.cursor[0] < len(field.frame)-1: |
|
|
|
newcursor = (field.cursor[0] +1,field.cursor[1]) |
|
|
|
field.cursor = newcursor |
|
|
|
case 'KEY_RIGHT': |
|
|
|
curline = field.field[field.cursor[0]] |
|
|
|
curline = field.frame[field.cursor[0]] |
|
|
|
if field.cursor[1] < len(curline)-1: |
|
|
|
newcursor = (field.cursor[0],field.cursor[1]+1) |
|
|
|
field.cursor = newcursor |
|
|
|
case 'KEY_LEFT': |
|
|
|
curline = field.field[field.cursor[0]] |
|
|
|
curline = field.frame[field.cursor[0]] |
|
|
|
if field.cursor[1] > 0: |
|
|
|
newcursor = (field.cursor[0],field.cursor[1]-1) |
|
|
|
field.cursor = newcursor |
|
|
|
case 'KEY_UP': |
|
|
|
curline = field.field[field.cursor[0]] |
|
|
|
curline = field.frame[field.cursor[0]] |
|
|
|
if field.cursor[0] > 0: |
|
|
|
newcursor = (field.cursor[0] -1,field.cursor[1]) |
|
|
|
field.cursor = newcursor |
|
|
|