2009-11-21 16:35:38 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
import sys
|
|
|
|
import curses
|
|
|
|
|
|
|
|
FILE = {'fp': None}
|
|
|
|
|
|
|
|
|
|
|
|
def simple_attr(stdscr):
|
|
|
|
row, col = stdscr.getmaxyx()
|
|
|
|
prev = ''
|
2009-11-22 17:22:34 +00:00
|
|
|
fp = FILE['fp']
|
|
|
|
for line in fp:
|
|
|
|
for ch in line:
|
2009-11-21 16:35:38 +00:00
|
|
|
y, x = stdscr.getyx()
|
2009-11-22 17:22:34 +00:00
|
|
|
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
|
2009-11-21 16:35:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main(sysargs=sys.argv[:]):
|
|
|
|
if not sysargs[1:]:
|
|
|
|
print('Usage: {0} <a c file name>'.format(sysargs[0]))
|
|
|
|
return 1
|
|
|
|
try:
|
|
|
|
FILE['fp'] = open(sysargs[1], 'r')
|
|
|
|
except (OSError, IOError):
|
|
|
|
print('Cannot open input file', file=sys.stderr)
|
|
|
|
return 1
|
|
|
|
curses.wrapper(simple_attr)
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main())
|
|
|
|
|
|
|
|
# vim:filetype=python
|