- commit
- ef3d5215e843a568f5f3b9a267b0cd0e596cfabe
- parent
- 4b68fbfbb7e09a9860cdb0f0d4266bc2e336c860
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2023-09-14 08:41
tweak post tui
Diffstat
M | _content/posts/2023-03-30-tui/index.md | 9 | +++++---- |
1 files changed, 5 insertions, 4 deletions
diff --git a/_content/posts/2023-03-30-tui/index.md b/_content/posts/2023-03-30-tui/index.md
@@ -10,7 +10,8 @@ state. But fear not! I will walk you through all the relevant steps. 10 10 # Enter and exit TUI mode 11 11 12 12 Terminals do not have a dedicated TUI mode. Instead, there is a collection of13 -1 options we can combine to get what we want:-1 13 options we can combine to get what we want. I will first describe each aspect -1 14 and then provide a code example. 14 15 15 16 ## Disable line buffering 16 17 @@ -19,8 +20,8 @@ enter key. In TUI applications, we want to react to every key press 19 20 individually. So we want to disable that. 20 21 21 22 In C, the termios library provides the two functions `tcgetattr()` and22 -1 `tcsetattr()` which allow us to get a struct with options for a given file23 -1 descriptor, change it, and the apply the new set of options.-1 23 `tcsetattr()` which allow us to get a struct with options for `stdin`, change -1 24 it, and the apply the new set of options. 24 25 25 26 It is common to store a copy of the original struct so it can be used to 26 27 restore the original state when we want to exit TUI mode. @@ -53,7 +54,7 @@ Switching to the alternate screen is `smcup` in terminfo and `\033[?1049h` in 53 54 xterm. Switching back to the original screen is `rmcup` in terminfo and 54 55 `\033[?1049l` in xterm. 55 5656 -1 ## Hide cursor-1 57 ## Hide the cursor 57 58 58 59 When typing in the command line, the cursor show us where the next typed 59 60 character will be inserted. In many TUI applications, arbitrary regions of the