Skip to content

Provide support for CSI REP control code#2702

Merged
kovidgoyal merged 3 commits into
kovidgoyal:masterfrom
keynslug:ft/csi-code-rep
Jun 1, 2020
Merged

Provide support for CSI REP control code#2702
kovidgoyal merged 3 commits into
kovidgoyal:masterfrom
keynslug:ft/csi-code-rep

Conversation

@keynslug
Copy link
Copy Markdown
Contributor

References:

I recently got bitten by the lack of support while evaluating sysdig ncurses-based CLI which for some reason thinks that I'm running on xterm-1003 compatible terminal emulator. As though this is probably bug on their side I reckoned that the support in kitty would be good to have either way.

Thoughts?

@kovidgoyal
Copy link
Copy Markdown
Owner

I am fine with adding support for this escape code, however the implementation has an issue. If the previous character was the last in a line it wont work. You need to special case x == 0 and decrement y after checking y > margin_top.

@kovidgoyal
Copy link
Copy Markdown
Owner

Also why is the repeat limited to the number of places left in the current line? It should probably be capped to 65535 to match VTE and xterm.

@keynslug
Copy link
Copy Markdown
Contributor Author

Also why is the repeat limited to the number of places left in the current line? It should probably be capped to 65535 to match VTE and xterm.

To be honest I was adhering to current libvte logic where they cap repetitions up to remaining row length.

I am fine with adding support for this escape code, however the implementation has an issue. If the previous character was the last in a line it wont work. You need to special case x == 0 and decrement y after checking y > margin_top.

As for that you're probably right but it's not clear then what should terminal do if: 1) the previous character was the last in a line above, and 2) that line is already off screen, for example due to scrolling or due to the fact that screen is 1 row high (which probably never happens but helps to illustrate an edge case). I could probably track last entered character in the similar way as libvte does this but I'm happy to hear your thoughts.

@kovidgoyal
Copy link
Copy Markdown
Owner

kovidgoyal commented May 29, 2020 via email

Instead cap by 65535 as a safeguard. This is more in line with ECMA 48.
@keynslug
Copy link
Copy Markdown
Contributor Author

keynslug commented May 29, 2020

That's all ECMA 48 has to say on the subject. No mention of truncating to current line length. Seems strange to go out of one's way to do something that is not mentioned in the standard. A cap to prevent DoS I can understand and think is good, but I see no reason to cap to remaining cells in line.

I see your point. Dropped the truncation.

Note that the previous line could only scroll off the screen on a one row terminal or if there was some control character sent, or the terminal window was resized, in which case the spec says behavior is undefined.

Well, doesn't spec talk about data stream here? Which is (I believe) not related to the screen contents, which in turn means that to follow the spec we must keep track of the last graphic character seen in that stream. Am I misinterpreting something?

@kovidgoyal
Copy link
Copy Markdown
Owner

kovidgoyal commented May 30, 2020 via email

@kovidgoyal kovidgoyal merged commit 9ba808e into kovidgoyal:master Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants