mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-08 03:24:04 +08:00
Fixed: Use current bg color when scrolling with horizontal margins
Fixes https://github.com/termux/termux-packages/issues/12556 Issue was also reported here: https://www.reddit.com/r/termux/comments/1df1dii/how_can_i_fix_this_annoying_screenfilling_thing/
This commit is contained in:
@@ -2092,13 +2092,14 @@ public final class TerminalEmulator {
|
|||||||
|
|
||||||
private void scrollDownOneLine() {
|
private void scrollDownOneLine() {
|
||||||
mScrollCounter++;
|
mScrollCounter++;
|
||||||
|
long currentStyle = getStyle();
|
||||||
if (mLeftMargin != 0 || mRightMargin != mColumns) {
|
if (mLeftMargin != 0 || mRightMargin != mColumns) {
|
||||||
// Horizontal margin: Do not put anything into scroll history, just non-margin part of screen up.
|
// Horizontal margin: Do not put anything into scroll history, just non-margin part of screen up.
|
||||||
mScreen.blockCopy(mLeftMargin, mTopMargin + 1, mRightMargin - mLeftMargin, mBottomMargin - mTopMargin - 1, mLeftMargin, mTopMargin);
|
mScreen.blockCopy(mLeftMargin, mTopMargin + 1, mRightMargin - mLeftMargin, mBottomMargin - mTopMargin - 1, mLeftMargin, mTopMargin);
|
||||||
// .. and blank bottom row between margins:
|
// .. and blank bottom row between margins:
|
||||||
mScreen.blockSet(mLeftMargin, mBottomMargin - 1, mRightMargin - mLeftMargin, 1, ' ', mEffect);
|
mScreen.blockSet(mLeftMargin, mBottomMargin - 1, mRightMargin - mLeftMargin, 1, ' ', currentStyle);
|
||||||
} else {
|
} else {
|
||||||
mScreen.scrollDownOneLine(mTopMargin, mBottomMargin, getStyle());
|
mScreen.scrollDownOneLine(mTopMargin, mBottomMargin, currentStyle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -127,4 +127,31 @@ public class ScrollRegionTest extends TerminalTestCase {
|
|||||||
" xxx"
|
" xxx"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See <a href="https://github.com/termux/termux-packages/issues/12556">reported issue</a>.
|
||||||
|
*/
|
||||||
|
public void testClearingWhenScrollingWithMargins() {
|
||||||
|
int newForeground = 2;
|
||||||
|
int newBackground = 3;
|
||||||
|
int size = 3;
|
||||||
|
TerminalTestCase terminal = withTerminalSized(size, size)
|
||||||
|
// Enable horizontal margin and set left margin to 1:
|
||||||
|
.enterString("\033[?69h\033[2s")
|
||||||
|
// Set foreground and background color:
|
||||||
|
.enterString("\033[" + (30 + newForeground) + ";" + (40 + newBackground) + "m")
|
||||||
|
// Enter newlines to scroll down:
|
||||||
|
.enterString("\r\n\r\n\r\n\r\n\r\n");
|
||||||
|
for (int row = 0; row < size; row++) {
|
||||||
|
for (int col = 0; col < size; col++) {
|
||||||
|
// The first column (outside of the scrolling area, due to us setting a left scroll
|
||||||
|
// margin of 1) should be unmodified, the others should use the current style:
|
||||||
|
int expectedForeground = col == 0 ? TextStyle.COLOR_INDEX_FOREGROUND : newForeground;
|
||||||
|
int expectedBackground = col == 0 ? TextStyle.COLOR_INDEX_BACKGROUND : newBackground;
|
||||||
|
terminal.assertForegroundColorAt(row, col, expectedForeground);
|
||||||
|
terminal.assertBackgroundColorAt(row, col, expectedBackground);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -301,6 +301,11 @@ public abstract class TerminalTestCase extends TestCase {
|
|||||||
assertEquals(color, TextStyle.decodeForeColor(style));
|
assertEquals(color, TextStyle.decodeForeColor(style));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void assertBackgroundColorAt(int externalRow, int column, int color) {
|
||||||
|
long style = mTerminal.getScreen().mLines[mTerminal.getScreen().externalToInternalRow(externalRow)].getStyle(column);
|
||||||
|
assertEquals(color, TextStyle.decodeBackColor(style));
|
||||||
|
}
|
||||||
|
|
||||||
public TerminalTestCase assertColor(int colorIndex, int expected) {
|
public TerminalTestCase assertColor(int colorIndex, int expected) {
|
||||||
int actual = mTerminal.mColors.mCurrentColors[colorIndex];
|
int actual = mTerminal.mColors.mCurrentColors[colorIndex];
|
||||||
if (expected != actual) {
|
if (expected != actual) {
|
||||||
|
Reference in New Issue
Block a user