mirror of
https://github.com/fankes/termux-app.git
synced 2025-10-24 12:49:20 +08:00
Invert selected text instead of highlighting
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)
This commit is contained in:
committed by
Leonid Pliushch
parent
f33ebf810f
commit
0910844896
@@ -117,11 +117,10 @@ public final class TerminalRenderer {
|
|||||||
} else {
|
} else {
|
||||||
final int columnWidthSinceLastRun = column - lastRunStartColumn;
|
final int columnWidthSinceLastRun = column - lastRunStartColumn;
|
||||||
final int charsSinceLastRun = currentCharIndex - lastRunStartIndex;
|
final int charsSinceLastRun = currentCharIndex - lastRunStartIndex;
|
||||||
int cursorColor = (lastRunInsideCursor || lastRunInsideSelection) ? mEmulator.mColors.mCurrentColors[TextStyle.COLOR_INDEX_CURSOR] : 0;
|
int cursorColor = lastRunInsideCursor ? mEmulator.mColors.mCurrentColors[TextStyle.COLOR_INDEX_CURSOR] : 0;
|
||||||
int cursorStyle = lastRunInsideSelection ? TerminalEmulator.CURSOR_STYLE_BLOCK : cursorShape;
|
|
||||||
drawTextRun(canvas, line, palette, heightOffset, lastRunStartColumn, columnWidthSinceLastRun,
|
drawTextRun(canvas, line, palette, heightOffset, lastRunStartColumn, columnWidthSinceLastRun,
|
||||||
lastRunStartIndex, charsSinceLastRun, measuredWidthForRun,
|
lastRunStartIndex, charsSinceLastRun, measuredWidthForRun,
|
||||||
cursorColor, cursorStyle, lastRunStyle, reverseVideo);
|
cursorColor, cursorShape, lastRunStyle, reverseVideo || lastRunInsideSelection);
|
||||||
}
|
}
|
||||||
measuredWidthForRun = 0.f;
|
measuredWidthForRun = 0.f;
|
||||||
lastRunStyle = style;
|
lastRunStyle = style;
|
||||||
@@ -143,10 +142,9 @@ public final class TerminalRenderer {
|
|||||||
|
|
||||||
final int columnWidthSinceLastRun = columns - lastRunStartColumn;
|
final int columnWidthSinceLastRun = columns - lastRunStartColumn;
|
||||||
final int charsSinceLastRun = currentCharIndex - lastRunStartIndex;
|
final int charsSinceLastRun = currentCharIndex - lastRunStartIndex;
|
||||||
int cursorColor = (lastRunInsideCursor || lastRunInsideSelection) ? mEmulator.mColors.mCurrentColors[TextStyle.COLOR_INDEX_CURSOR] : 0;
|
int cursorColor = lastRunInsideCursor ? mEmulator.mColors.mCurrentColors[TextStyle.COLOR_INDEX_CURSOR] : 0;
|
||||||
int cursorStyle = lastRunInsideSelection ? TerminalEmulator.CURSOR_STYLE_BLOCK : cursorShape;
|
|
||||||
drawTextRun(canvas, line, palette, heightOffset, lastRunStartColumn, columnWidthSinceLastRun, lastRunStartIndex, charsSinceLastRun,
|
drawTextRun(canvas, line, palette, heightOffset, lastRunStartColumn, columnWidthSinceLastRun, lastRunStartIndex, charsSinceLastRun,
|
||||||
measuredWidthForRun, cursorColor, cursorStyle, lastRunStyle, reverseVideo);
|
measuredWidthForRun, cursorColor, cursorShape, lastRunStyle, reverseVideo || lastRunInsideSelection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user