blob: 7f8fd77f9ec8368e8299a044091e0e029a06ace7 (
plain) (
blame)
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
|
import curses
import _thread
class CLIError(): pass
class CLI():
def __init__(self):
self.lock = _thread.allocalte_lock()
self.running = False
def start(self):
with self.lock:
stdscr = curses.initscr()
self.running = True
def exit(self):
self.stop_unless_running()
with self.lock:
self.running = False
curses.nocbreak()
stdscr.keypad(1)
curses.endwin()
def stop_unless_running(self):
if not self.running:
raise CLIError("This function needs the cli to be runnig!")
def print(self, text, x=0, y=0, attr=None):
with self.lock:
|