From 3d1e26b92d498a6845d70fc2a53a9ad221137907 Mon Sep 17 00:00:00 2001 From: Evgeny Zhabotinsky Date: Sun, 25 Sep 2022 05:25:14 +0300 Subject: [PATCH] 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 #2576 where in tmux scrolling one of several side-by-side panels down resulted in all visually scrolling. --- .../main/java/com/termux/terminal/TerminalEmulator.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/terminal-emulator/src/main/java/com/termux/terminal/TerminalEmulator.java b/terminal-emulator/src/main/java/com/termux/terminal/TerminalEmulator.java index 155baa7b76..86641fe365 100644 --- a/terminal-emulator/src/main/java/com/termux/terminal/TerminalEmulator.java +++ b/terminal-emulator/src/main/java/com/termux/terminal/TerminalEmulator.java @@ -1509,8 +1509,8 @@ private void doEsc(int b) { // http://www.vt100.net/docs/vt100-ug/chapter3.html: "Move the active position to the same horizontal // position on the preceding line. If the active position is at the top margin, a scroll down is performed". if (mCursorRow <= mTopMargin) { - mScreen.blockCopy(0, mTopMargin, mColumns, mBottomMargin - (mTopMargin + 1), 0, mTopMargin + 1); - blockClear(0, mTopMargin, mColumns); + mScreen.blockCopy(mLeftMargin, mTopMargin, mRightMargin - mLeftMargin, mBottomMargin - (mTopMargin + 1), mLeftMargin, mTopMargin + 1); + blockClear(mLeftMargin, mTopMargin, mRightMargin - mLeftMargin); } else { mCursorRow--; } @@ -1724,8 +1724,8 @@ private void doCsi(int b) { final int linesToScrollArg = getArg0(1); final int linesBetweenTopAndBottomMargins = mBottomMargin - mTopMargin; final int linesToScroll = Math.min(linesBetweenTopAndBottomMargins, linesToScrollArg); - mScreen.blockCopy(0, mTopMargin, mColumns, linesBetweenTopAndBottomMargins - linesToScroll, 0, mTopMargin + linesToScroll); - blockClear(0, mTopMargin, mColumns, linesToScroll); + mScreen.blockCopy(mLeftMargin, mTopMargin, mRightMargin - mLeftMargin, linesBetweenTopAndBottomMargins - linesToScroll, mLeftMargin, mTopMargin + linesToScroll); + blockClear(mLeftMargin, mTopMargin, mRightMargin - mLeftMargin, linesToScroll); } else { // "${CSI}${func};${startx};${starty};${firstrow};${lastrow}T" - initiate highlight mouse tracking. unimplementedSequence(b);