mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-07 19:14:04 +08:00
Handle backspace across wrapped lines (closes #59)
This commit is contained in:
@@ -127,10 +127,14 @@ public final class TerminalBuffer {
|
|||||||
mLines[externalToInternalRow(row)].mLineWrap = true;
|
mLines[externalToInternalRow(row)].mLineWrap = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getLineWrap(int row) {
|
public boolean getLineWrap(int row) {
|
||||||
return mLines[externalToInternalRow(row)].mLineWrap;
|
return mLines[externalToInternalRow(row)].mLineWrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearLineWrap(int row) {
|
||||||
|
mLines[externalToInternalRow(row)].mLineWrap = false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resize the screen which this transcript backs. Currently, this only works if the number of columns does not
|
* Resize the screen which this transcript backs. Currently, this only works if the number of columns does not
|
||||||
* change or the rows expand (that is, it only works when shrinking the number of rows).
|
* change or the rows expand (that is, it only works when shrinking the number of rows).
|
||||||
|
@@ -475,7 +475,15 @@ public final class TerminalEmulator {
|
|||||||
mSession.onBell();
|
mSession.onBell();
|
||||||
break;
|
break;
|
||||||
case 8: // Backspace (BS, ^H).
|
case 8: // Backspace (BS, ^H).
|
||||||
setCursorCol(Math.max(mLeftMargin, mCursorCol - 1));
|
if (mLeftMargin == mCursorCol) {
|
||||||
|
// Jump to previous line if it was auto-wrapped.
|
||||||
|
if (mCursorRow > 0 && mScreen.getLineWrap(mCursorRow-1)) {
|
||||||
|
mScreen.clearLineWrap(mCursorRow - 1);
|
||||||
|
setCursorRowCol(mCursorRow-1,mRightMargin-1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setCursorCol(mCursorCol - 1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 9: // Horizontal tab (HT, \t) - move to next tab stop, but not past edge of screen
|
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
|
// XXX: Should perhaps use color if writing to new cells. Try with
|
||||||
|
@@ -218,4 +218,13 @@ public class CursorAndScreenTest extends TerminalTestCase {
|
|||||||
" -");
|
" -");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBackspaceAcrossWrappedLines() {
|
||||||
|
// Backspace should not go to previous line if not auto-wrapped:
|
||||||
|
withTerminalSized(3, 3).enterString("hi\r\n\b\byou").assertLinesAre("hi ", "you", " ");
|
||||||
|
// Backspace should go to previous line if auto-wrapped:
|
||||||
|
withTerminalSized(3, 3).enterString("hi y").assertLinesAre("hi ", "y ", " ").enterString("\b\b#").assertLinesAre("hi#", "y ", " ");
|
||||||
|
// Initial backspace should do nothing:
|
||||||
|
withTerminalSized(3, 3).enterString("\b\b\b\bhi").assertLinesAre("hi ", " ", " ");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user