tomek-szczesny / notcurses-vt-proto

A prototype of Virtual Terminal feature in notcurses
2 stars 0 forks source link

Auto wrap mode (DECAWM) #12

Open tomek-szczesny opened 3 years ago

tomek-szczesny commented 3 years ago

// \e[?7h // Auto wrap mode (DECAWM)

Again, what the fuck is the meaning of this? Isn't auto wrap the default behavior of all terminals? Huh, maybe it's not.

o-sdn-o commented 3 years ago

For me, this Turns on/off the mode in which the terminal automatically feeds the carriage to a new line. The key point is that when the cursor moves back, it jumps to the end of the top line when it hits the beginning of the line.

tomek-szczesny commented 3 years ago

https://github.com/mattiase/wraptest

The auto-wrap mode flag, DECAWM, controls whether text will wrap around the edges at all. It can be set and cleared using the DECSET and DECRST control sequences; terminal emulators usually get this bit right. In the following text, we assume that auto-wrap is enabled (DECAWM set). When the terminal receives a printing character and the cursor is in the rightmost column, what happens depends on the hidden Last Column Flag: If the LCF is 0, then the character is drawn at the cursor position as usual, but instead of advancing the cursor afterwards, the LCF is set to 1. If the LCF is 1, then the cursor is moved to the first column of the next line, scrolling if necessary. Then LCF is set to 0, the character is drawn, and the cursor advanced as usual. The Last Column flag starts out as 0 when the terminal is powered on.

Others put it simply:

If the DECAWM function is set, then graphic characters received when the cursor is at the right border of the page appear at the beginning of the next line. Any text on the page scrolls up if the cursor is at the end of the scrolling region. If the DECAWM function is reset, then graphic characters received when the cursor is at the right border of the page replace characters already on the page.

And so on. I'm guessing this is just a formalism from htop's side to ensure that the host terminal is indeed auto wrapping.

I'd skip implementing LCF as this is clearly a remainder of 1980s digital technology, but I'm guessing that I'll end up implementing most of the stuff that xterm supports.

o-sdn-o commented 3 years ago

I'd skip implementing LCF as this is clearly a remainder of 1980s digital technology

FYI In VTM, disabling of this mode allows you to print long lines and use horizontal scrolling in the built-in terminal.

tomek-szczesny commented 3 years ago

Cool, bot outside of scope of notcurses VT for now. Clever idea though :)