Skip to content

Commit

Permalink
feat: update cellbuf
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 committed Nov 13, 2024
1 parent 59e87bc commit c71ad13
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 22 deletions.
4 changes: 2 additions & 2 deletions examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand Down
12 changes: 8 additions & 4 deletions ferocious_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand Down
4 changes: 2 additions & 2 deletions tutorials/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tutorials/go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand Down

0 comments on commit c71ad13

Please sign in to comment.