def __init__(self, file, n, godmode):
"""
main is the wrapper window
There are two nested windows, namely header and stdscr.
"""
self.main = curses.initscr()
self.ROWS, self.COLS = self.main.getmaxyx()
self.header = self.main.subwin(2, self.COLS, 0, 0)
# center the text
# cast it to int for python3 support
center = int((self.COLS / 2) - (len(HEADER) / 2))
self.header.addstr(center * ' ' + HEADER)
self.header.refresh()
self.stdscr = self.main.subwin(self.ROWS-1, self.COLS, 1, 0)
self.stdscr.idlok(True)
self.stdscr.scrollok(True)
curses.cbreak()
curses.noecho()
self.stdscr.keypad(1)
self.stdscr.refresh()
self.file = file
# this is for handling the backspaces
self.virtualfile = file.split('\n')
self.godmode = godmode
self.n = n
# handle terminal size
if self.COLS < 100:
curses.endwin()
print ('Error: Increase the width of your terminal')
sys.exit(1)
评论列表
文章目录