mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 02:35:19 +08:00
Fix tabs to not overwrite cells
This commit is contained in:
@@ -18,8 +18,8 @@ android {
|
||||
applicationId "com.termux"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 23
|
||||
versionCode 29
|
||||
versionName "0.29"
|
||||
versionCode 30
|
||||
versionName "0.30"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
@@ -474,15 +474,18 @@ public final class TerminalEmulator {
|
||||
else
|
||||
mSession.onBell();
|
||||
break;
|
||||
case 8: // BS
|
||||
case 8: // Backspace (BS, ^H).
|
||||
setCursorCol(Math.max(mLeftMargin, mCursorCol - 1));
|
||||
break;
|
||||
case 9: // Horizontal tab - move to next tab stop, but not past edge of screen
|
||||
int nextTabStop = nextTabStop(1);
|
||||
while (mCursorCol < nextTabStop) {
|
||||
// Emit newlines to get background color right.
|
||||
processCodePoint(' ');
|
||||
}
|
||||
case 9: // Horizontal tab (HT, \t) - move to next tab stop, but not past edge of screen
|
||||
// XXX: Should perhaps use color if writing to new cells. Try with
|
||||
// printf "\033[41m\tXX\033[0m\n"
|
||||
// The OSX Terminal.app colors the spaces from the tab red, but xterm does not.
|
||||
// Note that Terminal.app only colors on new cells, in e.g.
|
||||
// printf "\033[41m\t\r\033[42m\tXX\033[0m\n"
|
||||
// the first cells are created with a red background, but when tabbing over
|
||||
// them again with a green background they are not overwritten.
|
||||
mCursorCol = nextTabStop(1);
|
||||
break;
|
||||
case 10: // Line feed (LF, \n).
|
||||
case 11: // Vertical tab (VT, \v).
|
||||
|
@@ -163,7 +163,12 @@ public class CursorAndScreenTest extends TerminalTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testHorizontalTabColorsBackground() {
|
||||
/**
|
||||
* See comments on horizontal tab handling in TerminalEmulator.java.
|
||||
*
|
||||
* We do not want to color already written cells when tabbing over them.
|
||||
*/
|
||||
public void DISABLED_testHorizontalTabColorsBackground() {
|
||||
withTerminalSized(10, 3).enterString("\033[48;5;15m").enterString("\t");
|
||||
assertCursorAt(0, 8);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
@@ -258,4 +258,9 @@ public class TerminalTest extends TerminalTestCase {
|
||||
withTerminalSized(3, 3).enterString("abc\r ").assertLinesAre(" bc", " ", " ").assertCursorAt(0, 1);
|
||||
}
|
||||
|
||||
public void testTab() {
|
||||
withTerminalSized(11, 2).enterString("01234567890\r\tXX").assertLinesAre("01234567XX0", " ");
|
||||
withTerminalSized(11, 2).enterString("01234567890\033[44m\r\tXX").assertLinesAre("01234567XX0", " ");
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user