diff --git a/go.mod b/go.mod index e128cba..36260cd 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22.0 require ( github.com/atotto/clipboard v0.1.4 - github.com/charmbracelet/bubbletea v1.2.2 + github.com/charmbracelet/bubbletea v1.2.3 github.com/spf13/cobra v1.8.1 github.com/tobischo/gokeepasslib/v3 v3.6.0 golang.org/x/term v0.26.0 diff --git a/go.sum b/go.sum index 996af91..d974bee 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= -github.com/charmbracelet/bubbletea v1.2.2 h1:EMz//Ky/aFS2uLcKqpCst5UOE6z5CFDGRsUpyXz0chs= -github.com/charmbracelet/bubbletea v1.2.2/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM= +github.com/charmbracelet/bubbletea v1.2.3 h1:d9MdMsANIYZB5pE1KkRqaUV6GfsiWm+/9z4fTuGVm9I= +github.com/charmbracelet/bubbletea v1.2.3/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM= github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg= github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo= github.com/charmbracelet/x/ansi v0.4.5 h1:LqK4vwBNaXw2AyGIICa5/29Sbdq58GbGdFngSexTdRM= diff --git a/vendor/github.com/charmbracelet/bubbletea/.gitignore b/vendor/github.com/charmbracelet/bubbletea/.gitignore index 9cc5235..abd7c06 100644 --- a/vendor/github.com/charmbracelet/bubbletea/.gitignore +++ b/vendor/github.com/charmbracelet/bubbletea/.gitignore @@ -20,3 +20,4 @@ tutorials/basics/basics tutorials/commands/commands .idea coverage.txt +dist/ diff --git a/vendor/github.com/charmbracelet/bubbletea/.goreleaser.yml b/vendor/github.com/charmbracelet/bubbletea/.goreleaser.yml index 40d9f29..3353d02 100644 --- a/vendor/github.com/charmbracelet/bubbletea/.goreleaser.yml +++ b/vendor/github.com/charmbracelet/bubbletea/.goreleaser.yml @@ -1,6 +1,5 @@ +# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json +version: 2 includes: - from_url: url: charmbracelet/meta/main/goreleaser-lib.yaml - -# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json - diff --git a/vendor/github.com/charmbracelet/bubbletea/standard_renderer.go b/vendor/github.com/charmbracelet/bubbletea/standard_renderer.go index f30fc35..aa8524b 100644 --- a/vendor/github.com/charmbracelet/bubbletea/standard_renderer.go +++ b/vendor/github.com/charmbracelet/bubbletea/standard_renderer.go @@ -57,6 +57,9 @@ 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 @@ -334,6 +337,10 @@ 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). @@ -366,6 +373,18 @@ 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. diff --git a/vendor/modules.txt b/vendor/modules.txt index c9a388f..eb80165 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -4,7 +4,7 @@ github.com/atotto/clipboard # github.com/aymanbagabas/go-osc52/v2 v2.0.1 ## explicit; go 1.16 github.com/aymanbagabas/go-osc52/v2 -# github.com/charmbracelet/bubbletea v1.2.2 +# github.com/charmbracelet/bubbletea v1.2.3 ## explicit; go 1.18 github.com/charmbracelet/bubbletea # github.com/charmbracelet/lipgloss v1.0.0