Skip to content

Commit 1c23c7f

Browse files
evg-zhabotinskyzongou
authored andcommitted
Fixed: Make ScrollDown escape respect margins
SD sequence (`${CSI}${N}T`) was scrolling the whole width of the terminal instead of just between the margins. RI sequence (`${ESC}M`, move cursor up 1 line) was doing the same. Fixed that. Fixes termux#2576 where in tmux scrolling one of several side-by-side panels down resulted in all visually scrolling.
1 parent 09ca48a commit 1c23c7f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

terminal-emulator/src/main/java/com/termux/terminal/TerminalEmulator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,8 +1509,8 @@ private void doEsc(int b) {
15091509
// http://www.vt100.net/docs/vt100-ug/chapter3.html: "Move the active position to the same horizontal
15101510
// position on the preceding line. If the active position is at the top margin, a scroll down is performed".
15111511
if (mCursorRow <= mTopMargin) {
1512-
mScreen.blockCopy(0, mTopMargin, mColumns, mBottomMargin - (mTopMargin + 1), 0, mTopMargin + 1);
1513-
blockClear(0, mTopMargin, mColumns);
1512+
mScreen.blockCopy(mLeftMargin, mTopMargin, mRightMargin - mLeftMargin, mBottomMargin - (mTopMargin + 1), mLeftMargin, mTopMargin + 1);
1513+
blockClear(mLeftMargin, mTopMargin, mRightMargin - mLeftMargin);
15141514
} else {
15151515
mCursorRow--;
15161516
}
@@ -1724,8 +1724,8 @@ private void doCsi(int b) {
17241724
final int linesToScrollArg = getArg0(1);
17251725
final int linesBetweenTopAndBottomMargins = mBottomMargin - mTopMargin;
17261726
final int linesToScroll = Math.min(linesBetweenTopAndBottomMargins, linesToScrollArg);
1727-
mScreen.blockCopy(0, mTopMargin, mColumns, linesBetweenTopAndBottomMargins - linesToScroll, 0, mTopMargin + linesToScroll);
1728-
blockClear(0, mTopMargin, mColumns, linesToScroll);
1727+
mScreen.blockCopy(mLeftMargin, mTopMargin, mRightMargin - mLeftMargin, linesBetweenTopAndBottomMargins - linesToScroll, mLeftMargin, mTopMargin + linesToScroll);
1728+
blockClear(mLeftMargin, mTopMargin, mRightMargin - mLeftMargin, linesToScroll);
17291729
} else {
17301730
// "${CSI}${func};${startx};${starty};${firstrow};${lastrow}T" - initiate highlight mouse tracking.
17311731
unimplementedSequence(b);

0 commit comments

Comments
 (0)