- commit
- 8a6662decfb3d1dc3ebbba1acfa4d68a29db5e95
- parent
- 9f567dd468ad71967eeb133efcbeb5118a5066b9
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2023-07-19 16:30
tweak tui post
Diffstat
M | _content/posts/2023-03-30-tui/index.md | 8 | ++++---- |
1 files changed, 4 insertions, 4 deletions
diff --git a/_content/posts/2023-03-30-tui/index.md b/_content/posts/2023-03-30-tui/index.md
@@ -84,7 +84,7 @@ def exit_tui(): 84 84 sys.stdout.write('\033[?1049l') 85 85 sys.stdout.write('\033[?25h') 86 86 sys.stdout.flush()87 -1 termios.tcsetattr(fd, otermios.TCSADRAIN, old_state)-1 87 termios.tcsetattr(fd, termios.TCSADRAIN, old_state) 88 88 89 89 enter_tui() 90 90 run_mainloop() @@ -110,7 +110,7 @@ The underlying mechanism for this are the signals `SIGSTOP`, `SIGTSTP`, and 110 110 `SIGCONT`. `SIGSTOP` and `SIGTSTP` are used to stop a process. The difference 111 111 between the two is that the our application can intercept and handle (or 112 112 ignore) `SIGTSTP`, but not `SIGSTOP`. Luckily, the terminal sends `SIGTSTP` on113 -1 `ctrl-z`. `SIGCONT` is used to continue a process and is sent by the terminal-1 113 `ctrl-z`. `SIGCONT` is used to un-stop a process and is sent by the terminal 114 114 when you type `fg`. 115 115 116 116 Signals can interrupt our code at any time, e.g. in the middle of writing a @@ -143,7 +143,7 @@ Some things to note: 143 143 - We do not need to register a separate handler for `SIGCONT`. Instead, we just 144 144 rely on the fact that `SIGSTOP` will immediately stop the process. On 145 145 `SIGCONT`, execution will continue and we can restore the TUI context in the146 -1 next command.-1 146 next line. 147 147 - The screen might have changed in the meantime, so it is best to do a fresh 148 148 render. 149 149 @@ -177,7 +177,7 @@ class TUIMode(AbstractContextManager): 177 177 sys.stdout.write('\033[?1049l') 178 178 sys.stdout.write('\033[?25h') 179 179 sys.stdout.flush()180 -1 termios.tcsetattr(self.fd, otermios.TCSADRAIN, self.old_state)-1 180 termios.tcsetattr(self.fd, termios.TCSADRAIN, self.old_state) 181 181 182 182 183 183 def on_stop(ctx):