DangerousPrototypes / BusPirate5-firmware

Bus Pirate v5 Firmware
MIT License
140 stars 43 forks source link

VT100 compatible color mode not cleared #102

Open grymoire opened 1 month ago

grymoire commented 1 month ago

When you connect to the BP, and enable VT100 compatible color mode, the bottom of the screen displays the voltages on the pins.

When you type "#" of "$" (reset, or boot mode), the BP disconnects, yet the terminal is not cleared. The voltages stayed displayed on the screen, even when you execute commands that could cause the screen to scroll down. It is necessary to type "clear" to reset the terminal.

henrygab commented 1 month ago

It would probably be good to define as a function, such as void ResetTerminalOnExit() or similar. Possible items which might be output to reset the terminal (did DEC/ANSI not provide a shortcut method?) might include:


Reset top/bottom margins

It appears that a scroll region is setup during initialization: https://github.com/DangerousPrototypes/BusPirate5-firmware/blob/5bbaed7eeb2edc6f1bb16a796789bf51f37a1874/ui/ui_term.c#L126-L127 One [site](https://xtermjs.org/docs/api/vtfeatures/) defines `CSI #; # r` as "set top/bottom margins". Documentation is sparse, but since default is to set to the viewport size, it's likely the sequence `CSI ; r` (omitting the numeric values) should reset to full size, regardless of terminal size. As a C string, this would be: `"\e[;r"`?


Set cursor to bottom of screen

If getting rid of scroll area, don't want next output to overwrite the status bar information, as the user may want that to persist in the scrollback buffer.


Use other reset commands

`CSI ? ###... l`, where the `###` can be one or more values to be reset: `###` | Meaning -----:|----- 1 | Normal Cursor Keys 2 | Designate VT52 mode 3 | 80 Column Mode 6 | Normal Cursor Mode 7 | No Wraparound Mode 8 | No Auto-repeat Keys 9 | Don’t send Mouse X & Y on button press 12 | Stop Blinking Cursor 25 | Hide Cursor 45 | No reverse wrap-around 47 | Use Normal Screen Buffer 66 | Numeric keypad 1000 | Don’t send Mouse reports 1002 | Don’t use Cell Motion Mouse Tracking 1003 | Don’t use All Motion Mouse Tracking 1004 | Don’t send FocusIn/FocusOut events 1005 | Disable UTF-8 Mouse Mode 1006 | Disable SGR Mouse Mode 1015 | Disable urxvt Mouse Mode 1016 | Disable SGR-Pixels Mouse Mode 1047 | Use Normal Screen Buffer (clearing screen if in alt) 1048 | Restore cursor as in DECRC 1049 | Use Normal Screen Buffer and restore cursor 2004 | Reset bracketed paste mode


Output a single line

Output `"\r\n"` to force a single line scroll.


wyattearp commented 1 month ago

It would probably be good to define as a function, such as void ResetTerminalOnExit() or similar. Possible items which might be output to reset the terminal (did DEC/ANSI not provide a shortcut method?) might include:

I'm going to second that it would be cool to have just a ResetTerminal() function. Numerous times I've wanted to type clear or reset and have it drop me back to the top of the screen like a standard bash prompt. This is also a present issue when entering / exiting the logic analyzer mode.

wyattearp commented 1 month ago

Looking at the statemachine in #100, this appears to be related as well. I think it's probably best if we could sketch out the statemachine's intended execution and then create an update to address that.