Proofread and more info.

This commit is contained in:
Julien Palard 2021-10-13 13:25:42 +02:00
parent 7bcea341a2
commit 231e7c55dd
1 changed files with 12 additions and 2 deletions

View File

@ -31,7 +31,7 @@ the bottom, but the logs will start from the top, as if there were no
progress bar.
While trying to solve this with my coworker, we were discussing about
my implementatin, and were reading a random function:
my implementation, and looking at a random function:
```c
static void DECSC(struct lw_terminal *term_emul)
@ -47,7 +47,7 @@ static void DECSC(struct lw_terminal *term_emul)
and soon we realized it was the missing piece! Saving the cursor position to restore it later!!
It soon started to look like an ugly undocumented, but almost working, ... thing:
It soon started to look like an ugly undocumented, but almost working, ... thing?
```python
print(f"\0337\033[0;{lines-1}r\0338")
@ -110,6 +110,16 @@ finally:
write("\0338") # Restore cursor position
```
For the record here's what's used (`\033` is `ESC`):
- `ESC 7` is [DECSC](https://github.com/JulienPalard/vt100-emulator/blob/be03b202fe4f40385df2d9e7888702d91cbf0f9a/src/lw_terminal_vt100.c#L231) (Save Cursor)
- `ESC 8` is [DECRC](https://github.com/JulienPalard/vt100-emulator/blob/be03b202fe4f40385df2d9e7888702d91cbf0f9a/src/lw_terminal_vt100.c#L480) (Restore Cursor)
- `ESC [ Pn ; Pn r` is [DECSTBM](https://github.com/JulienPalard/vt100-emulator/blob/be03b202fe4f40385df2d9e7888702d91cbf0f9a/src/lw_terminal_vt100.c#L368) (Set Top and Bottom Margins)
- `ESC [ Pn A` is [CUU](https://github.com/JulienPalard/vt100-emulator/blob/be03b202fe4f40385df2d9e7888702d91cbf0f9a/src/lw_terminal_vt100.c#L606) (Cursor Up)
- `ESC [ Pn ; Pn f` is [HVP](https://github.com/JulienPalard/vt100-emulator/blob/be03b202fe4f40385df2d9e7888702d91cbf0f9a/src/lw_terminal_vt100.c#L811) (Horizontal and Vertical Position)
- `ESC [ Ps K` is [EL](https://github.com/JulienPalard/vt100-emulator/blob/be03b202fe4f40385df2d9e7888702d91cbf0f9a/src/lw_terminal_vt100.c#L770) (Erase In Line)
Don't forget the `-u` (unbuffered) Python flag if you want to see it step by step:
![progress bar started at the top]({static}/images/hello-1-2-3.gif)