diff --git a/basics/simple_attr.py b/basics/simple_attr.py index 7bfa11e..efd61a2 100644 --- a/basics/simple_attr.py +++ b/basics/simple_attr.py @@ -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 prev == '*' and ch == '/': - stdscr.attroff(curses.A_BOLD) - - prev = ch + 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) + + prev = ch def main(sysargs=sys.argv[:]):