Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import curses
- def run(callback, machine):
- def internal(stdscr, machine):
- console = ConsoleDisplay(stdscr, machine.rows(), machine.cols())
- callback(console, machine)
- curses.wrapper(internal, machine)
- class ConsoleDisplay():
- def __init__(self, win, rows, cols):
- def set_escape_keys_interpreted_by_curses(win):
- win.keypad(1)
- def set_getch_nonblocking(win):
- win.nodelay(1)
- def set_cursor_as_a_block():
- curses.curs_set(2)
- win.resize(rows, cols)
- set_escape_keys_interpreted_by_curses(win)
- set_getch_nonblocking(win)
- set_cursor_as_a_block()
- self._win = win
- self.rows = rows
- self.cols = cols
- def set_char(self, x, y, c):
- if c == 0:
- c = 32 # TODO: set this in RAM mem instead...
- self._win.insstr(y, x, str(chr(c)))
- def refresh(self):
- self._win.refresh()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement