iterating over each char in the file in a more pythonic way, though still not happy with retaining all of the branches from the C version
This commit is contained in:
parent
2cb096e27e
commit
996ade6414
@ -8,25 +8,27 @@ FILE = {'fp': None}
|
||||
def simple_attr(stdscr):
|
||||
row, col = stdscr.getmaxyx()
|
||||
prev = ''
|
||||
for ch in FILE['fp'].read():
|
||||
y, x = stdscr.getyx()
|
||||
if y == (row - 1):
|
||||
stdscr.addstr(row - 1, 0, "<-Press Any Key->")
|
||||
stdscr.getch()
|
||||
stdscr.clear()
|
||||
stdscr.move(0, 0)
|
||||
if prev == '/' and ch == '*':
|
||||
stdscr.attron(curses.A_BOLD)
|
||||
fp = FILE['fp']
|
||||
for line in fp:
|
||||
for ch in line:
|
||||
y, x = stdscr.getyx()
|
||||
stdscr.addstr(y, x - 1, '/{0}'.format(ch))
|
||||
else:
|
||||
stdscr.addstr(y, x, ch)
|
||||
stdscr.refresh()
|
||||
if y == (row - 1):
|
||||
stdscr.addstr(row - 1, 0, "<-Press Any Key->")
|
||||
stdscr.getch()
|
||||
stdscr.clear()
|
||||
stdscr.move(0, 0)
|
||||
elif prev == '/' and ch == '*':
|
||||
stdscr.attron(curses.A_BOLD)
|
||||
y, x = stdscr.getyx()
|
||||
stdscr.addstr(y, x - 1, '/{0}'.format(ch))
|
||||
else:
|
||||
stdscr.addstr(y, x, ch)
|
||||
stdscr.refresh()
|
||||
|
||||
if prev == '*' and ch == '/':
|
||||
stdscr.attroff(curses.A_BOLD)
|
||||
if prev == '*' and ch == '/':
|
||||
stdscr.attroff(curses.A_BOLD)
|
||||
|
||||
prev = ch
|
||||
prev = ch
|
||||
|
||||
|
||||
def main(sysargs=sys.argv[:]):
|
||||
|
Loading…
Reference in New Issue
Block a user