-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhacker.py
40 lines (31 loc) · 899 Bytes
/
hacker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import curses, os, sys
if len(sys.argv) is 1 and os.path.isfile('input.txt.hacker'):
src_file = open('input.txt.hacker')
elif len(sys.argv) is 2 and os.path.isfile(sys.argv[1]):
src_file = open(sys.argv[1])
else:
print("Either have a file called 'input.txt.hacker' or supply a file "
"name as the first argument, e.g. python main.py test.py")
exit(1)
myscreen = curses.initscr()
curses.start_color()
curses.noecho()
curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)
char = 0
myscreen.getch()
for line in src_file:
if char == 27:
break
for word in line:
myscreen.addstr(word , curses.color_pair(1))
myscreen.refresh()
char = myscreen.getch()
if char == 27:
break
myscreen.refresh()
if char == 27:
curses.endwin()
else:
while char != 27:
char = myscreen.getch()
curses.endwin()