Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for GNU Screen #158

Open
jwodder opened this issue Nov 7, 2023 · 2 comments
Open

Add support for GNU Screen #158

jwodder opened this issue Nov 7, 2023 · 2 comments

Comments

@jwodder
Copy link

jwodder commented Nov 7, 2023

It appears that this library is currently unable to query GNU Screen and tmux terminals for their foreground & background colors, but I would like it to be able to do so. According to the source code for the termbg Rust library, a Screen terminal can be queried for its background color with the sequence "\x1bP\x1b]11;?\x07\x1b\\\x03"; I can confirm this works as of Screen 4.9.1, and I can also confirm that the foreground color can be queried by changing the 11 in the background query to a 10. In addition, the sequence that termenv uses for querying the cursor position ("\x1b[6n") also works with Screen.

termbg also uses the sequence "\x1bPtmux;\x1b\x1b]11;?\x07\x1b\\\x03" for getting the background color for tmux terminals. I don't have tmux, so I can't test it, but this sequence does work with my copy of Screen.

@CannibalVox
Copy link

Passthroughs silently fail on tmux since 3.3 unless they're specifically enabled. That said, tmux now allows foreground and background queries without passthrough, not sure when that started.

I believe the issue with screen that caused it to be disabled is that the cursor position query is something screen is able to field itself, resulting in the responses sometimes arriving out of order (they issue the passthrough color request, screen passes it along, they issue the cursor request, screen replies immediately, the color reply comes back and screen passes it along). If this happens, it's not just a matter of the color being mistaken, the color reply will be stuck in the pipe and can cause problems.

@CannibalVox
Copy link

It looks like tmux has had the ability to respond to these queries since 3.2a, but depending on what the color was, it just sometimes... wouldn't. Starting in 3.4, it is guaranteed to respond (though it may sometimes provide an incorrect color), and it precaches the response on startup, so it won't have the screen issue where the values may arrive out of order.

It seems like it should be 100% safe to allow tmux to respond.

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

No branches or pull requests

2 participants