-
-
Notifications
You must be signed in to change notification settings - Fork 252
Expand file tree
/
Copy pathscroll.py
More file actions
26 lines (23 loc) · 958 Bytes
/
scroll.py
File metadata and controls
26 lines (23 loc) · 958 Bytes
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
from fmtstr.terminal import Terminal
from fmtstr.terminalcontrol import TerminalController
from bpython.scrollfrontend.repl import Repl
def main():
with TerminalController() as tc:
with Terminal(tc) as term:
with Repl() as repl:
rows, columns = tc.get_screen_size()
repl.width = columns
repl.height = rows
while True:
try:
repl.process_event(tc.get_event())
except SystemExit:
array, cursor_pos = repl.paint(about_to_exit=True)
term.render_to_terminal(array, cursor_pos)
raise
else:
array, cursor_pos = repl.paint()
scrolled = term.render_to_terminal(array, cursor_pos)
repl.scroll_offset += scrolled
if __name__ == '__main__':
main()