-
-
Notifications
You must be signed in to change notification settings - Fork 793
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
force_reverse_video_selection #3440
Comments
FWIW, the logic for this stuff is already rather complex: wezterm/wezterm-gui/src/termwindow/render/mod.rs Lines 490 to 677 in 45db43a
I'm not eager to try adding more options in here unless there is a really clear and pressing need.
and other combinations of factors/configs. |
Hmmm, I don't really know much about this so I'll take you word for it about complexity, but for reverse video cursor coupled with reverse video selection couldn't you disallow having both for a start? Since you already have the cursor one you could let that one take priority, and so if both are set the selection one would have no effect. There's obviously no clear and pressing need, it's just a look thing, I can definitely go without it, I'm just trying to replicate my old Konsole look on WezTerm. |
As far as I know, the logic for this should be fairly simple. If reverse video for selection is enabled in config, simply swap foreground and background color for selected text. I looked at the code, here is what that would look like IMO:
While it is not a pressing need, this is the default behavior in gnome terminal, terminator, konsole, kitty and a couple more I think. It ensures that selected text is always very easy to read and contrasts the background nicely (no matter the colors), since the selection is simply the user theme color swapped. I am used to it to the point, that I actually can't live without it 😅 I tried to implement this feature myself. I ran into an issue however, right now the selection in a line is rendered as a rectangle with a single color:
This feature would require that selection background color depends on the color of the text in front of it. So if you have a line with first white text, then red text, then more white text, that would require 3 separate rectangles each with its own color. I don't know the performance implications of this, I thought background color was rendered on a per character basis. How would I go about implementing this? |
if you're interested in working on this, the only changes you need to make are in the wezterm/wezterm-gui/src/termwindow/render/mod.rs Lines 201 to 213 in 45db43a
it is passed this set of information that encodes all of the pertinent information for that cell: wezterm/wezterm-gui/src/termwindow/render/mod.rs Lines 185 to 199 in 45db43a
|
Okay, I checked the The only place where selection background is drawn is with a color set in the config file, am I correct? wezterm/wezterm-gui/src/termwindow/render/screen_line.rs Lines 285 to 305 in 94ab049
I'd like to make selection background adapt to the foreground color of the text that selection covers. |
ah, then I think you'll need use wezterm/wezterm-gui/src/termwindow/render/screen_line.rs Lines 194 to 198 in 94ab049
the thing to be careful about here is that we paint the background first, then composite the selection rectangle over the top; the selection color can have an alpha component and blend together, so it isn't valid to simply draw the selection background instead of the main background. There needs to be two separate rectangles of different colors. They can be both draw in the same loop, so maybe the thing to try is adding a wezterm/wezterm-gui/src/termwindow/render/screen_line.rs Lines 261 to 263 in 94ab049
and using that to draw the selection color. Then this logic can be removed: wezterm/wezterm-gui/src/termwindow/render/screen_line.rs Lines 291 to 300 in 94ab049
|
This config option allows selection to behave similarly as the cursor does when force_reverse_video_cursor config option is set to true. With this new config set to true, selected text's foreground and background colors are swapped. Addresses issue wez#3440
Hey, I added a PR for this feature #4093. When the new config option I added is set to true, the selection behaves exactly as it does in Terminator (what I used before Wezterm). I left comments in the code, so hopefully my code makes sense. Let me know what you think about it. There is one more thing to address here and that is the cursor itself. When the cursor itself is selected, and force reverse video cursor config is enabled, colors should be swapped again for the cursor. Otherwise the cursor and the text is covers has the same color as the selection making it illegible. Here is the example of PR in action. Notice how the reverse video cursor is the same color as the selection itself. That needs fixing, otherwise I think it's perfect. |
This config option allows selection to behave similarly as the cursor does when force_reverse_video_cursor config option is set to true. With this new config set to true, selected text's foreground and background colors are swapped. Addresses issue wez#3440
This config option allows selection to behave similarly as the cursor does when force_reverse_video_cursor config option is set to true. With this new config set to true, selected text's foreground and background colors are swapped. Addresses issue wez#3440
This config option allows selection to behave similarly as the cursor does when force_reverse_video_cursor config option is set to true. With this new config set to true, selected text's foreground and background colors are swapped. Addresses issue wez#3440
Thank you for working on this @Tomiyou ! |
This config option allows selection to behave similarly as the cursor does when force_reverse_video_cursor config option is set to true. With this new config set to true, selected text's foreground and background colors are swapped. Addresses issue wez#3440
This config option allows selection to behave similarly as the cursor does when force_reverse_video_cursor config option is set to true. With this new config set to true, selected text's foreground and background colors are swapped. Addresses issue wez#3440
This config option allows selection to behave similarly as the cursor does when force_reverse_video_cursor config option is set to true. With this new config set to true, selected text's foreground and background colors are swapped. Addresses issue wez#3440
This config option allows selection to behave similarly as the cursor does when force_reverse_video_cursor config option is set to true. With this new config set to true, selected text's foreground and background colors are swapped. Addresses issue wez#3440
This config option allows selection to behave similarly as the cursor does when force_reverse_video_cursor config option is set to true. With this new config set to true, selected text's foreground and background colors are swapped. Addresses issue wez#3440
This config option allows selection to behave similarly as the cursor does when force_reverse_video_cursor config option is set to true. With this new config set to true, selected text's foreground and background colors are swapped. Addresses issue wez#3440
This config option allows selection to behave similarly as the cursor does when force_reverse_video_cursor config option is set to true. With this new config set to true, selected text's foreground and background colors are swapped. Addresses issue wez#3440
This config option allows selection to behave similarly as the cursor does when force_reverse_video_cursor config option is set to true. With this new config set to true, selected text's foreground and background colors are swapped. Addresses issue wez#3440
Hello,
Describe the solution you'd like
Following the Discussion #3432 , I would like for wezterm to be able to reverse fg and bg colors on selection like other terminal emulators can do. Since I was told no setting currently exists for this, I am opening this FR.
Additional context
Thank you!
The text was updated successfully, but these errors were encountered: