From f2e01145fe92c9744d40f9fe87544df51a84a4dc Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Tue, 29 Oct 2024 12:30:58 -0400 Subject: [PATCH 01/15] docs(examples): fix panics in table-width example --- examples/table-resize/main.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/examples/table-resize/main.go b/examples/table-resize/main.go index 762211c0d4..01aae3f4f1 100644 --- a/examples/table-resize/main.go +++ b/examples/table-resize/main.go @@ -104,7 +104,12 @@ func main() { return headerStyle } - if rows[row-1][1] == "Pikachu" { + rowIndex := row - 1 + if rowIndex < 0 || rowIndex >= len(rows) { + return baseStyle + } + + if rows[rowIndex][1] == "Pikachu" { return selectedStyle } @@ -117,7 +122,14 @@ func main() { c = dimTypeColors } - color := c[fmt.Sprint(rows[row-1][col])] + if col >= len(rows[rowIndex]) { + return baseStyle + } + + color, ok := c[rows[rowIndex][col]] + if !ok { + return baseStyle + } return baseStyle.Foreground(color) } From 129d5ebad90a7462f7f5bb43eba9cac26d3e2ca9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:41:07 -0400 Subject: [PATCH 02/15] chore(deps): bump github.com/charmbracelet/x/ansi from 0.4.0 to 0.4.2 (#1214) Bumps [github.com/charmbracelet/x/ansi](https://github.com/charmbracelet/x) from 0.4.0 to 0.4.2. - [Release notes](https://github.com/charmbracelet/x/releases) - [Commits](https://github.com/charmbracelet/x/compare/ansi/v0.4.0...ansi/v0.4.2) --- updated-dependencies: - dependency-name: github.com/charmbracelet/x/ansi dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index fa0e943061..40449e3303 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/charmbracelet/lipgloss v0.13.1 - github.com/charmbracelet/x/ansi v0.4.0 + github.com/charmbracelet/x/ansi v0.4.2 github.com/charmbracelet/x/term v0.2.0 github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f github.com/mattn/go-localereader v0.0.1 diff --git a/go.sum b/go.sum index b9c3ac358b..fea46d58bd 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiE github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/charmbracelet/lipgloss v0.13.1 h1:Oik/oqDTMVA01GetT4JdEC033dNzWoQHdWnHnQmXE2A= github.com/charmbracelet/lipgloss v0.13.1/go.mod h1:zaYVJ2xKSKEnTEEbX6uAHabh2d975RJ+0yfkFpRBz5U= -github.com/charmbracelet/x/ansi v0.4.0 h1:NqwHA4B23VwsDn4H3VcNX1W1tOmgnvY1NDx5tOXdnOU= -github.com/charmbracelet/x/ansi v0.4.0/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/ansi v0.4.2 h1:0JM6Aj/g/KC154/gOP4vfxun0ff6itogDYk41kof+qk= +github.com/charmbracelet/x/ansi v0.4.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0= github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0= github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= From 0cef3c7896a8393f461c3d6c4ef7df5aefa77db1 Mon Sep 17 00:00:00 2001 From: Konstantin Antonov Date: Sat, 7 Sep 2024 03:48:39 +0200 Subject: [PATCH 03/15] feat(render): remove flickering --- standard_renderer.go | 64 ++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 47 deletions(-) diff --git a/standard_renderer.go b/standard_renderer.go index 0cb0ef374b..70943811ba 100644 --- a/standard_renderer.go +++ b/standard_renderer.go @@ -168,6 +168,9 @@ func (r *standardRenderer) flush() { // Output buffer buf := &bytes.Buffer{} + // Moving to the begining of the section, that we rendered. + buf.WriteString(ansi.CursorUp(r.linesRendered-1) + ansi.CursorLeft(r.width)) + newLines := strings.Split(r.buf.String(), "\n") // If we know the output's height, we can use it to determine how many @@ -179,64 +182,25 @@ func (r *standardRenderer) flush() { } numLinesThisFlush := len(newLines) - oldLines := strings.Split(r.lastRender, "\n") - skipLines := make(map[int]struct{}) flushQueuedMessages := len(r.queuedMessageLines) > 0 && !r.altScreenActive - // Clear any lines we painted in the last render. - if r.linesRendered > 0 { - for i := r.linesRendered - 1; i > 0; i-- { - // if we are clearing queued messages, we want to clear all lines, since - // printing messages allows for native terminal word-wrap, we - // don't have control over the queued lines - if flushQueuedMessages { - buf.WriteString(ansi.EraseEntireLine) - } else if (len(newLines) <= len(oldLines)) && (len(newLines) > i && len(oldLines) > i) && (newLines[i] == oldLines[i]) { - // If the number of lines we want to render hasn't increased and - // new line is the same as the old line we can skip rendering for - // this line as a performance optimization. - skipLines[i] = struct{}{} - } else if _, exists := r.ignoreLines[i]; !exists { - buf.WriteString(ansi.EraseEntireLine) - } - - buf.WriteString(ansi.CursorUp1) - } - - if _, exists := r.ignoreLines[0]; !exists { - // We need to return to the start of the line here to properly - // erase it. Going back the entire width of the terminal will - // usually be farther than we need to go, but terminal emulators - // will stop the cursor at the start of the line as a rule. - // - // We use this sequence in particular because it's part of the ANSI - // standard (whereas others are proprietary to, say, VT100/VT52). - // If cursor previous line (ESC[ + + F) were better supported - // we could use that above to eliminate this step. - buf.WriteString(ansi.CursorLeft(r.width)) - buf.WriteString(ansi.EraseEntireLine) - } - } - - // Merge the set of lines we're skipping as a rendering optimization with - // the set of lines we've explicitly asked the renderer to ignore. - for k, v := range r.ignoreLines { - skipLines[k] = v - } - if flushQueuedMessages { - // Dump the lines we've queued up for printing + // Dump the lines we've queued up for printing. for _, line := range r.queuedMessageLines { + + // Removing previousy rendered content at the end of line. + line = line + ansi.EraseLineRight + _, _ = buf.WriteString(line) _, _ = buf.WriteString("\r\n") } - // clear the queued message lines + // Clear the queued message lines. r.queuedMessageLines = []string{} } - // Paint new lines + // Paint new lines. for i := 0; i < len(newLines); i++ { - if _, skip := skipLines[i]; skip { + if _, skip := r.ignoreLines[i]; skip { // Unless this is the last line, move the cursor down. if i < len(newLines)-1 { buf.WriteString(ansi.CursorDown1) @@ -250,6 +214,9 @@ func (r *standardRenderer) flush() { line := newLines[i] + // Removing left over content from previous render at the end of the line. + line = line + ansi.EraseLineRight + // Truncate lines wider than the width of the window to avoid // wrapping, which will mess up rendering. If we don't have the // width of the window this will be ignored. @@ -270,6 +237,9 @@ func (r *standardRenderer) flush() { } r.linesRendered = numLinesThisFlush + // Clearing left over content from last render (if our new frame contains less lines). + buf.WriteString(ansi.EraseDisplayRight) + // Make sure the cursor is at the start of the last line to keep rendering // behavior consistent. if r.altScreenActive { From 2106895cd889c8d5a5b55048f340e6af2dc5b505 Mon Sep 17 00:00:00 2001 From: Konstantin Antonov Date: Sun, 8 Sep 2024 00:35:11 +0200 Subject: [PATCH 04/15] feat(render): update tests for non-flick rendering + optimisations --- screen_test.go | 18 +++++++++--------- standard_renderer.go | 19 ++++++++++++------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/screen_test.go b/screen_test.go index 728cd9779f..db46bb6a9f 100644 --- a/screen_test.go +++ b/screen_test.go @@ -14,47 +14,47 @@ func TestClearMsg(t *testing.T) { { name: "clear_screen", cmds: []Cmd{ClearScreen}, - expected: "\x1b[?25l\x1b[?2004h\x1b[2J\x1b[1;1H\rsuccess\r\n\x1b[D\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l", + expected: "\x1b[?25l\x1b[?2004h\x1b[2J\x1b[1;1H\rsuccess\x1b[0K\r\n\x1b[0K\x1b[D\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l", }, { name: "altscreen", cmds: []Cmd{EnterAltScreen, ExitAltScreen}, - expected: "\x1b[?25l\x1b[?2004h\x1b[?1049h\x1b[2J\x1b[1;1H\x1b[?25l\x1b[?1049l\x1b[?25l\rsuccess\r\n\x1b[D\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l", + expected: "\x1b[?25l\x1b[?2004h\x1b[?1049h\x1b[2J\x1b[1;1H\x1b[?25l\x1b[?1049l\x1b[?25l\rsuccess\x1b[0K\r\n\x1b[0K\x1b[D\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l", }, { name: "altscreen_autoexit", cmds: []Cmd{EnterAltScreen}, - expected: "\x1b[?25l\x1b[?2004h\x1b[?1049h\x1b[2J\x1b[1;1H\x1b[?25l\rsuccess\r\n\x1b[2;0H\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l\x1b[?1049l\x1b[?25h", + expected: "\x1b[?25l\x1b[?2004h\x1b[?1049h\x1b[2J\x1b[1;1H\x1b[?25l\rsuccess\x1b[0K\r\n\x1b[0K\x1b[2;0H\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l\x1b[?1049l\x1b[?25h", }, { name: "mouse_cellmotion", cmds: []Cmd{EnableMouseCellMotion}, - expected: "\x1b[?25l\x1b[?2004h\x1b[?1002h\x1b[?1006h\rsuccess\r\n\x1b[D\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l", + expected: "\x1b[?25l\x1b[?2004h\x1b[?1002h\x1b[?1006h\rsuccess\x1b[0K\r\n\x1b[0K\x1b[D\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l", }, { name: "mouse_allmotion", cmds: []Cmd{EnableMouseAllMotion}, - expected: "\x1b[?25l\x1b[?2004h\x1b[?1003h\x1b[?1006h\rsuccess\r\n\x1b[D\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l", + expected: "\x1b[?25l\x1b[?2004h\x1b[?1003h\x1b[?1006h\rsuccess\x1b[0K\r\n\x1b[0K\x1b[D\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l", }, { name: "mouse_disable", cmds: []Cmd{EnableMouseAllMotion, DisableMouse}, - expected: "\x1b[?25l\x1b[?2004h\x1b[?1003h\x1b[?1006h\x1b[?1002l\x1b[?1003l\x1b[?1006l\rsuccess\r\n\x1b[D\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l", + expected: "\x1b[?25l\x1b[?2004h\x1b[?1003h\x1b[?1006h\x1b[?1002l\x1b[?1003l\x1b[?1006l\rsuccess\x1b[0K\r\n\x1b[0K\x1b[D\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l", }, { name: "cursor_hide", cmds: []Cmd{HideCursor}, - expected: "\x1b[?25l\x1b[?2004h\x1b[?25l\rsuccess\r\n\x1b[D\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l", + expected: "\x1b[?25l\x1b[?2004h\x1b[?25l\rsuccess\x1b[0K\r\n\x1b[0K\x1b[D\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l", }, { name: "cursor_hideshow", cmds: []Cmd{HideCursor, ShowCursor}, - expected: "\x1b[?25l\x1b[?2004h\x1b[?25l\x1b[?25h\rsuccess\r\n\x1b[D\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l", + expected: "\x1b[?25l\x1b[?2004h\x1b[?25l\x1b[?25h\rsuccess\x1b[0K\r\n\x1b[0K\x1b[D\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l", }, { name: "bp_stop_start", cmds: []Cmd{DisableBracketedPaste, EnableBracketedPaste}, - expected: "\x1b[?25l\x1b[?2004h\x1b[?2004l\x1b[?2004h\rsuccess\r\n\x1b[D\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l", + expected: "\x1b[?25l\x1b[?2004h\x1b[?2004l\x1b[?2004h\rsuccess\x1b[0K\r\n\x1b[0K\x1b[D\x1b[2K\r\x1b[?2004l\x1b[?25h\x1b[?1002l\x1b[?1003l\x1b[?1006l", }, } diff --git a/standard_renderer.go b/standard_renderer.go index 70943811ba..4dbbd36ffb 100644 --- a/standard_renderer.go +++ b/standard_renderer.go @@ -161,15 +161,17 @@ func (r *standardRenderer) flush() { defer r.mtx.Unlock() if r.buf.Len() == 0 || r.buf.String() == r.lastRender { - // Nothing to do + // Nothing to do. return } - // Output buffer + // Output buffer. buf := &bytes.Buffer{} // Moving to the begining of the section, that we rendered. - buf.WriteString(ansi.CursorUp(r.linesRendered-1) + ansi.CursorLeft(r.width)) + if r.linesRendered > 0 { + buf.WriteString(ansi.CursorUp(r.linesRendered - 1)) + } newLines := strings.Split(r.buf.String(), "\n") @@ -214,7 +216,7 @@ func (r *standardRenderer) flush() { line := newLines[i] - // Removing left over content from previous render at the end of the line. + // Removing previousy rendered content at the end of line. line = line + ansi.EraseLineRight // Truncate lines wider than the width of the window to avoid @@ -235,10 +237,13 @@ func (r *standardRenderer) flush() { } } } - r.linesRendered = numLinesThisFlush - // Clearing left over content from last render (if our new frame contains less lines). - buf.WriteString(ansi.EraseDisplayRight) + // Clearing left over content from last render. + if r.linesRendered > numLinesThisFlush { + buf.WriteString(ansi.EraseDisplayRight) + } + + r.linesRendered = numLinesThisFlush // Make sure the cursor is at the start of the last line to keep rendering // behavior consistent. From 9ec9ad96056a4601d381f5a5538495574d6a8200 Mon Sep 17 00:00:00 2001 From: Konstantin Antonov Date: Sun, 8 Sep 2024 02:37:25 +0200 Subject: [PATCH 05/15] feat(render): fix typo --- standard_renderer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standard_renderer.go b/standard_renderer.go index 4dbbd36ffb..dba91877f3 100644 --- a/standard_renderer.go +++ b/standard_renderer.go @@ -168,7 +168,7 @@ func (r *standardRenderer) flush() { // Output buffer. buf := &bytes.Buffer{} - // Moving to the begining of the section, that we rendered. + // Moving to the beginning of the section, that we rendered. if r.linesRendered > 0 { buf.WriteString(ansi.CursorUp(r.linesRendered - 1)) } From e44d9c6af253dde1208d6eeaf3a86570cdd2e291 Mon Sep 17 00:00:00 2001 From: Konstantin Antonov Date: Sun, 15 Sep 2024 02:09:59 +0200 Subject: [PATCH 06/15] update golden output --- examples/simple/testdata/TestApp.golden | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/simple/testdata/TestApp.golden b/examples/simple/testdata/TestApp.golden index 413aee46d6..cb6dc1af96 100644 --- a/examples/simple/testdata/TestApp.golden +++ b/examples/simple/testdata/TestApp.golden @@ -1,5 +1,7 @@ -[?25l[?2004h Hi. This program will exit in 10 seconds. - -To quit sooner press ctrl-c, or press ctrl-z to suspend... -Hi. This program will exit in 9 seconds. - [?2004l[?25h[?1002l[?1003l[?1006l \ No newline at end of file +[?25l[?2004h Hi. This program will exit in 10 seconds. + +To quit sooner press ctrl-c, or press ctrl-z to suspend... +Hi. This program will exit in 9 seconds. + +To quit sooner press ctrl-c, or press ctrl-z to suspend... + [?2004l[?25h[?1002l[?1003l[?1006l \ No newline at end of file From 4f161cdb4b2fe0d3bc60e05b696bbc3adde0355e Mon Sep 17 00:00:00 2001 From: Konstantin Antonov Date: Mon, 16 Sep 2024 17:57:32 +0200 Subject: [PATCH 07/15] feat(render): upd EraseDisplayRight --- standard_renderer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standard_renderer.go b/standard_renderer.go index dba91877f3..f89e0be88c 100644 --- a/standard_renderer.go +++ b/standard_renderer.go @@ -240,7 +240,7 @@ func (r *standardRenderer) flush() { // Clearing left over content from last render. if r.linesRendered > numLinesThisFlush { - buf.WriteString(ansi.EraseDisplayRight) + buf.WriteString(ansi.EraseDisplayBelow) } r.linesRendered = numLinesThisFlush From 3dfbcd9c9bb79ea7faa7ab021d688da0d963fe4c Mon Sep 17 00:00:00 2001 From: Konstantin Antonov Date: Wed, 18 Sep 2024 04:11:09 +0200 Subject: [PATCH 08/15] feat(render): skipping lines from previous frame --- examples/simple/testdata/TestApp.golden | 4 +- standard_renderer.go | 53 ++++++++++++++----------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/examples/simple/testdata/TestApp.golden b/examples/simple/testdata/TestApp.golden index cb6dc1af96..6664a0eed0 100644 --- a/examples/simple/testdata/TestApp.golden +++ b/examples/simple/testdata/TestApp.golden @@ -2,6 +2,4 @@  To quit sooner press ctrl-c, or press ctrl-z to suspend... Hi. This program will exit in 9 seconds. - -To quit sooner press ctrl-c, or press ctrl-z to suspend... - [?2004l[?25h[?1002l[?1003l[?1006l \ No newline at end of file + [?2004l[?25h[?1002l[?1003l[?1006l \ No newline at end of file diff --git a/standard_renderer.go b/standard_renderer.go index f89e0be88c..48b44c4669 100644 --- a/standard_renderer.go +++ b/standard_renderer.go @@ -174,6 +174,7 @@ func (r *standardRenderer) flush() { } newLines := strings.Split(r.buf.String(), "\n") + oldLines := strings.Split(r.lastRender, "\n") // If we know the output's height, we can use it to determine how many // lines we can render. We drop lines from the top of the render buffer if @@ -202,39 +203,43 @@ func (r *standardRenderer) flush() { // Paint new lines. for i := 0; i < len(newLines); i++ { - if _, skip := r.ignoreLines[i]; skip { + canSkip := !flushQueuedMessages && // Queuing messages triggers repaint -> we don't have access to previous frame content. + len(oldLines) > i && oldLines[i] == newLines[i] // Previously rendered line is the same. + + if _, ignore := r.ignoreLines[i]; ignore || canSkip { // Unless this is the last line, move the cursor down. if i < len(newLines)-1 { buf.WriteString(ansi.CursorDown1) } - } else { - if i == 0 && r.lastRender == "" { - // On first render, reset the cursor to the start of the line - // before writing anything. - buf.WriteByte('\r') - } + continue + } - line := newLines[i] + if i == 0 && r.lastRender == "" { + // On first render, reset the cursor to the start of the line + // before writing anything. + buf.WriteByte('\r') + } - // Removing previousy rendered content at the end of line. - line = line + ansi.EraseLineRight + line := newLines[i] - // Truncate lines wider than the width of the window to avoid - // wrapping, which will mess up rendering. If we don't have the - // width of the window this will be ignored. - // - // Note that on Windows we only get the width of the window on - // program initialization, so after a resize this won't perform - // correctly (signal SIGWINCH is not supported on Windows). - if r.width > 0 { - line = ansi.Truncate(line, r.width, "") - } + // Removing previousy rendered content at the end of line. + line = line + ansi.EraseLineRight - _, _ = buf.WriteString(line) + // Truncate lines wider than the width of the window to avoid + // wrapping, which will mess up rendering. If we don't have the + // width of the window this will be ignored. + // + // Note that on Windows we only get the width of the window on + // program initialization, so after a resize this won't perform + // correctly (signal SIGWINCH is not supported on Windows). + if r.width > 0 { + line = ansi.Truncate(line, r.width, "") + } - if i < len(newLines)-1 { - _, _ = buf.WriteString("\r\n") - } + _, _ = buf.WriteString(line) + + if i < len(newLines)-1 { + _, _ = buf.WriteString("\r\n") } } From dcb05b0cb3cf982a351961c188b91c2f20daad15 Mon Sep 17 00:00:00 2001 From: Konstantin Antonov Date: Tue, 15 Oct 2024 22:31:40 +0200 Subject: [PATCH 09/15] fix single-line CursorUp(0) --- standard_renderer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standard_renderer.go b/standard_renderer.go index 48b44c4669..05e2f0e114 100644 --- a/standard_renderer.go +++ b/standard_renderer.go @@ -169,7 +169,7 @@ func (r *standardRenderer) flush() { buf := &bytes.Buffer{} // Moving to the beginning of the section, that we rendered. - if r.linesRendered > 0 { + if r.linesRendered > 1 { buf.WriteString(ansi.CursorUp(r.linesRendered - 1)) } From 9bafc58cc877f352240250bf2bf342ad900c8448 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Thu, 24 Oct 2024 12:42:46 -0400 Subject: [PATCH 10/15] fix: update standard_renderer.go --- standard_renderer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standard_renderer.go b/standard_renderer.go index 05e2f0e114..1121af88e5 100644 --- a/standard_renderer.go +++ b/standard_renderer.go @@ -245,7 +245,7 @@ func (r *standardRenderer) flush() { // Clearing left over content from last render. if r.linesRendered > numLinesThisFlush { - buf.WriteString(ansi.EraseDisplayBelow) + buf.WriteString(ansi.EraseScreenBelow) } r.linesRendered = numLinesThisFlush From af9690711ad76e8c662a1b56ecc0c940a9ae5837 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 15:58:27 -0400 Subject: [PATCH 11/15] chore(ci): sync golangci-lint config (#1221) Co-authored-by: aymanbagabas <3187948+aymanbagabas@users.noreply.github.com> --- .golangci-soft.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.golangci-soft.yml b/.golangci-soft.yml index 8783713710..8bd7c5c98a 100644 --- a/.golangci-soft.yml +++ b/.golangci-soft.yml @@ -36,5 +36,4 @@ linters: - govet - ineffassign - staticcheck - - typecheck - unused From 5f70edd7873cccfc82de75a624b1b28305c9be4e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:03:17 -0400 Subject: [PATCH 12/15] chore(ci): sync golangci-lint config (#1222) Co-authored-by: aymanbagabas <3187948+aymanbagabas@users.noreply.github.com> --- .golangci-soft.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.golangci-soft.yml b/.golangci-soft.yml index 8bd7c5c98a..d325d4fcc6 100644 --- a/.golangci-soft.yml +++ b/.golangci-soft.yml @@ -1,5 +1,6 @@ run: tests: false + issues-exit-code: 0 issues: include: From 2472d90201467bb911eb0ba37f4a9da69ad33209 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Thu, 31 Oct 2024 16:04:51 -0400 Subject: [PATCH 13/15] fix: remove unnecessary line break --- standard_renderer.go | 1 - 1 file changed, 1 deletion(-) diff --git a/standard_renderer.go b/standard_renderer.go index 1121af88e5..583e5b389e 100644 --- a/standard_renderer.go +++ b/standard_renderer.go @@ -190,7 +190,6 @@ func (r *standardRenderer) flush() { if flushQueuedMessages { // Dump the lines we've queued up for printing. for _, line := range r.queuedMessageLines { - // Removing previousy rendered content at the end of line. line = line + ansi.EraseLineRight From 3bbf24dec24acebdb32ef675cb9788c90206e911 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:19:21 -0400 Subject: [PATCH 14/15] chore(deps): bump github.com/charmbracelet/lipgloss in /examples (#1220) Bumps [github.com/charmbracelet/lipgloss](https://github.com/charmbracelet/lipgloss) from 0.13.1 to 1.0.0. - [Release notes](https://github.com/charmbracelet/lipgloss/releases) - [Changelog](https://github.com/charmbracelet/lipgloss/blob/master/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/lipgloss/compare/v0.13.1...v1.0.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/lipgloss dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- examples/go.mod | 4 ++-- examples/go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/go.mod b/examples/go.mod index 67f2c9adaa..5557aad7d5 100644 --- a/examples/go.mod +++ b/examples/go.mod @@ -9,7 +9,7 @@ require ( github.com/charmbracelet/bubbletea v1.1.0 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/harmonica v0.2.0 - github.com/charmbracelet/lipgloss v0.13.1 + github.com/charmbracelet/lipgloss v1.0.0 github.com/charmbracelet/x/exp/teatest v0.0.0-20240521184646-23081fb03b28 github.com/fogleman/ease v0.0.0-20170301025033-8da417bf1776 github.com/lucasb-eyer/go-colorful v1.2.0 @@ -22,7 +22,7 @@ require ( github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymanbagabas/go-udiff v0.2.0 // indirect github.com/aymerick/douceur v0.2.0 // indirect - github.com/charmbracelet/x/ansi v0.4.0 // indirect + github.com/charmbracelet/x/ansi v0.4.2 // indirect github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b // indirect github.com/charmbracelet/x/term v0.2.0 // indirect github.com/dlclark/regexp2 v1.11.0 // indirect diff --git a/examples/go.sum b/examples/go.sum index a5d1e5b3ed..2c3de2dc45 100644 --- a/examples/go.sum +++ b/examples/go.sum @@ -20,10 +20,10 @@ github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ= github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao= -github.com/charmbracelet/lipgloss v0.13.1 h1:Oik/oqDTMVA01GetT4JdEC033dNzWoQHdWnHnQmXE2A= -github.com/charmbracelet/lipgloss v0.13.1/go.mod h1:zaYVJ2xKSKEnTEEbX6uAHabh2d975RJ+0yfkFpRBz5U= -github.com/charmbracelet/x/ansi v0.4.0 h1:NqwHA4B23VwsDn4H3VcNX1W1tOmgnvY1NDx5tOXdnOU= -github.com/charmbracelet/x/ansi v0.4.0/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +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.2 h1:0JM6Aj/g/KC154/gOP4vfxun0ff6itogDYk41kof+qk= +github.com/charmbracelet/x/ansi v0.4.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b h1:MnAMdlwSltxJyULnrYbkZpp4k58Co7Tah3ciKhSNo0Q= github.com/charmbracelet/x/exp/golden v0.0.0-20240815200342-61de596daa2b/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/teatest v0.0.0-20240521184646-23081fb03b28 h1:sOWKNRjt8uOEVgPiJVIJCse1+mUDM2F/vYY6W0Go640= From d6aee5bd5f9492b96f31969a09d1c38f21532120 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:19:40 -0400 Subject: [PATCH 15/15] chore(deps): bump github.com/charmbracelet/lipgloss from 0.13.1 to 1.0.0 (#1219) Bumps [github.com/charmbracelet/lipgloss](https://github.com/charmbracelet/lipgloss) from 0.13.1 to 1.0.0. - [Release notes](https://github.com/charmbracelet/lipgloss/releases) - [Changelog](https://github.com/charmbracelet/lipgloss/blob/master/.goreleaser.yml) - [Commits](https://github.com/charmbracelet/lipgloss/compare/v0.13.1...v1.0.0) --- updated-dependencies: - dependency-name: github.com/charmbracelet/lipgloss dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 40449e3303..cec66a6a70 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/charmbracelet/bubbletea go 1.18 require ( - github.com/charmbracelet/lipgloss v0.13.1 + github.com/charmbracelet/lipgloss v1.0.0 github.com/charmbracelet/x/ansi v0.4.2 github.com/charmbracelet/x/term v0.2.0 github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f diff --git a/go.sum b/go.sum index fea46d58bd..fb191d19a8 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ 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/lipgloss v0.13.1 h1:Oik/oqDTMVA01GetT4JdEC033dNzWoQHdWnHnQmXE2A= -github.com/charmbracelet/lipgloss v0.13.1/go.mod h1:zaYVJ2xKSKEnTEEbX6uAHabh2d975RJ+0yfkFpRBz5U= +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.2 h1:0JM6Aj/g/KC154/gOP4vfxun0ff6itogDYk41kof+qk= github.com/charmbracelet/x/ansi v0.4.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4hwm0x0=