Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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.).



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: