Skip to content

Commit

Permalink
chore: revert "fix: cursor position adjustment after exiting alt scre…
Browse files Browse the repository at this point in the history
…en (#1241)"

This reverts commit 4ad0792.
  • Loading branch information
aymanbagabas committed Nov 22, 2024
1 parent 4ad0792 commit 2314d4c
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions standard_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ type standardRenderer struct {

// lines explicitly set not to render
ignoreLines map[int]struct{}

// lines rendered before entering alt screen mode
linesRenderedBeforeAltScreen int
}

// newRenderer creates a new renderer. Normally you'll want to initialize it
Expand Down Expand Up @@ -337,10 +334,6 @@ func (r *standardRenderer) enterAltScreen() {
r.altScreenActive = true
r.execute(ansi.EnableAltScreenBuffer)

// Save the current line count before entering the alternate screen mode.
// This allows us to compare and adjust the cursor position when exiting the alternate screen.
r.linesRenderedBeforeAltScreen = r.linesRendered

// Ensure that the terminal is cleared, even when it doesn't support
// alt screen (or alt screen support is disabled, like GNU screen by
// default).
Expand Down Expand Up @@ -373,18 +366,6 @@ func (r *standardRenderer) exitAltScreen() {
r.altScreenActive = false
r.execute(ansi.DisableAltScreenBuffer)

// Adjust cursor and screen
if r.linesRendered < r.linesRenderedBeforeAltScreen {
// If fewer lines were rendered in the alternate screen, move the cursor up
// to align with the previous normal screen position and clear any remaining lines.
r.execute(ansi.CursorUp(r.linesRenderedBeforeAltScreen - r.linesRendered))
r.execute(ansi.EraseScreenBelow)
} else if r.linesRendered > r.linesRenderedBeforeAltScreen && r.linesRenderedBeforeAltScreen > 0 {
// If more lines were rendered in the alternate screen, move the cursor down
// to align with the new position.
r.execute(ansi.CursorDown(r.linesRendered - r.linesRenderedBeforeAltScreen))
}

// cmd.exe and other terminals keep separate cursor states for the AltScreen
// and the main buffer. We have to explicitly reset the cursor visibility
// whenever we exit AltScreen.
Expand Down

0 comments on commit 2314d4c

Please sign in to comment.