@@ -1046,6 +1046,9 @@ static char* FormatCont(int c)
linebuffer = tempLineBuffer;
}
// Append the screen to the current line buffer. If in alternate screen mode, this appends the
// alternate screen to an empty line buffer. If not, this appends the base screen to the normal
// line buffer.
if (HEIGHT - new_height >= usedHeight) {
// Height is decreasing but pushing HEIGHT lines into the buffer would scroll all the used
// lines off the top, leaving the cursor floating without any text. Keep all used lines that
Loading
Loading
@@ -1062,47 +1065,35 @@ static char* FormatCont(int c)
[self _appendScreenToScrollback:HEIGHT];
}
}
THIS IS ALL FUCKED UP! When you are in alt screen mode, changing the size adds lots of garbage from the base screen into the scrollback buffer that shouldn't be there.
int altUsedHeight = 0;
int altScreenLinesAppended = 0;
if (temp_buffer) {
// In alternate screen mode.
screen_char_t *saved_buffer_lines = buffer_lines;
screen_char_t *saved_screen_top = screen_top;
int savedCursorY = cursorY;
int savedCursorX = cursorX;
// Use the "real" line buffer for the base screen.
// Append alt screen contents to primary line buffer so that we can get positions for selection ranges.
linebuffer = saved_line_buffer;
buffer_lines = temp_buffer;
screen_top = temp_buffer;
cursorX = SAVE_CURSOR_X;
cursorY = SAVE_CURSOR_Y;
altUsedHeight = [self _usedHeight];
if (HEIGHT - new_height >= altUsedHeight) {
// Append the screen to the current line buffer. If in alternate screen mode, this appends the
// alternate screen to an empty line buffer. If not, this appends the base screen to the normal
// line buffer.
if (HEIGHT - new_height >= usedHeight) {
// Height is decreasing but pushing HEIGHT lines into the buffer would scroll all the used
// lines off the top, leaving the cursor floating without any text. Keep all used lines that
@@ -1277,10 +1319,12 @@ static char* FormatCont(int c)
if (hasSelection &&
newSelStartY >= linesDropped &&
newSelEndY >= linesDropped) {
// TODO(georgen): There's a wee bug here. If you're in alternate screen mode and the screen becomes smaller, the top N lines are thrown away. That makes Y offsets below that point wrong and Y offsets within that range totally insanely wrong. The right thing to do would be to decrease offsets beneath that point by N.