Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(v2) x/ansi and x/cellbuf changes #1246

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions da1.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ type PrimaryDeviceAttributesMsg []int
func parsePrimaryDevAttrs(csi *ansi.CsiSequence) Msg {
// Primary Device Attributes
da1 := make(PrimaryDeviceAttributesMsg, len(csi.Params))
csi.Range(func(i int, p int, hasMore bool) bool {
if !hasMore {
da1[i] = p
for i, p := range csi.Params {
if !p.HasMore() {
da1[i] = p.Param(0)
}
return true
})
}
return da1
}
21 changes: 10 additions & 11 deletions examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ module examples
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/bubbles/v2 v2.0.0-alpha.2.0.20241121172047-bd415b4ebae8
github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20241121171714-fbd5423ea935
github.com/charmbracelet/colorprofile v0.1.8
github.com/charmbracelet/glamour v0.8.0
github.com/charmbracelet/harmonica v0.2.0
github.com/charmbracelet/lipgloss/v2 v2.0.0-alpha.2
github.com/charmbracelet/x/ansi v0.4.3
github.com/charmbracelet/lipgloss/v2 v2.0.0-alpha.2.0.20241121164047-8448a9be4804
github.com/charmbracelet/x/ansi v0.5.1
github.com/charmbracelet/x/exp/teatest/v2 v2.0.0-20241016014612-3b4d04043233
github.com/fogleman/ease v0.0.0-20170301025033-8da417bf1776
github.com/lucasb-eyer/go-colorful v1.2.0
Expand All @@ -23,15 +23,14 @@ 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 // indirect
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 // indirect
github.com/charmbracelet/x/input v0.2.0 // 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/term v0.2.1 // indirect
github.com/charmbracelet/x/vt v0.0.0-20241121165045-a3720547cbb4 // indirect
github.com/charmbracelet/x/wcwidth v0.0.0-20241113152101-0af7d04e9f32 // indirect
github.com/charmbracelet/x/windows v0.2.0 // indirect
github.com/dlclark/regexp2 v1.11.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
Expand All @@ -47,7 +46,7 @@ require (
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/text v0.20.0 // indirect
)

replace github.com/charmbracelet/bubbletea/v2 => ../
43 changes: 18 additions & 25 deletions examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,38 @@ github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWp
github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA=
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/charmbracelet/bubbles/v2 v2.0.0-alpha.1.0.20241031195835-cc9a7270283d h1:iXR9lgmZhwy9yrrCmmDv++akjSbZJs4Owzlbfoc9OrQ=
github.com/charmbracelet/bubbles/v2 v2.0.0-alpha.1.0.20241031195835-cc9a7270283d/go.mod h1:m1OsgLhZIiKx3O0R51XwnXwwm9vP/LFa8IBUMQiiZmw=
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/bubbles/v2 v2.0.0-alpha.2.0.20241121172047-bd415b4ebae8 h1:CRhvWh0cIainbY47znHAxzohyXDNmcmrp9ggjvn1cJk=
github.com/charmbracelet/bubbles/v2 v2.0.0-alpha.2.0.20241121172047-bd415b4ebae8/go.mod h1:fKcC1zxdgRjgg21XbRIf/bkSELpd9D9XKlHRCrhR1Tk=
github.com/charmbracelet/colorprofile v0.1.8 h1:PywDeXsiAzlPtkiiKgMEVLvb6nlEuKrMj9+FJBtj4jU=
github.com/charmbracelet/colorprofile v0.1.8/go.mod h1:+jpmObxZl1Dab3H3IMVIPSZTsKcFpjJUv97G0dLqM60=
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=
github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao=
github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw=
github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY=
github.com/charmbracelet/lipgloss/v2 v2.0.0-20241029194924-049a2d260c67 h1:t/4KovO/31pdh9e74EVGVSbIlcY3bG4lmtrL3pD4fgU=
github.com/charmbracelet/lipgloss/v2 v2.0.0-20241029194924-049a2d260c67/go.mod h1:EcAf9+4/UeilG4rNQmiRzrou258LAVjVK4YUh+BvfqQ=
github.com/charmbracelet/lipgloss/v2 v2.0.0-alpha.2 h1:Gp+S9hMymU6HmxD1dihbnoMOGwt6wDMMvf0jyw3gEc0=
github.com/charmbracelet/lipgloss/v2 v2.0.0-alpha.2/go.mod h1:72/7KVsLdRldv/CeBjZx6igXIZ9CFtBzQUmDEbhXZ3w=
github.com/charmbracelet/x/ansi v0.4.3 h1:wcdDrW0ejaaZGJxCyxVNzzmctqV+oARIudaFGQvsRkA=
github.com/charmbracelet/x/ansi v0.4.3/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/lipgloss/v2 v2.0.0-alpha.2.0.20241121164047-8448a9be4804 h1:7CYjb9YMZA4kMhLgGdtlXvq+nu1oyENpMyMQlTvqSFw=
github.com/charmbracelet/lipgloss/v2 v2.0.0-alpha.2.0.20241121164047-8448a9be4804/go.mod h1:F/6E/LGdH3eHCJf2rG8/O3CjlW8cZFL5YJCknJs1GkI=
github.com/charmbracelet/x/ansi v0.5.1 h1:+mg6abP9skvsu/JQZrIJ9Z/4O1YDnLVkpfutar3dUnc=
github.com/charmbracelet/x/ansi v0.5.1/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q=
github.com/charmbracelet/x/cellbuf v0.0.6 h1:pJUWN/G1jbt1Nj/+ILfC2/ABQoZzWu1vG73yHQEYELI=
github.com/charmbracelet/x/cellbuf v0.0.6/go.mod h1:d72o71glp8flkCz54PHLe3+nuw5u2v3UxmKqruUERWQ=
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=
github.com/charmbracelet/x/exp/teatest/v2 v2.0.0-20241016014612-3b4d04043233/go.mod h1:cw9df32BXdkcd0LzAHsFMmvXOsrrlDKazIW8PCq0cPM=
github.com/charmbracelet/x/input v0.2.0 h1:1Sv+y/flcqUfUH2PXNIDKDIdT2G8smOnGOgawqhwy8A=
github.com/charmbracelet/x/input v0.2.0/go.mod h1:KUSFIS6uQymtnr5lHVSOK9j8RvwTD4YHnWnzJUYnd/M=
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=
github.com/charmbracelet/x/wcwidth v0.0.0-20241011142426-46044092ad91/go.mod h1:Ey8PFmYwH+/td9bpiEx07Fdx9ZVkxfIjWXxBluxF4Nw=
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
github.com/charmbracelet/x/vt v0.0.0-20241121165045-a3720547cbb4 h1:EacjHxcQEEgOZ7TbkAU3b84hd1Bn5NwA8YV5uyJ9EI4=
github.com/charmbracelet/x/vt v0.0.0-20241121165045-a3720547cbb4/go.mod h1:1/jFoHl7/I4br0StC9OXXEondkK9qi3nUtKoqI35HcI=
github.com/charmbracelet/x/wcwidth v0.0.0-20241113152101-0af7d04e9f32 h1:14czE6R5CgOlvONsJYa2B1uTyLvXzGXpBqw2AyZeTh4=
github.com/charmbracelet/x/wcwidth v0.0.0-20241113152101-0af7d04e9f32/go.mod h1:hyua5CY63kyl7IfyIxv1SjVEqoKze/XmDkEglItuVjA=
github.com/charmbracelet/x/windows v0.2.0 h1:ilXA1GJjTNkgOm94CLPeSz7rar54jtFatdmoiONPuEw=
github.com/charmbracelet/x/windows v0.2.0/go.mod h1:ZibNFR49ZFqCXgP76sYanisxRyC+EYrBE7TTknD8s1s=
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
github.com/fogleman/ease v0.0.0-20170301025033-8da417bf1776 h1:VRIbnDWRmAh5yBdz+J6yFMF5vso1It6vn+WmM/5l7MA=
github.com/fogleman/ease v0.0.0-20170301025033-8da417bf1776/go.mod h1:9wvnDu3YOfxzWM9Cst40msBF1C2UdQgDv962oTxSuMs=
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
Expand Down Expand Up @@ -94,11 +88,10 @@ golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
2 changes: 1 addition & 1 deletion examples/list-fancy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func newStyles(darkBG bool) styles {
Background(lipgloss.Color("#25A065")).
Padding(0, 1),
statusMessage: lipgloss.NewStyle().
Foreground(lightDark("#04B575", "#04B575")),
Foreground(lightDark(lipgloss.Color("#04B575"), lipgloss.Color("#04B575"))),
}
}

Expand Down
4 changes: 2 additions & 2 deletions examples/paginator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ type styles struct {
func newStyles(bgIsDark bool) (s styles) {
lightDark := lipgloss.LightDark(bgIsDark)

s.activeDot = lipgloss.NewStyle().Foreground(lightDark("235", "252")).SetString("•")
s.inactiveDot = s.activeDot.Foreground(lightDark("250", "238")).SetString("•")
s.activeDot = lipgloss.NewStyle().Foreground(lightDark(lipgloss.Color("235"), lipgloss.Color("252"))).SetString("•")
s.inactiveDot = s.activeDot.Foreground(lightDark(lipgloss.Color("250"), lipgloss.Color("238"))).SetString("•")
return s
}

Expand Down
2 changes: 1 addition & 1 deletion examples/tabs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func newStyles(bgIsDark bool) *styles {

inactiveTabBorder := tabBorderWithBottom("┴", "─", "┴")
activeTabBorder := tabBorderWithBottom("┘", " ", "└")
highlightColor := lightDark("#874BFD", "#7D56F4")
highlightColor := lightDark(lipgloss.Color("#874BFD"), lipgloss.Color("#7D56F4"))

s := new(styles)
s.doc = lipgloss.NewStyle().
Expand Down
57 changes: 29 additions & 28 deletions ferocious_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/charmbracelet/colorprofile"
"github.com/charmbracelet/x/ansi"
"github.com/charmbracelet/x/cellbuf"
"github.com/charmbracelet/x/vt"
)

var undefPoint = image.Pt(-1, -1)
Expand All @@ -22,10 +23,10 @@ type cursor struct {

// screen represents a terminal screen.
type screen struct {
dirty map[int]int // keeps track of dirty cells
linew []int // keeps track of the width of each line
cellbuf.Buffer // the cell buffer
cur cursor // cursor state
dirty map[int]int // keeps track of dirty cells
linew []int // keeps track of the width of each line
cur cursor // cursor state
*vt.Buffer // the cell buffer
}

// isDirty returns true if the cell at the given position is dirty.
Expand All @@ -37,19 +38,15 @@ func (s *screen) isDirty(x, y int) bool {

// reset resets the screen to its initial state.
func (s *screen) reset() {
s.Buffer = cellbuf.Buffer{}
s.Buffer = vt.NewBuffer(0, 0)
s.dirty = make(map[int]int)
s.cur = cursor{}
s.linew = make([]int, 0)
}

// Set implements [cellbuf.Grid] and marks changed cells as dirty.
func (s *screen) SetCell(x, y int, cell cellbuf.Cell) (v bool) {
c, ok := s.Cell(x, y)
if !ok {
return
}

func (s *screen) SetCell(x, y int, cell *cellbuf.Cell) (v bool) {
c := s.Cell(x, y)
if c.Equal(cell) {
// Cells are the same, no need to update.
return
Expand Down Expand Up @@ -128,7 +125,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 +227,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 @@ -308,8 +309,8 @@ func (c *ferociousRenderer) update(msg Msg) {
}

case enableModeMsg:
switch string(msg) {
case ansi.AltScreenBufferMode.String():
switch ansi.DECMode(msg) {
case ansi.AltScreenSaveCursorMode:
if c.altScreen {
return
}
Expand All @@ -326,7 +327,7 @@ func (c *ferociousRenderer) update(msg Msg) {
// whenever we enter or leave AltScreen.
c.updateCursorVisibility()

case ansi.CursorEnableMode.String():
case ansi.TextCursorEnableMode:
if !c.cursorHidden {
return
}
Expand All @@ -335,8 +336,8 @@ func (c *ferociousRenderer) update(msg Msg) {
}

case disableModeMsg:
switch string(msg) {
case ansi.AltScreenBufferMode.String():
switch ansi.DECMode(msg) {
case ansi.AltScreenSaveCursorMode:
if !c.altScreen {
return
}
Expand All @@ -349,7 +350,7 @@ func (c *ferociousRenderer) update(msg Msg) {
// whenever we enter or leave AltScreen.
c.updateCursorVisibility()

case ansi.CursorEnableMode.String():
case ansi.TextCursorEnableMode:
if c.cursorHidden {
return
}
Expand All @@ -362,7 +363,7 @@ func (c *ferociousRenderer) update(msg Msg) {
}
}

var spaceCell = cellbuf.Cell{Content: " ", Width: 1}
var spaceCell = &cellbuf.Cell{Content: " ", Width: 1}

// changes commits the changes from the cell buffer using the dirty cells map
// and writes them to the internal buffer.
Expand All @@ -379,7 +380,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 All @@ -399,14 +400,15 @@ func (c *ferociousRenderer) changes() {
var segX int // The start position of the current segment.
var eraser bool // Whether we're erasing using spaces and no styles or links.
for x := 0; x < width; x++ {
cell, ok := c.scr.Cell(x, y)
if !ok || cell.Width == 0 {
cell := c.scr.Cell(x, y)
if cell.Width == 0 {
continue
}

// Convert the cell to respect the current color profile.
cell.Style = cell.Style.Convert(c.profile)
cell.Link = cell.Link.Convert(c.profile)
// TODO: ??
// cell.Style = cell.Style.Convert(c.profile)
// cell.Link = cell.Link.Convert(c.profile)

if !c.scr.isDirty(x, y) {
if seg != nil {
Expand Down Expand Up @@ -559,9 +561,8 @@ func (c *ferociousRenderer) moveCursor(x, y int) {
// OPTIM: We write the cell content under the cursor if it's the same
// style and link. This is more efficient than moving the cursor which
// costs at least 3 bytes [ansi.CursorRight].
cell, ok := c.scr.Cell(c.scr.cur.X, c.scr.cur.Y)
if ok &&
(cell.Style.Equal(c.pen) && cell.Link == c.link) {
cell := c.scr.Cell(c.scr.cur.X, c.scr.cur.Y)
if cell.Style.Equal(c.pen) && cell.Link == c.link {
c.buf.WriteString(cell.Content)
break
}
Expand Down
17 changes: 9 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ module github.com/charmbracelet/bubbletea/v2
go 1.18

require (
github.com/charmbracelet/colorprofile v0.1.6
github.com/charmbracelet/x/ansi v0.4.3
github.com/charmbracelet/x/cellbuf v0.0.3
github.com/charmbracelet/x/term v0.2.0
github.com/charmbracelet/colorprofile v0.1.8
github.com/charmbracelet/x/ansi v0.5.1
github.com/charmbracelet/x/cellbuf v0.0.6
github.com/charmbracelet/x/term v0.2.1
github.com/charmbracelet/x/vt v0.0.0-20241121165045-a3720547cbb4
github.com/charmbracelet/x/windows v0.2.0
github.com/muesli/cancelreader v0.2.2
github.com/rivo/uniseg v0.4.7
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e
golang.org/x/sync v0.8.0
golang.org/x/sys v0.26.0
golang.org/x/sync v0.9.0
golang.org/x/sys v0.27.0
)

require (
github.com/charmbracelet/x/wcwidth v0.0.0-20241011142426-46044092ad91 // indirect
github.com/charmbracelet/x/wcwidth v0.0.0-20241113152101-0af7d04e9f32 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/text v0.20.0 // indirect
)
Loading
Loading