From c71ad13e23d65439b74d57973213fb307d9e2b3b Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 13 Nov 2024 10:41:42 -0300 Subject: [PATCH] feat: update cellbuf Signed-off-by: Carlos Alexandro Becker --- examples/go.mod | 4 ++-- examples/go.sum | 8 ++++---- ferocious_renderer.go | 12 ++++++++---- go.mod | 4 ++-- go.sum | 8 ++++---- tutorials/go.mod | 4 ++-- tutorials/go.sum | 8 ++++---- 7 files changed, 26 insertions(+), 22 deletions(-) diff --git a/examples/go.mod b/examples/go.mod index 623813254a..4b19ba6785 100644 --- a/examples/go.mod +++ b/examples/go.mod @@ -5,7 +5,7 @@ go 1.23.1 require ( github.com/charmbracelet/bubbles/v2 v2.0.0-alpha.2 github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2 - github.com/charmbracelet/colorprofile v0.1.6 + github.com/charmbracelet/colorprofile v0.1.7 github.com/charmbracelet/glamour v0.8.0 github.com/charmbracelet/harmonica v0.2.0 github.com/charmbracelet/lipgloss/v2 v2.0.0-alpha.2 @@ -23,7 +23,7 @@ require ( github.com/aymanbagabas/go-udiff v0.2.0 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/charmbracelet/lipgloss v0.13.0 // indirect - github.com/charmbracelet/x/cellbuf v0.0.3 // indirect + github.com/charmbracelet/x/cellbuf v0.0.6-0.20241110171603-a30b032a5ae2 // indirect github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 // indirect github.com/charmbracelet/x/term v0.2.0 // indirect github.com/charmbracelet/x/wcwidth v0.0.0-20241011142426-46044092ad91 // indirect diff --git a/examples/go.sum b/examples/go.sum index b477ab8bd2..beb3d1ff4a 100644 --- a/examples/go.sum +++ b/examples/go.sum @@ -16,8 +16,8 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/charmbracelet/bubbles/v2 v2.0.0-alpha.2 h1:Oevn3XNNcccbI8m6cOI6rAMsY1niKsDMv55qtejWRXE= github.com/charmbracelet/bubbles/v2 v2.0.0-alpha.2/go.mod h1:BWGE1i9NQA60C720gn2FYOyRyJp2BVtQNVfai7wcMoM= -github.com/charmbracelet/colorprofile v0.1.6 h1:nMMqCns0c0DfCwNGdagBh6SxutFqkltSxxKk5S9kt+Y= -github.com/charmbracelet/colorprofile v0.1.6/go.mod h1:3EMXDxwRDJl0c17eJ1jX99MhtlP9OxE/9Qw0C5lvyUg= +github.com/charmbracelet/colorprofile v0.1.7 h1:q7PtMQrRBBnLNE2EbtbNUtouu979EivKcDGGaimhyO8= +github.com/charmbracelet/colorprofile v0.1.7/go.mod h1:d3UYToTrNmsD2p9/lbiya16H1WahndM0miDlJWXWf4U= github.com/charmbracelet/glamour v0.8.0 h1:tPrjL3aRcQbn++7t18wOpgLyl8wrOHUEDS7IZ68QtZs= github.com/charmbracelet/glamour v0.8.0/go.mod h1:ViRgmKkf3u5S7uakt2czJ272WSg2ZenlYEZXT2x7Bjw= github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ= @@ -28,8 +28,8 @@ github.com/charmbracelet/lipgloss/v2 v2.0.0-alpha.2 h1:Gp+S9hMymU6HmxD1dihbnoMOG github.com/charmbracelet/lipgloss/v2 v2.0.0-alpha.2/go.mod h1:72/7KVsLdRldv/CeBjZx6igXIZ9CFtBzQUmDEbhXZ3w= github.com/charmbracelet/x/ansi v0.4.6-0.20241110171603-a30b032a5ae2 h1:iW1rX9FDCWBSIusGCmCLQdd2f9gN9c88KJyvCt1EsRA= github.com/charmbracelet/x/ansi v0.4.6-0.20241110171603-a30b032a5ae2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= -github.com/charmbracelet/x/cellbuf v0.0.3 h1:HapUUjlo0pZ7iGijrTer1f4X8Uvq17l0zR+80Oh+iJg= -github.com/charmbracelet/x/cellbuf v0.0.3/go.mod h1:SF8R3AqchNzYKKJCFT7co8wt1HgQDfAitQ+SBoxWLNc= +github.com/charmbracelet/x/cellbuf v0.0.6-0.20241110171603-a30b032a5ae2 h1:Tya33mYdX3mi/BAWaw3M2CB8gq6OoZOEiDCTYW25lqg= +github.com/charmbracelet/x/cellbuf v0.0.6-0.20241110171603-a30b032a5ae2/go.mod h1:+a10wKGeO6TKYBbvxCfQEEgn5knWzoZtLf00oiXgvBg= github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ= github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/teatest/v2 v2.0.0-20241016014612-3b4d04043233 h1:2bTR/MtnJuq9RrCZSPwCOO34YSDByKL6nzXQMnsKK6U= diff --git a/ferocious_renderer.go b/ferocious_renderer.go index cb02a21831..42d6aaca15 100644 --- a/ferocious_renderer.go +++ b/ferocious_renderer.go @@ -55,7 +55,7 @@ func (s *screen) SetCell(x, y int, cell cellbuf.Cell) (v bool) { return } - v = s.Buffer.SetCell(x, y, cell) + v = s.Buffer.Draw(x, y, cell) if v { // Mark the cell as dirty. You nasty one ;) idx := y*s.Width() + x @@ -128,7 +128,11 @@ func (c *ferociousRenderer) close() error { seq += "\r" c.scr.cur.X = 0 } - if _, line := cellbuf.RenderLineWithProfile(c.scr, y, c.profile); line != "" { + + if _, line := cellbuf.RenderLine( + c.scr, y, + cellbuf.WithRenderProfile(c.profile), + ); line != "" { // OPTIM: We only clear the line if there's content on it. seq += ansi.EraseEntireLine } @@ -226,7 +230,7 @@ func (c *ferociousRenderer) render(s string) { // Ensure the buffer is at least the height of the new frame. height := cellbuf.Height(s) c.scr.Resize(c.scr.Width(), height) - linew := cellbuf.SetContent(c.scr, c.method, s) + linew := cellbuf.Paint(c.scr, c.method, s, nil) c.scr.linew = linew } @@ -379,7 +383,7 @@ func (c *ferociousRenderer) changes() { var x int for y := 0; y < height; y++ { var line string - x, line = cellbuf.RenderLineWithProfile(c.scr, y, c.profile) + x, line = cellbuf.RenderLine(c.scr, y, cellbuf.WithRenderProfile(c.profile)) c.buf.WriteString(line) if y < height-1 { x = 0 diff --git a/go.mod b/go.mod index 0dd2580b3e..936e7f2a47 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module github.com/charmbracelet/bubbletea/v2 go 1.18 require ( - github.com/charmbracelet/colorprofile v0.1.6 + github.com/charmbracelet/colorprofile v0.1.7 github.com/charmbracelet/x/ansi v0.4.6-0.20241110171603-a30b032a5ae2 - github.com/charmbracelet/x/cellbuf v0.0.3 + github.com/charmbracelet/x/cellbuf v0.0.6-0.20241110171603-a30b032a5ae2 github.com/charmbracelet/x/term v0.2.0 github.com/charmbracelet/x/windows v0.2.0 github.com/muesli/cancelreader v0.2.2 diff --git a/go.sum b/go.sum index 6e5e252f4b..93279f7a0e 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,9 @@ -github.com/charmbracelet/colorprofile v0.1.6 h1:nMMqCns0c0DfCwNGdagBh6SxutFqkltSxxKk5S9kt+Y= -github.com/charmbracelet/colorprofile v0.1.6/go.mod h1:3EMXDxwRDJl0c17eJ1jX99MhtlP9OxE/9Qw0C5lvyUg= +github.com/charmbracelet/colorprofile v0.1.7 h1:q7PtMQrRBBnLNE2EbtbNUtouu979EivKcDGGaimhyO8= +github.com/charmbracelet/colorprofile v0.1.7/go.mod h1:d3UYToTrNmsD2p9/lbiya16H1WahndM0miDlJWXWf4U= github.com/charmbracelet/x/ansi v0.4.6-0.20241110171603-a30b032a5ae2 h1:iW1rX9FDCWBSIusGCmCLQdd2f9gN9c88KJyvCt1EsRA= github.com/charmbracelet/x/ansi v0.4.6-0.20241110171603-a30b032a5ae2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= -github.com/charmbracelet/x/cellbuf v0.0.3 h1:HapUUjlo0pZ7iGijrTer1f4X8Uvq17l0zR+80Oh+iJg= -github.com/charmbracelet/x/cellbuf v0.0.3/go.mod h1:SF8R3AqchNzYKKJCFT7co8wt1HgQDfAitQ+SBoxWLNc= +github.com/charmbracelet/x/cellbuf v0.0.6-0.20241110171603-a30b032a5ae2 h1:Tya33mYdX3mi/BAWaw3M2CB8gq6OoZOEiDCTYW25lqg= +github.com/charmbracelet/x/cellbuf v0.0.6-0.20241110171603-a30b032a5ae2/go.mod h1:+a10wKGeO6TKYBbvxCfQEEgn5knWzoZtLf00oiXgvBg= 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/charmbracelet/x/wcwidth v0.0.0-20241011142426-46044092ad91 h1:D5OO0lVavz7A+Swdhp62F9gbkibxmz9B2hZ/jVdMPf0= diff --git a/tutorials/go.mod b/tutorials/go.mod index 357e5f9273..783451a166 100644 --- a/tutorials/go.mod +++ b/tutorials/go.mod @@ -5,9 +5,9 @@ go 1.18 require github.com/charmbracelet/bubbletea/v2 v2.0.0-20240918180721-14cb6b5de1d2 require ( - github.com/charmbracelet/colorprofile v0.1.6 // indirect + github.com/charmbracelet/colorprofile v0.1.7 // indirect github.com/charmbracelet/x/ansi v0.4.6-0.20241110171603-a30b032a5ae2 // indirect - github.com/charmbracelet/x/cellbuf v0.0.3 // indirect + github.com/charmbracelet/x/cellbuf v0.0.6-0.20241110171603-a30b032a5ae2 // indirect github.com/charmbracelet/x/term v0.2.0 // indirect github.com/charmbracelet/x/wcwidth v0.0.0-20241011142426-46044092ad91 // indirect github.com/charmbracelet/x/windows v0.2.0 // indirect diff --git a/tutorials/go.sum b/tutorials/go.sum index 6e5e252f4b..93279f7a0e 100644 --- a/tutorials/go.sum +++ b/tutorials/go.sum @@ -1,9 +1,9 @@ -github.com/charmbracelet/colorprofile v0.1.6 h1:nMMqCns0c0DfCwNGdagBh6SxutFqkltSxxKk5S9kt+Y= -github.com/charmbracelet/colorprofile v0.1.6/go.mod h1:3EMXDxwRDJl0c17eJ1jX99MhtlP9OxE/9Qw0C5lvyUg= +github.com/charmbracelet/colorprofile v0.1.7 h1:q7PtMQrRBBnLNE2EbtbNUtouu979EivKcDGGaimhyO8= +github.com/charmbracelet/colorprofile v0.1.7/go.mod h1:d3UYToTrNmsD2p9/lbiya16H1WahndM0miDlJWXWf4U= github.com/charmbracelet/x/ansi v0.4.6-0.20241110171603-a30b032a5ae2 h1:iW1rX9FDCWBSIusGCmCLQdd2f9gN9c88KJyvCt1EsRA= github.com/charmbracelet/x/ansi v0.4.6-0.20241110171603-a30b032a5ae2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= -github.com/charmbracelet/x/cellbuf v0.0.3 h1:HapUUjlo0pZ7iGijrTer1f4X8Uvq17l0zR+80Oh+iJg= -github.com/charmbracelet/x/cellbuf v0.0.3/go.mod h1:SF8R3AqchNzYKKJCFT7co8wt1HgQDfAitQ+SBoxWLNc= +github.com/charmbracelet/x/cellbuf v0.0.6-0.20241110171603-a30b032a5ae2 h1:Tya33mYdX3mi/BAWaw3M2CB8gq6OoZOEiDCTYW25lqg= +github.com/charmbracelet/x/cellbuf v0.0.6-0.20241110171603-a30b032a5ae2/go.mod h1:+a10wKGeO6TKYBbvxCfQEEgn5knWzoZtLf00oiXgvBg= 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/charmbracelet/x/wcwidth v0.0.0-20241011142426-46044092ad91 h1:D5OO0lVavz7A+Swdhp62F9gbkibxmz9B2hZ/jVdMPf0=