3 ms·
It filters out escape sequences on input, yes. But ncurses does generate its own escape sequences (obviously, that's how it does what it does); and so it still
by derefr 5y ago
It filters out escape sequences on input, yes. But ncurses does generate its own escape sequences (obviously, that's how it does what it does); and so it still has to have a full internal PTY <-> what-a-terminal-emulator-would-do mapping model for what it itself has emitted to the screen, in order to be able to do "damage region" repainting correctly without e.g. suddenly making some text lose color because it jumped to a "display cell" that actually corresponds in the PTY stream to both the text and some SGR escape codes.
- moonchild 5y ago> suddenly making some text lose color because it jumped to a "display cell" that actually corresponds in the PTY stream to both the text and some SGR escape codes Not how the terminal works. Try this: printf " \e[34mhiii\r\e[0mxx\n" This: - Prints a space - Switches to blue - Prints hiii - Moves to the left of the screen - Turns off all attributes - Prints 'xx' (such that the cell where the colour started has definitely been overwritten) This should result in a default-coloured 'xx' followed by blue 'iii'. You do not need a complete model of the terminal. All you need is calculate dirty regions -> redraw them line-by-line in the naive manner. SGR escapes aren't associated with specific cells; you can think of them as commands to the terminal. 'Set your default foreground colour to ...' They could as easily go along a separate channel (barring synchronization overhead, etc.).