From 19c6134c712e3bd3c7b9cce67e29dad902d14d2d Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Thu, 19 Aug 2021 16:29:12 +0300 Subject: [PATCH 1/2] terminal: invert text color under block cursor Issue: https://github.com/termux/termux-app/issues/219 --- .../main/java/com/termux/view/TerminalRenderer.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/terminal-view/src/main/java/com/termux/view/TerminalRenderer.java b/terminal-view/src/main/java/com/termux/view/TerminalRenderer.java index f9c5b53aab..307e422694 100644 --- a/terminal-view/src/main/java/com/termux/view/TerminalRenderer.java +++ b/terminal-view/src/main/java/com/termux/view/TerminalRenderer.java @@ -118,9 +118,13 @@ public final void render(TerminalEmulator mEmulator, Canvas canvas, int topRow, final int columnWidthSinceLastRun = column - lastRunStartColumn; final int charsSinceLastRun = currentCharIndex - lastRunStartIndex; int cursorColor = lastRunInsideCursor ? mEmulator.mColors.mCurrentColors[TextStyle.COLOR_INDEX_CURSOR] : 0; + boolean invertCursorTextColor = false; + if (lastRunInsideCursor && cursorShape == TerminalEmulator.TERMINAL_CURSOR_STYLE_BLOCK) { + invertCursorTextColor = true; + } drawTextRun(canvas, line, palette, heightOffset, lastRunStartColumn, columnWidthSinceLastRun, lastRunStartIndex, charsSinceLastRun, measuredWidthForRun, - cursorColor, cursorShape, lastRunStyle, reverseVideo || lastRunInsideSelection); + cursorColor, cursorShape, lastRunStyle, reverseVideo || invertCursorTextColor || lastRunInsideSelection); } measuredWidthForRun = 0.f; lastRunStyle = style; @@ -143,8 +147,12 @@ public final void render(TerminalEmulator mEmulator, Canvas canvas, int topRow, final int columnWidthSinceLastRun = columns - lastRunStartColumn; final int charsSinceLastRun = currentCharIndex - lastRunStartIndex; int cursorColor = lastRunInsideCursor ? mEmulator.mColors.mCurrentColors[TextStyle.COLOR_INDEX_CURSOR] : 0; + boolean invertCursorTextColor = false; + if (lastRunInsideCursor && cursorShape == TerminalEmulator.TERMINAL_CURSOR_STYLE_BLOCK) { + invertCursorTextColor = true; + } drawTextRun(canvas, line, palette, heightOffset, lastRunStartColumn, columnWidthSinceLastRun, lastRunStartIndex, charsSinceLastRun, - measuredWidthForRun, cursorColor, cursorShape, lastRunStyle, reverseVideo || lastRunInsideSelection); + measuredWidthForRun, cursorColor, cursorShape, lastRunStyle, reverseVideo || invertCursorTextColor || lastRunInsideSelection); } } From 4a74618f17a65bcafba67b7bf85273390dfa64cb Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Thu, 19 Aug 2021 16:44:28 +0300 Subject: [PATCH 2/2] terminal: set default cursor color to white --- .../src/main/java/com/termux/terminal/TerminalColorScheme.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terminal-emulator/src/main/java/com/termux/terminal/TerminalColorScheme.java b/terminal-emulator/src/main/java/com/termux/terminal/TerminalColorScheme.java index 4fbb56df94..e4fd4e9c77 100644 --- a/terminal-emulator/src/main/java/com/termux/terminal/TerminalColorScheme.java +++ b/terminal-emulator/src/main/java/com/termux/terminal/TerminalColorScheme.java @@ -57,7 +57,7 @@ public final class TerminalColorScheme { 0xff808080, 0xff8a8a8a, 0xff949494, 0xff9e9e9e, 0xffa8a8a8, 0xffb2b2b2, 0xffbcbcbc, 0xffc6c6c6, 0xffd0d0d0, 0xffdadada, 0xffe4e4e4, 0xffeeeeee, // COLOR_INDEX_DEFAULT_FOREGROUND, COLOR_INDEX_DEFAULT_BACKGROUND and COLOR_INDEX_DEFAULT_CURSOR: - 0xffffffff, 0xff000000, 0xffA9AAA9}; + 0xffffffff, 0xff000000, 0xffffffff}; public final int[] mDefaultColors = new int[TextStyle.NUM_INDEXED_COLORS];