mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-05 02:05:25 +08:00
Do not scroll when below bottom margin
This commit is contained in:
@@ -1192,12 +1192,20 @@ public final class TerminalEmulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void doLinefeed() {
|
private void doLinefeed() {
|
||||||
|
boolean belowScrollingRegion = mCursorRow >= mBottomMargin;
|
||||||
int newCursorRow = mCursorRow + 1;
|
int newCursorRow = mCursorRow + 1;
|
||||||
if (newCursorRow >= mBottomMargin) {
|
if (belowScrollingRegion) {
|
||||||
scrollDownOneLine();
|
// Move down (but not scroll) as long as we are above the last row.
|
||||||
newCursorRow = mBottomMargin - 1;
|
if (mCursorRow != mRows - 1) {
|
||||||
|
setCursorRow(newCursorRow);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (newCursorRow == mBottomMargin) {
|
||||||
|
scrollDownOneLine();
|
||||||
|
newCursorRow = mBottomMargin - 1;
|
||||||
|
}
|
||||||
|
setCursorRow(newCursorRow);
|
||||||
}
|
}
|
||||||
setCursorRow(newCursorRow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void continueSequence(int state) {
|
private void continueSequence(int state) {
|
||||||
@@ -1571,7 +1579,7 @@ public final class TerminalEmulator {
|
|||||||
break;
|
break;
|
||||||
case 'r': // "CSI${top};${bottom}r" - set top and bottom Margins (DECSTBM).
|
case 'r': // "CSI${top};${bottom}r" - set top and bottom Margins (DECSTBM).
|
||||||
{
|
{
|
||||||
// http://www.vt100.net/docs/vt510-rm/DECSTBM
|
// https://vt100.net/docs/vt510-rm/DECSTBM.html
|
||||||
// The top margin defaults to 1, the bottom margin defaults to mRows.
|
// The top margin defaults to 1, the bottom margin defaults to mRows.
|
||||||
// The escape sequence numbers top 1..23, but we number top 0..22.
|
// The escape sequence numbers top 1..23, but we number top 0..22.
|
||||||
// The escape sequence numbers bottom 2..24, and so do we (because we use a zero based numbering
|
// The escape sequence numbers bottom 2..24, and so do we (because we use a zero based numbering
|
||||||
|
@@ -98,4 +98,13 @@ public class ScrollRegionTest extends TerminalTestCase {
|
|||||||
withTerminalSized(2, 5).enterString("1\r\n2\r\n3\r\n4\r\n5").assertLinesAre("1 ", "2 ", "3 ", "4 ", "5 ");
|
withTerminalSized(2, 5).enterString("1\r\n2\r\n3\r\n4\r\n5").assertLinesAre("1 ", "2 ", "3 ", "4 ", "5 ");
|
||||||
enterString("\033[3r").enterString("\033[2T").assertLinesAre("1 ", "2 ", " ", " ", "3 ");
|
enterString("\033[3r").enterString("\033[2T").assertLinesAre("1 ", "2 ", " ", " ", "3 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testScrollDownBelowScrollRegion() {
|
||||||
|
withTerminalSized(2, 5).enterString("1\r\n2\r\n3\r\n4\r\n5").assertLinesAre("1 ", "2 ", "3 ", "4 ", "5 ");
|
||||||
|
enterString("\033[1;3r"); // DECSTBM margins.
|
||||||
|
enterString("\033[4;1H"); // Place cursor just below bottom margin.
|
||||||
|
enterString("QQ\r\nRR\r\n\r\n\r\nYY");
|
||||||
|
assertLinesAre("1 ", "2 ", "3 ", "QQ", "YY");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user