- commit
- 50a4c218124e64f13a71d3321c2daae0e0d63f52
- parent
- c4f56a66b32e2b5100acc9783c4a9b5c1a4ee5c7
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-07-11 15:16
rm write
Diffstat
| M | boon.py | 24 | +++++++++++------------- |
1 files changed, 11 insertions, 13 deletions
diff --git a/boon.py b/boon.py
@@ -53,10 +53,6 @@ def get_cap(cap, *args): 53 53 return code.decode('ascii') 54 54 55 5556 -1 def write(cap, *args):57 -1 sys.stdout.write(get_cap(cap, *args))58 -159 -160 56 @contextmanager 61 57 def termios_reset(fd): 62 58 old = termios.tcgetattr(fd) @@ -68,16 +64,18 @@ def termios_reset(fd): 68 64 69 65 @contextmanager 70 66 def fullscreen():71 -1 write('civis')72 -1 write('smcup')-1 67 sys.stdout.write(get_cap('civis')) -1 68 sys.stdout.write(get_cap('smcup')) -1 69 sys.stdout.flush() 73 70 try: 74 71 fd = sys.stdin.fileno() 75 72 with termios_reset(fd): 76 73 tty.setcbreak(fd) 77 74 yield 78 75 finally:79 -1 write('rmcup')80 -1 write('cnorm')-1 76 sys.stdout.write(get_cap('rmcup')) -1 77 sys.stdout.write(get_cap('cnorm')) -1 78 sys.stdout.flush() 81 79 82 80 83 81 def getch(): @@ -110,13 +108,13 @@ class App: 110 108 for i, line in enumerate(lines): 111 109 if len(self.old_lines) > i and line == self.old_lines[i]: 112 110 continue113 -1 write('cup', i, 0)114 -1 write('el')115 -1 print(line)-1 111 sys.stdout.write(get_cap('cup', i, 0)) -1 112 sys.stdout.write(get_cap('el')) -1 113 sys.stdout.write(line) 116 114 117 115 # clear rest of screen118 -1 write('cup', len(lines), 0)119 -1 write('ed')-1 116 sys.stdout.write(get_cap('cup', len(lines), 0)) -1 117 sys.stdout.write(get_cap('ed')) 120 118 sys.stdout.flush() 121 119 122 120 self.old_lines = lines