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

Invert selected text instead of highlighting #1628

Merged
1 commit merged into from Jul 12, 2020
Merged

Invert selected text instead of highlighting #1628

1 commit merged into from Jul 12, 2020

Conversation

kdrag0n
Copy link
Contributor

@kdrag0n kdrag0n commented Jul 4, 2020

Highlighting text in the terminal often makes it hard to read, which can be problematic for users who want to adjust or review selections before copying them. For example, the default theme makes white and green text hard to read on its light gray selection background, and there are plenty of other themes where the choice of text and cursor colors would hinder selection readability.

To fix this issue and make selected text more legible in nearly all combinations of colors, invert selected text instead of highlighting it. This is more common among terminal emulators anyway:

  • Invert: xterm, fbcon, kitty, Konsole, Alacritty, Tilix, gnome-terminal (7)
  • Highlight: Termux, Terminal.app, iTerm2, Windows Terminal (4)

Highlighting text in the terminal often makes it hard to read, which
can be problematic for users who want to adjust or review selections
before copying them. For example, the default theme makes white and
green text hard to read on its light gray selection background, and
there are plenty of other themes where the choice of text and cursor
colors would hinder selection readability.

To fix this issue and make selected text more legible in nearly all
combinations of colors, invert selected text instead of highlighting it.
This is more common among terminal emulators anyway:
    Invert:    xterm, fbcon, kitty, Konsole, Alacritty, Tilix,
               gnome-terminal (7)
    Highlight: Termux, Terminal.app, iTerm2, Windows Terminal (4)
@kdrag0n
Copy link
Contributor Author

kdrag0n commented Jul 4, 2020

Example of selected dmesg text:
Before:
image
After:
image

drawTextRun(canvas, line, palette, heightOffset, lastRunStartColumn, columnWidthSinceLastRun,
lastRunStartIndex, charsSinceLastRun, measuredWidthForRun,
cursorColor, cursorStyle, lastRunStyle, reverseVideo);
cursorColor, cursorShape, lastRunStyle, reverseVideo || lastRunInsideSelection);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't you effectively reverting your last PR (#1627) here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reverts the cursor style part but it still depends on the insideSelection logic from #1627. I chose to submit this separately since I wanted to fix the existing behavior first before changing anything.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, okay, and since you're drawing the selection by reversing video instead of by using the cursor it isn't necessary anymore.

@trygveaa
Copy link
Contributor

trygveaa commented Jul 4, 2020

Invert: kitty

Kitty uses a constant background color, not inverting. However it also uses a constant foreground color for selections, which removes the problem you're describing. Personally I prefer this because it's more clean (or maybe it's just because it's what I'm used to at this point).

@kdrag0n kdrag0n closed this Jul 5, 2020
@kdrag0n kdrag0n reopened this Jul 5, 2020
@kdrag0n
Copy link
Contributor Author

kdrag0n commented Jul 5, 2020

My bad; the kitty color scheme I'm using has the selection colors set to inverted white text, so I classified it as "invert."

I'm personally not a fan of constant colors because while it looks cleaner in some cases, sometimes I find it jarring for colors to disappear when I select text in kitty. It's particularly annoying when viewing something that relies on color differentiation to be clear, e.g. diff-so-pretty output or folder/file classification in ls.

(sorry for the closing and reopening spam, I accidentally clicked "close" while scrolling)

@ghost ghost merged commit 0910844 into termux:master Jul 12, 2020
@lzhiyong
Copy link

lzhiyong commented Aug 8, 2020

@xeffyr There is still a problem with inverting color in force dark mode on Android 10,
the background color of text selection is not obvious


Screenshot_2020-08-08-16-57-15-819_com termux

@ghost
Copy link

ghost commented Aug 8, 2020

@lzhiyong Because this improvememt was released in v0.96 which is still not available for installation.

I have dark mode on and also Android 10 - everything works, however I use custom Termux build with all latest features available.

@lzhiyong
Copy link

lzhiyong commented Aug 8, 2020

@xeffyr thank you for your reply, I think you can add a dark theme, or use the daynight theme, on Android 9, even if dark mode is turned on, the background color of DrawerLayout and dialog is still white, force dark mode requires Android 10 or higher.

@ghost
Copy link

ghost commented Aug 8, 2020

@lzhiyong Termux already has dark theme. Enable it manually as shown in #1681 (comment).

This pull request was closed.
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.

None yet

3 participants