From 3ec7fd4fe4b4a6e2effe5c081843f12a1e891146 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 22:18:12 -0300 Subject: [PATCH 01/14] chore(deps): bump golangci/golangci-lint-action from 5 to 6 (#522) Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 5 to 6. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/v5...v6) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action 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> --- .github/workflows/lint-soft.yml | 2 +- .github/workflows/lint.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint-soft.yml b/.github/workflows/lint-soft.yml index cd79f53..2eb2526 100644 --- a/.github/workflows/lint-soft.yml +++ b/.github/workflows/lint-soft.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v4 - name: golangci-lint - uses: golangci/golangci-lint-action@v5 + uses: golangci/golangci-lint-action@v6 with: # Optional: golangci-lint command line arguments. args: --config .golangci-soft.yml --issues-exit-code=0 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7e45846..86612f0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v4 - name: golangci-lint - uses: golangci/golangci-lint-action@v5 + uses: golangci/golangci-lint-action@v6 with: # Optional: golangci-lint command line arguments. #args: From 3b924571706b57c05be7b33e1dbcdc4b7496bcca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 22:18:47 -0300 Subject: [PATCH 02/14] feat(deps): bump github.com/charmbracelet/bubbletea (#525) Bumps [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) from 0.25.0 to 0.26.2. - [Release notes](https://github.com/charmbracelet/bubbletea/releases) - [Commits](https://github.com/charmbracelet/bubbletea/compare/v0.25.0...v0.26.2) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbletea dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 12 ++++++------ go.sum | 26 +++++++++++++------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index 2400211..f698eba 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/MakeNowJust/heredoc v1.0.0 github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d github.com/atotto/clipboard v0.1.4 - github.com/charmbracelet/bubbletea v0.25.0 + github.com/charmbracelet/bubbletea v0.26.2 github.com/charmbracelet/harmonica v0.2.0 github.com/charmbracelet/lipgloss v0.10.0 github.com/dustin/go-humanize v1.0.1 @@ -20,14 +20,14 @@ require ( require ( github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect - github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect + github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/mattn/go-isatty v0.0.18 // indirect github.com/mattn/go-localereader v0.0.1 // indirect - github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect + github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect - golang.org/x/sync v0.1.0 // indirect - golang.org/x/sys v0.12.0 // indirect - golang.org/x/term v0.6.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.20.0 // indirect + golang.org/x/term v0.20.0 // indirect golang.org/x/text v0.3.8 // indirect ) diff --git a/go.sum b/go.sum index 4684261..b9c4188 100644 --- a/go.sum +++ b/go.sum @@ -6,16 +6,16 @@ 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 v0.25.0 h1:bAfwk7jRz7FKFl9RzlIULPkStffg5k6pNt5dywy4TcM= -github.com/charmbracelet/bubbletea v0.25.0/go.mod h1:EN3QDR1T5ZdWmdfDzYcqOCAps45+QIJbLOBxmVNWNNg= +github.com/charmbracelet/bubbletea v0.26.2 h1:Eeb+n75Om9gQ+I6YpbCXQRKHt5Pn4vMwusQpwLiEgJQ= +github.com/charmbracelet/bubbletea v0.26.2/go.mod h1:6I0nZ3YHUrQj7YHIHlM8RySX4ZIthTliMY+W8X8b+Gs= 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.10.0 h1:KWeXFSexGcfahHX+54URiZGkBFazf70JNMtwg/AFW3s= github.com/charmbracelet/lipgloss v0.10.0/go.mod h1:Wig9DSfvANsxqkRsqj6x87irdy123SR4dOXlKa91ciE= -github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY= -github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= 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/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= @@ -27,8 +27,8 @@ github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+Ei github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b h1:1XF24mVaiu7u+CFywTdcDo2ie1pzzhwjt6RHqzpMU34= -github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho= +github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI= +github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo= github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA= github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= @@ -41,13 +41,13 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/sahilm/fuzzy v0.1.1 h1:ceu5RHF8DGgoi+/dR5PsECjCDH1BE3Fnmpo7aVXOdRA= github.com/sahilm/fuzzy v0.1.1/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.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.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= +golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= From 50b0bb0f3b53c58f1bcf6cb50671882f0b4b6e73 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 14 May 2024 22:21:14 -0300 Subject: [PATCH 03/14] docs: fix typo Signed-off-by: Carlos Alexandro Becker --- progress/progress.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/progress/progress.go b/progress/progress.go index d5a4c5a..8728de9 100644 --- a/progress/progress.go +++ b/progress/progress.go @@ -309,7 +309,7 @@ func (m Model) barView(b *strings.Builder, percent float64, textWidth int) { if fw == 1 { // this is up for debate: in a gradient of width=1, should the // single character rendered be the first color, the last color - // or exactly 50% inbetween? I opted for 50% + // or exactly 50% in between? I opted for 50% p = 0.5 } else if m.scaleRamp { p = float64(i) / float64(fw-1) From e84ce79497b7aeeb5e207d348889816e8124a516 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Wed, 22 May 2024 11:49:10 -0400 Subject: [PATCH 04/14] chore(ci): enable gofumpt --- .golangci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.golangci.yml b/.golangci.yml index a5a91d0..3affce9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,6 +16,7 @@ linters: enable: - bodyclose - exportloopref + - gofumpt - goimports - gosec - nilerr From 14a62710fc1cd45d42ddc1d3fd28d222b336a820 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Thu, 23 May 2024 15:01:01 -0400 Subject: [PATCH 05/14] fix(textarea): use x/ansi to strip ansi sequences --- textarea/textarea_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/textarea/textarea_test.go b/textarea/textarea_test.go index d0381a7..792f28c 100644 --- a/textarea/textarea_test.go +++ b/textarea/textarea_test.go @@ -6,9 +6,9 @@ import ( "unicode" "github.com/MakeNowJust/heredoc" - "github.com/acarl005/stripansi" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/x/ansi" ) func TestVerticalScrolling(t *testing.T) { @@ -1326,7 +1326,7 @@ func sendString(m Model, str string) Model { } func stripString(str string) string { - s := stripansi.Strip(str) + s := ansi.Strip(str) ss := strings.Split(s, "\n") var lines []string From 3e827603f3631c5f3e2f8df4b93e3cf59bd4fb87 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Thu, 23 May 2024 15:00:18 -0400 Subject: [PATCH 06/14] chore: upgrade dependencies --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index f698eba..c0d02d4 100644 --- a/go.mod +++ b/go.mod @@ -4,11 +4,11 @@ go 1.18 require ( github.com/MakeNowJust/heredoc v1.0.0 - github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d github.com/atotto/clipboard v0.1.4 github.com/charmbracelet/bubbletea v0.26.2 github.com/charmbracelet/harmonica v0.2.0 - github.com/charmbracelet/lipgloss v0.10.0 + github.com/charmbracelet/lipgloss v0.11.0 + github.com/charmbracelet/x/ansi v0.1.1 github.com/dustin/go-humanize v1.0.1 github.com/lucasb-eyer/go-colorful v1.2.0 github.com/mattn/go-runewidth v0.0.15 @@ -22,7 +22,7 @@ require ( github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-localereader v0.0.1 // indirect github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect diff --git a/go.sum b/go.sum index b9c4188..b512d7e 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= -github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8= -github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= @@ -10,8 +8,10 @@ github.com/charmbracelet/bubbletea v0.26.2 h1:Eeb+n75Om9gQ+I6YpbCXQRKHt5Pn4vMwus github.com/charmbracelet/bubbletea v0.26.2/go.mod h1:6I0nZ3YHUrQj7YHIHlM8RySX4ZIthTliMY+W8X8b+Gs= 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.10.0 h1:KWeXFSexGcfahHX+54URiZGkBFazf70JNMtwg/AFW3s= -github.com/charmbracelet/lipgloss v0.10.0/go.mod h1:Wig9DSfvANsxqkRsqj6x87irdy123SR4dOXlKa91ciE= +github.com/charmbracelet/lipgloss v0.11.0 h1:UoAcbQ6Qml8hDwSWs0Y1cB5TEQuZkDPH/ZqwWWYTG4g= +github.com/charmbracelet/lipgloss v0.11.0/go.mod h1:1UdRTH9gYgpcdNN5oBtjbu/IzNKtzVtb7sqN1t9LNn8= +github.com/charmbracelet/x/ansi v0.1.1 h1:CGAduulr6egay/YVbGc8Hsu8deMg1xZ/bkaXTPi1JDk= +github.com/charmbracelet/x/ansi v0.1.1/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= 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= @@ -20,8 +20,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= -github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= -github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= From e1ea5dc5289658bf043a697d0bb01fb3cc5c3d76 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Thu, 23 May 2024 15:13:44 -0400 Subject: [PATCH 07/14] refactor: switch to x/ansi for text manipulation (#505) Need to be consistent with Lipgloss and https://github.com/charmbracelet/lipgloss/pull/279 --- go.mod | 2 +- list/defaultitem.go | 8 ++++---- list/list.go | 9 ++++----- progress/progress.go | 4 ++-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index c0d02d4..31768e6 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,6 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/lucasb-eyer/go-colorful v1.2.0 github.com/mattn/go-runewidth v0.0.15 - github.com/muesli/reflow v0.3.0 github.com/muesli/termenv v0.15.2 github.com/rivo/uniseg v0.4.7 github.com/sahilm/fuzzy v0.1.1 @@ -26,6 +25,7 @@ require ( github.com/mattn/go-localereader v0.0.1 // indirect github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect + github.com/muesli/reflow v0.3.0 // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.20.0 // indirect golang.org/x/term v0.20.0 // indirect diff --git a/list/defaultitem.go b/list/defaultitem.go index 5474c00..ce98dd3 100644 --- a/list/defaultitem.go +++ b/list/defaultitem.go @@ -8,7 +8,7 @@ import ( "github.com/charmbracelet/bubbles/key" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" - "github.com/muesli/reflow/truncate" + "github.com/charmbracelet/x/ansi" ) // DefaultItemStyles defines styling for a default list item. @@ -155,15 +155,15 @@ func (d DefaultDelegate) Render(w io.Writer, m Model, index int, item Item) { } // Prevent text from exceeding list width - textwidth := uint(m.width - s.NormalTitle.GetPaddingLeft() - s.NormalTitle.GetPaddingRight()) - title = truncate.StringWithTail(title, textwidth, ellipsis) + textwidth := m.width - s.NormalTitle.GetPaddingLeft() - s.NormalTitle.GetPaddingRight() + title = ansi.Truncate(title, textwidth, ellipsis) if d.ShowDescription { var lines []string for i, line := range strings.Split(desc, "\n") { if i >= d.height-1 { break } - lines = append(lines, truncate.StringWithTail(line, textwidth, ellipsis)) + lines = append(lines, ansi.Truncate(line, textwidth, ellipsis)) } desc = strings.Join(lines, "\n") } diff --git a/list/list.go b/list/list.go index af360d1..573e76a 100644 --- a/list/list.go +++ b/list/list.go @@ -17,8 +17,7 @@ import ( "github.com/charmbracelet/bubbles/textinput" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" - "github.com/muesli/reflow/ansi" - "github.com/muesli/reflow/truncate" + "github.com/charmbracelet/x/ansi" "github.com/sahilm/fuzzy" ) @@ -1075,7 +1074,7 @@ func (m Model) titleView() string { // Status message if m.filterState != Filtering { view += " " + m.statusMessage - view = truncate.StringWithTail(view, uint(m.width-spinnerWidth), ellipsis) + view = ansi.Truncate(view, m.width-spinnerWidth, ellipsis) } } @@ -1126,7 +1125,7 @@ func (m Model) statusView() string { if filtered { f := strings.TrimSpace(m.FilterInput.Value()) - f = truncate.StringWithTail(f, 10, "…") + f = ansi.Truncate(f, 10, "…") status += fmt.Sprintf("“%s” ", f) } @@ -1151,7 +1150,7 @@ func (m Model) paginationView() string { // If the dot pagination is wider than the width of the window // use the arabic paginator. - if ansi.PrintableRuneWidth(s) > m.width { + if ansi.StringWidth(s) > m.width { m.Paginator.Type = paginator.Arabic s = m.Styles.ArabicPagination.Render(m.Paginator.View()) } diff --git a/progress/progress.go b/progress/progress.go index 8728de9..fa04635 100644 --- a/progress/progress.go +++ b/progress/progress.go @@ -10,8 +10,8 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/harmonica" "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/x/ansi" "github.com/lucasb-eyer/go-colorful" - "github.com/muesli/reflow/ansi" "github.com/muesli/termenv" ) @@ -283,7 +283,7 @@ func (m Model) View() string { func (m Model) ViewAs(percent float64) string { b := strings.Builder{} percentView := m.percentageView(percent) - m.barView(&b, percent, ansi.PrintableRuneWidth(percentView)) + m.barView(&b, percent, ansi.StringWidth(percentView)) b.WriteString(percentView) return b.String() } From 5b33bdbff601c6dce0792f95ac9949a7d3d3ebc7 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Thu, 23 May 2024 15:21:20 -0400 Subject: [PATCH 08/14] chore: upgrade dependencies --- go.mod | 8 +++++--- go.sum | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 31768e6..225a2d4 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/MakeNowJust/heredoc v1.0.0 github.com/atotto/clipboard v0.1.4 - github.com/charmbracelet/bubbletea v0.26.2 + github.com/charmbracelet/bubbletea v0.26.3 github.com/charmbracelet/harmonica v0.2.0 github.com/charmbracelet/lipgloss v0.11.0 github.com/charmbracelet/x/ansi v0.1.1 @@ -19,15 +19,17 @@ require ( require ( github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect + github.com/charmbracelet/x/input v0.1.0 // indirect + github.com/charmbracelet/x/term v0.1.1 // indirect + github.com/charmbracelet/x/windows v0.1.0 // indirect github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-localereader v0.0.1 // indirect github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect - github.com/muesli/reflow v0.3.0 // indirect + github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.20.0 // indirect - golang.org/x/term v0.20.0 // indirect golang.org/x/text v0.3.8 // indirect ) diff --git a/go.sum b/go.sum index b512d7e..e92ed4e 100644 --- a/go.sum +++ b/go.sum @@ -4,14 +4,20 @@ 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 v0.26.2 h1:Eeb+n75Om9gQ+I6YpbCXQRKHt5Pn4vMwusQpwLiEgJQ= -github.com/charmbracelet/bubbletea v0.26.2/go.mod h1:6I0nZ3YHUrQj7YHIHlM8RySX4ZIthTliMY+W8X8b+Gs= +github.com/charmbracelet/bubbletea v0.26.3 h1:iXyGvI+FfOWqkB2V07m1DF3xxQijxjY2j8PqiXYqasg= +github.com/charmbracelet/bubbletea v0.26.3/go.mod h1:bpZHfDHTYJC5g+FBK+ptJRCQotRC+Dhh3AoMxa/2+3Q= 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.11.0 h1:UoAcbQ6Qml8hDwSWs0Y1cB5TEQuZkDPH/ZqwWWYTG4g= github.com/charmbracelet/lipgloss v0.11.0/go.mod h1:1UdRTH9gYgpcdNN5oBtjbu/IzNKtzVtb7sqN1t9LNn8= github.com/charmbracelet/x/ansi v0.1.1 h1:CGAduulr6egay/YVbGc8Hsu8deMg1xZ/bkaXTPi1JDk= github.com/charmbracelet/x/ansi v0.1.1/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/input v0.1.0 h1:TEsGSfZYQyOtp+STIjyBq6tpRaorH0qpwZUj8DavAhQ= +github.com/charmbracelet/x/input v0.1.0/go.mod h1:ZZwaBxPF7IG8gWWzPUVqHEtWhc1+HXJPNuerJGRGZ28= +github.com/charmbracelet/x/term v0.1.1 h1:3cosVAiPOig+EV4X9U+3LDgtwwAoEzJjNdwbXDjF6yI= +github.com/charmbracelet/x/term v0.1.1/go.mod h1:wB1fHt5ECsu3mXYusyzcngVWWlu1KKUmmLhfgr/Flxw= +github.com/charmbracelet/x/windows v0.1.0 h1:gTaxdvzDM5oMa/I2ZNF7wN78X/atWemG9Wph7Ika2k4= +github.com/charmbracelet/x/windows v0.1.0/go.mod h1:GLEO/l+lizvFDBPLIOk+49gdX49L9YWMB5t+DZd0jkQ= 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= @@ -24,30 +30,27 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= -github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI= github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo= github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA= github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= -github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= -github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8= github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo= github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8= -github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/sahilm/fuzzy v0.1.1 h1:ceu5RHF8DGgoi+/dR5PsECjCDH1BE3Fnmpo7aVXOdRA= github.com/sahilm/fuzzy v0.1.1/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y= +github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= +github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= +golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.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.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= -golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= From 613d1cb46e03194efae6da7c450f3502c3c7520e Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Sun, 28 Apr 2024 02:22:33 -0500 Subject: [PATCH 09/14] fix(help): Fix help bubble not centering correctly --- help/help.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/help/help.go b/help/help.go index 8e5f77f..edb5a47 100644 --- a/help/help.go +++ b/help/help.go @@ -215,9 +215,8 @@ func (m Model) FullHelpView(groups [][]key.Binding) string { if m.Width > 0 && totalWidth > m.Width { break } + out = append(out, sep) } - - out = append(out, sep) } return lipgloss.JoinHorizontal(lipgloss.Top, out...) From 620ca7dfa9fee23c2b01b153bdd3a913591a42d7 Mon Sep 17 00:00:00 2001 From: Garrett Martin Date: Thu, 23 May 2024 14:37:59 -0700 Subject: [PATCH 10/14] fix: default textarea EndOfBufferCharacter should be ' ' (#510) --- textarea/textarea.go | 2 +- textarea/textarea_test.go | 292 +++++++++++++++++++------------------- 2 files changed, 147 insertions(+), 147 deletions(-) diff --git a/textarea/textarea.go b/textarea/textarea.go index 6421681..a830efd 100644 --- a/textarea/textarea.go +++ b/textarea/textarea.go @@ -259,7 +259,7 @@ func New() Model { FocusedStyle: focusedStyle, BlurredStyle: blurredStyle, cache: memoization.NewMemoCache[line, [][]rune](defaultMaxHeight), - EndOfBufferCharacter: '~', + EndOfBufferCharacter: ' ', ShowLineNumbers: true, Cursor: cur, KeyMap: DefaultKeyMap, diff --git a/textarea/textarea_test.go b/textarea/textarea_test.go index 792f28c..770e997 100644 --- a/textarea/textarea_test.go +++ b/textarea/textarea_test.go @@ -342,11 +342,11 @@ func TestView(t *testing.T) { want: want{ view: heredoc.Doc(` > 1 Hello, World! - > ~ - > ~ - > ~ - > ~ - > ~ + > + > + > + > + > `), }, }, @@ -360,11 +360,11 @@ func TestView(t *testing.T) { want: want{ view: heredoc.Doc(` > 1 the first line - > ~ - > ~ - > ~ - > ~ - > ~ + > + > + > + > + > `), cursorRow: 0, cursorCol: 14, @@ -382,9 +382,9 @@ func TestView(t *testing.T) { > 1 the first line > 2 the second line > 3 the third line - > ~ - > ~ - > ~ + > + > + > `), cursorRow: 2, cursorCol: 14, @@ -401,11 +401,11 @@ func TestView(t *testing.T) { want: want{ view: heredoc.Doc(` > the first line - > ~ - > ~ - > ~ - > ~ - > ~ + > + > + > + > + > `), cursorRow: 0, cursorCol: 14, @@ -424,9 +424,9 @@ func TestView(t *testing.T) { > the first line > the second line > the third line - > ~ - > ~ - > ~ + > + > + > `), cursorRow: 2, cursorCol: 14, @@ -529,11 +529,11 @@ func TestView(t *testing.T) { want: want{ view: heredoc.Doc(` * 1 the first line - * ~ - * ~ - * ~ - * ~ - * ~ + * + * + * + * + * `), cursorRow: 0, cursorCol: 14, @@ -552,9 +552,9 @@ func TestView(t *testing.T) { * 1 the first line * 2 the second line * 3 the third line - * ~ - * ~ - * ~ + * + * + * `), cursorRow: 2, cursorCol: 14, @@ -571,11 +571,11 @@ func TestView(t *testing.T) { want: want{ view: heredoc.Doc(` > 1 foo - > ~ - > ~ - > ~ - > ~ - > ~ + > + > + > + > + > `), cursorRow: 0, cursorCol: 3, @@ -594,9 +594,9 @@ func TestView(t *testing.T) { > 1 foo > 2 bar > 3 baz - > ~ - > ~ - > ~ + > + > + > `), cursorRow: 2, cursorCol: 3, @@ -619,9 +619,9 @@ func TestView(t *testing.T) { foo bar baz - ~ - ~ - ~ + + + `), cursorRow: 2, cursorCol: 3, @@ -640,11 +640,11 @@ func TestView(t *testing.T) { want: want{ view: heredoc.Doc(` > 1 foo bar - > ~ - > ~ - > ~ - > ~ - > ~ + > + > + > + > + > `), cursorRow: 0, cursorCol: 7, @@ -664,10 +664,10 @@ func TestView(t *testing.T) { view: heredoc.Doc(` > 1 foo bar baz > 2 foo bar - > ~ - > ~ - > ~ - > ~ + > + > + > + > `), cursorRow: 1, cursorCol: 7, @@ -686,11 +686,11 @@ func TestView(t *testing.T) { want: want{ view: heredoc.Doc(` > 1 12 - > ~ - > ~ - > ~ - > ~ - > ~ + > + > + > + > + > `), cursorRow: 0, cursorCol: 2, @@ -709,11 +709,11 @@ func TestView(t *testing.T) { want: want{ view: heredoc.Doc(` > 1 123 - > ~ - > ~ - > ~ - > ~ - > ~ + > + > + > + > + > `), cursorRow: 0, cursorCol: 3, @@ -733,10 +733,10 @@ func TestView(t *testing.T) { view: heredoc.Doc(` > 1 1234 > - > ~ - > ~ - > ~ - > ~ + > + > + > + > `), cursorRow: 1, cursorCol: 0, @@ -756,10 +756,10 @@ func TestView(t *testing.T) { view: heredoc.Doc(` > 1 1234 > 5 - > ~ - > ~ - > ~ - > ~ + > + > + > + > `), cursorRow: 1, cursorCol: 1, @@ -779,11 +779,11 @@ func TestView(t *testing.T) { want: want{ view: heredoc.Doc(` > 1 123 - > ~ - > ~ - > ~ - > ~ - > ~ + > + > + > + > + > `), cursorRow: 0, cursorCol: 3, @@ -804,10 +804,10 @@ func TestView(t *testing.T) { view: heredoc.Doc(` > 1 1234 > - > ~ - > ~ - > ~ - > ~ + > + > + > + > `), cursorRow: 1, cursorCol: 0, @@ -828,10 +828,10 @@ func TestView(t *testing.T) { view: heredoc.Doc(` > 1 1234 > 5 - > ~ - > ~ - > ~ - > ~ + > + > + > + > `), cursorRow: 1, cursorCol: 1, @@ -853,8 +853,8 @@ func TestView(t *testing.T) { > 2 > 3 > - > ~ - > ~ + > + > `), cursorRow: 3, cursorCol: 0, @@ -876,8 +876,8 @@ func TestView(t *testing.T) { > 2 > 3 > - > ~ - > ~ + > + > `), cursorRow: 3, cursorCol: 0, @@ -900,8 +900,8 @@ func TestView(t *testing.T) { > 2 > 3 > - > ~ - > ~ + > + > `), cursorRow: 3, cursorCol: 0, @@ -925,8 +925,8 @@ func TestView(t *testing.T) { 2 3 - ~ - ~ + + `), cursorRow: 3, cursorCol: 0, @@ -946,10 +946,10 @@ func TestView(t *testing.T) { view: heredoc.Doc(` > 1 12 > 3 - > ~ - > ~ - > ~ - > ~ + > + > + > + > `), cursorRow: 1, cursorCol: 1, @@ -969,11 +969,11 @@ func TestView(t *testing.T) { want: want{ view: heredoc.Doc(` > 123 - > ~ - > ~ - > ~ - > ~ - > ~ + > + > + > + > + > `), cursorRow: 0, cursorCol: 3, @@ -994,10 +994,10 @@ func TestView(t *testing.T) { view: heredoc.Doc(` > 1234 > - > ~ - > ~ - > ~ - > ~ + > + > + > + > `), cursorRow: 1, cursorCol: 0, @@ -1018,10 +1018,10 @@ func TestView(t *testing.T) { view: heredoc.Doc(` > 1234 > 5 - > ~ - > ~ - > ~ - > ~ + > + > + > + > `), cursorRow: 1, cursorCol: 1, @@ -1044,11 +1044,11 @@ func TestView(t *testing.T) { view: heredoc.Doc(` ┌──────────┐ │> 1 1 │ - │> ~ │ - │> ~ │ - │> ~ │ - │> ~ │ - │> ~ │ + │> │ + │> │ + │> │ + │> │ + │> │ └──────────┘ `), cursorRow: 0, @@ -1072,11 +1072,11 @@ func TestView(t *testing.T) { view: heredoc.Doc(` ┌──────────┐ │> 1 123 │ - │> ~ │ - │> ~ │ - │> ~ │ - │> ~ │ - │> ~ │ + │> │ + │> │ + │> │ + │> │ + │> │ └──────────┘ `), cursorRow: 0, @@ -1101,10 +1101,10 @@ func TestView(t *testing.T) { ┌──────────┐ │> 1 1234│ │> │ - │> ~ │ - │> ~ │ - │> ~ │ - │> ~ │ + │> │ + │> │ + │> │ + │> │ └──────────┘ `), cursorRow: 1, @@ -1129,10 +1129,10 @@ func TestView(t *testing.T) { ┌──────────┐ │> 1 1234│ │> 5 │ - │> ~ │ - │> ~ │ - │> ~ │ - │> ~ │ + │> │ + │> │ + │> │ + │> │ └──────────┘ `), cursorRow: 1, @@ -1157,11 +1157,11 @@ func TestView(t *testing.T) { view: heredoc.Doc(` ┌──────────┐ │> 123456 │ - │> ~ │ - │> ~ │ - │> ~ │ - │> ~ │ - │> ~ │ + │> │ + │> │ + │> │ + │> │ + │> │ └──────────┘ `), cursorRow: 0, @@ -1186,11 +1186,11 @@ func TestView(t *testing.T) { view: heredoc.Doc(` ┌──────────┐ │> 1234567 │ - │> ~ │ - │> ~ │ - │> ~ │ - │> ~ │ - │> ~ │ + │> │ + │> │ + │> │ + │> │ + │> │ └──────────┘ `), cursorRow: 0, @@ -1216,10 +1216,10 @@ func TestView(t *testing.T) { ┌──────────┐ │> 12345678│ │> │ - │> ~ │ - │> ~ │ - │> ~ │ - │> ~ │ + │> │ + │> │ + │> │ + │> │ └──────────┘ `), cursorRow: 1, @@ -1245,10 +1245,10 @@ func TestView(t *testing.T) { ┌──────────┐ │> 12345678│ │> 9 │ - │> ~ │ - │> ~ │ - │> ~ │ - │> ~ │ + │> │ + │> │ + │> │ + │> │ └──────────┘ `), cursorRow: 1, @@ -1265,11 +1265,11 @@ func TestView(t *testing.T) { want: want{ view: heredoc.Doc(` > 1 . - > ~ - > ~ - > ~ - > ~ - > ~ + > + > + > + > + > `), }, }, From bd562f9d85a3d38a858fb46a8cac9a8eee6b8481 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 May 2024 13:38:11 -0400 Subject: [PATCH 11/14] feat(deps): bump github.com/charmbracelet/x/ansi from 0.1.1 to 0.1.2 (#529) Bumps [github.com/charmbracelet/x/ansi](https://github.com/charmbracelet/x) from 0.1.1 to 0.1.2. - [Release notes](https://github.com/charmbracelet/x/releases) - [Commits](https://github.com/charmbracelet/x/compare/ansi/v0.1.1...ansi/v0.1.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 225a2d4..1abad4c 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/charmbracelet/bubbletea v0.26.3 github.com/charmbracelet/harmonica v0.2.0 github.com/charmbracelet/lipgloss v0.11.0 - github.com/charmbracelet/x/ansi v0.1.1 + github.com/charmbracelet/x/ansi v0.1.2 github.com/dustin/go-humanize v1.0.1 github.com/lucasb-eyer/go-colorful v1.2.0 github.com/mattn/go-runewidth v0.0.15 diff --git a/go.sum b/go.sum index e92ed4e..4709f5d 100644 --- a/go.sum +++ b/go.sum @@ -10,8 +10,8 @@ github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao= github.com/charmbracelet/lipgloss v0.11.0 h1:UoAcbQ6Qml8hDwSWs0Y1cB5TEQuZkDPH/ZqwWWYTG4g= github.com/charmbracelet/lipgloss v0.11.0/go.mod h1:1UdRTH9gYgpcdNN5oBtjbu/IzNKtzVtb7sqN1t9LNn8= -github.com/charmbracelet/x/ansi v0.1.1 h1:CGAduulr6egay/YVbGc8Hsu8deMg1xZ/bkaXTPi1JDk= -github.com/charmbracelet/x/ansi v0.1.1/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= +github.com/charmbracelet/x/ansi v0.1.2 h1:6+LR39uG8DE6zAmbu023YlqjJHkYXDF1z36ZwzO4xZY= +github.com/charmbracelet/x/ansi v0.1.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/charmbracelet/x/input v0.1.0 h1:TEsGSfZYQyOtp+STIjyBq6tpRaorH0qpwZUj8DavAhQ= github.com/charmbracelet/x/input v0.1.0/go.mod h1:ZZwaBxPF7IG8gWWzPUVqHEtWhc1+HXJPNuerJGRGZ28= github.com/charmbracelet/x/term v0.1.1 h1:3cosVAiPOig+EV4X9U+3LDgtwwAoEzJjNdwbXDjF6yI= From 296fcf77faad6e1928bf5b170eaa7ff74c5bc9e4 Mon Sep 17 00:00:00 2001 From: Michael Lorant Date: Fri, 31 May 2024 10:28:20 +1000 Subject: [PATCH 12/14] feat(textarea) Add multiline placeholder (#302) Add the capability to show a multiline placeholder. Some refactoring was required to improve readability and improve logic. End of line buffer character was only shown when line numbers were displayed which requires some verification whether this is the intended outcome. This change resolves this issue. --- textarea/textarea.go | 73 +++++-- textarea/textarea_test.go | 404 +++++++++++++++++++++++++++++++++++++- 2 files changed, 458 insertions(+), 19 deletions(-) diff --git a/textarea/textarea.go b/textarea/textarea.go index a830efd..1e99437 100644 --- a/textarea/textarea.go +++ b/textarea/textarea.go @@ -3,6 +3,7 @@ package textarea import ( "crypto/sha256" "fmt" + "strconv" "strings" "unicode" @@ -14,6 +15,7 @@ import ( "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/charmbracelet/x/ansi" rw "github.com/mattn/go-runewidth" "github.com/rivo/uniseg" ) @@ -1170,36 +1172,71 @@ func (m Model) getPromptString(displayLine int) (prompt string) { func (m Model) placeholderView() string { var ( s strings.Builder - p = rw.Truncate(rw.Truncate(m.Placeholder, m.width, "..."), m.width, "") + p = m.Placeholder style = m.style.Placeholder.Inline(true) ) - prompt := m.getPromptString(0) - prompt = m.style.Prompt.Render(prompt) - s.WriteString(m.style.CursorLine.Render(prompt)) + // word wrap lines + pwordwrap := ansi.Wordwrap(p, m.width, "") + // wrap lines (handles lines that could not be word wrapped) + pwrap := ansi.Hardwrap(pwordwrap, m.width, true) + // split string by new lines + plines := strings.Split(strings.TrimSpace(pwrap), "\n") - if m.ShowLineNumbers { - s.WriteString(m.style.CursorLine.Render(m.style.CursorLineNumber.Render((fmt.Sprintf(m.lineNumberFormat, 1))))) - } + for i := 0; i < m.height; i++ { + lineStyle := m.style.Placeholder + lineNumberStyle := m.style.LineNumber + if len(plines) > i { + lineStyle = m.style.CursorLine + lineNumberStyle = m.style.CursorLineNumber + } - m.Cursor.TextStyle = m.style.Placeholder - m.Cursor.SetChar(string(p[0])) - s.WriteString(m.style.CursorLine.Render(m.Cursor.View())) - - // The rest of the placeholder text - s.WriteString(m.style.CursorLine.Render(style.Render(p[1:] + strings.Repeat(" ", max(0, m.width-uniseg.StringWidth(p)))))) - - // The rest of the new lines - for i := 1; i < m.height; i++ { - s.WriteRune('\n') + // render prompt prompt := m.getPromptString(i) prompt = m.style.Prompt.Render(prompt) - s.WriteString(prompt) + s.WriteString(lineStyle.Render(prompt)) + // when show line numbers enabled: + // - render line number for only the cursor line + // - indent other placeholder lines + // this is consistent with vim with line numbers enabled if m.ShowLineNumbers { + var ln string + + switch { + case i == 0: + ln = strconv.Itoa(i + 1) + fallthrough + case len(plines) > i: + s.WriteString(lineStyle.Render(lineNumberStyle.Render(fmt.Sprintf(m.lineNumberFormat, ln)))) + default: + } + } + + switch { + // first line + case i == 0: + // first character of first line as cursor with character + m.Cursor.TextStyle = m.style.Placeholder + m.Cursor.SetChar(string(plines[0][0])) + s.WriteString(lineStyle.Render(m.Cursor.View())) + + // the rest of the first line + s.WriteString(lineStyle.Render(style.Render(plines[0][1:] + strings.Repeat(" ", max(0, m.width-uniseg.StringWidth(plines[0])))))) + // remaining lines + case len(plines) > i: + // current line placeholder text + if len(plines) > i { + s.WriteString(lineStyle.Render(style.Render(plines[i] + strings.Repeat(" ", max(0, m.width-uniseg.StringWidth(plines[i])))))) + } + default: + // end of line buffer character eob := m.style.EndOfBuffer.Render(string(m.EndOfBufferCharacter)) s.WriteString(eob) } + + // terminate with new line + s.WriteRune('\n') } m.viewport.SetContent(s.String()) diff --git a/textarea/textarea_test.go b/textarea/textarea_test.go index 770e997..6aab299 100644 --- a/textarea/textarea_test.go +++ b/textarea/textarea_test.go @@ -326,6 +326,8 @@ func TestVerticalNavigationShouldRememberPositionWhileTraversing(t *testing.T) { } func TestView(t *testing.T) { + t.Parallel() + type want struct { view string cursorRow int @@ -1264,7 +1266,64 @@ func TestView(t *testing.T) { }, want: want{ view: heredoc.Doc(` - > 1 . + > 1 H + > e + > l + > l + > o + > , + `), + }, + }, + { + name: "placeholder single line", + modelFunc: func(m Model) Model { + m.Placeholder = "placeholder the first line" + m.ShowLineNumbers = false + + return m + }, + want: want{ + view: heredoc.Doc(` + > placeholder the first line + > + > + > + > + > + `), + }, + }, + { + name: "placeholder multiple lines", + modelFunc: func(m Model) Model { + m.Placeholder = "placeholder the first line\nplaceholder the second line\nplaceholder the third line" + m.ShowLineNumbers = false + + return m + }, + want: want{ + view: heredoc.Doc(` + > placeholder the first line + > placeholder the second line + > placeholder the third line + > + > + > + `), + }, + }, + { + name: "placeholder single line with line numbers", + modelFunc: func(m Model) Model { + m.Placeholder = "placeholder the first line" + m.ShowLineNumbers = true + + return m + }, + want: want{ + view: heredoc.Doc(` + > 1 placeholder the first line > > > @@ -1273,10 +1332,353 @@ func TestView(t *testing.T) { `), }, }, + { + name: "placeholder multiple lines with line numbers", + modelFunc: func(m Model) Model { + m.Placeholder = "placeholder the first line\nplaceholder the second line\nplaceholder the third line" + m.ShowLineNumbers = true + + return m + }, + want: want{ + view: heredoc.Doc(` + > 1 placeholder the first line + > placeholder the second line + > placeholder the third line + > + > + > + `), + }, + }, + { + name: "placeholder single line with end of buffer character", + modelFunc: func(m Model) Model { + m.Placeholder = "placeholder the first line" + m.ShowLineNumbers = false + m.EndOfBufferCharacter = '*' + + return m + }, + want: want{ + view: heredoc.Doc(` + > placeholder the first line + > * + > * + > * + > * + > * + `), + }, + }, + { + name: "placeholder multiple lines with with end of buffer character", + modelFunc: func(m Model) Model { + m.Placeholder = "placeholder the first line\nplaceholder the second line\nplaceholder the third line" + m.ShowLineNumbers = false + m.EndOfBufferCharacter = '*' + + return m + }, + want: want{ + view: heredoc.Doc(` + > placeholder the first line + > placeholder the second line + > placeholder the third line + > * + > * + > * + `), + }, + }, + { + name: "placeholder single line with line numbers and end of buffer character", + modelFunc: func(m Model) Model { + m.Placeholder = "placeholder the first line" + m.ShowLineNumbers = true + m.EndOfBufferCharacter = '*' + + return m + }, + want: want{ + view: heredoc.Doc(` + > 1 placeholder the first line + > * + > * + > * + > * + > * + `), + }, + }, + { + name: "placeholder multiple lines with line numbers and end of buffer character", + modelFunc: func(m Model) Model { + m.Placeholder = "placeholder the first line\nplaceholder the second line\nplaceholder the third line" + m.ShowLineNumbers = true + m.EndOfBufferCharacter = '*' + + return m + }, + want: want{ + view: heredoc.Doc(` + > 1 placeholder the first line + > placeholder the second line + > placeholder the third line + > * + > * + > * + `), + }, + }, + { + name: "placeholder single line that is longer than max width", + modelFunc: func(m Model) Model { + m.Placeholder = "placeholder the first line that is longer than the max width" + m.SetWidth(40) + m.ShowLineNumbers = false + + return m + }, + want: want{ + view: heredoc.Doc(` + > placeholder the first line that is + > longer than the max width + > + > + > + > + `), + }, + }, + { + name: "placeholder multiple lines that are longer than max width", + modelFunc: func(m Model) Model { + m.Placeholder = "placeholder the first line that is longer than the max width\nplaceholder the second line that is longer than the max width" + m.ShowLineNumbers = false + m.SetWidth(40) + + return m + }, + want: want{ + view: heredoc.Doc(` + > placeholder the first line that is + > longer than the max width + > placeholder the second line that is + > longer than the max width + > + > + `), + }, + }, + { + name: "placeholder single line that is longer than max width with line numbers", + modelFunc: func(m Model) Model { + m.Placeholder = "placeholder the first line that is longer than the max width" + m.ShowLineNumbers = true + m.SetWidth(40) + + return m + }, + want: want{ + view: heredoc.Doc(` + > 1 placeholder the first line that is + > longer than the max width + > + > + > + > + `), + }, + }, + { + name: "placeholder multiple lines that are longer than max width with line numbers", + modelFunc: func(m Model) Model { + m.Placeholder = "placeholder the first line that is longer than the max width\nplaceholder the second line that is longer than the max width" + m.ShowLineNumbers = true + m.SetWidth(40) + + return m + }, + want: want{ + view: heredoc.Doc(` + > 1 placeholder the first line that is + > longer than the max width + > placeholder the second line that + > is longer than the max width + > + > + `), + }, + }, + { + name: "placeholder single line that is longer than max width at limit", + modelFunc: func(m Model) Model { + m.Placeholder = "123456789012345678" + m.ShowLineNumbers = false + m.SetWidth(20) + + return m + }, + want: want{ + view: heredoc.Doc(` + > 123456789012345678 + > + > + > + > + > + `), + }, + }, + { + name: "placeholder single line that is longer than max width at limit plus one", + modelFunc: func(m Model) Model { + m.Placeholder = "1234567890123456789" + m.ShowLineNumbers = false + m.SetWidth(20) + + return m + }, + want: want{ + view: heredoc.Doc(` + > 123456789012345678 + > 9 + > + > + > + > + `), + }, + }, + { + name: "placeholder single line that is longer than max width with line numbers at limit", + modelFunc: func(m Model) Model { + m.Placeholder = "12345678901234" + m.ShowLineNumbers = true + m.SetWidth(20) + + return m + }, + want: want{ + view: heredoc.Doc(` + > 1 12345678901234 + > + > + > + > + > + `), + }, + }, + { + name: "placeholder single line that is longer than max width with line numbers at limit plus one", + modelFunc: func(m Model) Model { + m.Placeholder = "123456789012345" + m.ShowLineNumbers = true + m.SetWidth(20) + + return m + }, + want: want{ + view: heredoc.Doc(` + > 1 12345678901234 + > 5 + > + > + > + > + `), + }, + }, + { + name: "placeholder multiple lines that are longer than max width at limit", + modelFunc: func(m Model) Model { + m.Placeholder = "123456789012345678\n123456789012345678" + m.ShowLineNumbers = false + m.SetWidth(20) + + return m + }, + want: want{ + view: heredoc.Doc(` + > 123456789012345678 + > 123456789012345678 + > + > + > + > + `), + }, + }, + { + name: "placeholder multiple lines that are longer than max width at limit plus one", + modelFunc: func(m Model) Model { + m.Placeholder = "1234567890123456789\n1234567890123456789" + m.ShowLineNumbers = false + m.SetWidth(20) + + return m + }, + want: want{ + view: heredoc.Doc(` + > 123456789012345678 + > 9 + > 123456789012345678 + > 9 + > + > + `), + }, + }, + { + name: "placeholder multiple lines that are longer than max width with line numbers at limit", + modelFunc: func(m Model) Model { + m.Placeholder = "12345678901234\n12345678901234" + m.ShowLineNumbers = true + m.SetWidth(20) + + return m + }, + want: want{ + view: heredoc.Doc(` + > 1 12345678901234 + > 12345678901234 + > + > + > + > + `), + }, + }, + { + name: "placeholder multiple lines that are longer than max width with line numbers at limit plus one", + modelFunc: func(m Model) Model { + m.Placeholder = "123456789012345\n123456789012345" + m.ShowLineNumbers = true + m.SetWidth(20) + + return m + }, + want: want{ + view: heredoc.Doc(` + > 1 12345678901234 + > 5 + > 12345678901234 + > 5 + > + > + `), + }, + }, } for _, tt := range tests { + tt := tt + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + textarea := newTextArea() if tt.modelFunc != nil { From 11a9fccd58e9544d336ba8aa74ad866122a410df Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Fri, 31 May 2024 13:48:29 -0700 Subject: [PATCH 13/14] chore: fix lint issues (#534) --- help/help.go | 11 +++++------ list/defaultitem.go | 14 +++++++------- list/list.go | 4 ++-- table/table.go | 4 ++-- textarea/textarea.go | 9 +++++---- textinput/textinput.go | 6 ++++-- viewport/viewport.go | 2 +- 7 files changed, 26 insertions(+), 24 deletions(-) diff --git a/help/help.go b/help/help.go index edb5a47..f4e1c97 100644 --- a/help/help.go +++ b/help/help.go @@ -15,7 +15,6 @@ import ( // Note that if a key is disabled (via key.Binding.SetEnabled) it will not be // rendered in the help view, so in theory generated help should self-manage. type KeyMap interface { - // ShortHelp returns a slice of bindings to be displayed in the short // version of the help. The help bubble will render help in the order in // which the help items are returned here. @@ -82,10 +81,10 @@ func New() Model { ShortKey: keyStyle, ShortDesc: descStyle, ShortSeparator: sepStyle, - Ellipsis: sepStyle.Copy(), - FullKey: keyStyle.Copy(), - FullDesc: descStyle.Copy(), - FullSeparator: sepStyle.Copy(), + Ellipsis: sepStyle, + FullKey: keyStyle, + FullDesc: descStyle, + FullSeparator: sepStyle, }, } } @@ -118,7 +117,7 @@ func (m Model) ShortHelpView(bindings []key.Binding) string { var b strings.Builder var totalWidth int - var separator = m.Styles.ShortSeparator.Inline(true).Render(m.ShortSeparator) + separator := m.Styles.ShortSeparator.Inline(true).Render(m.ShortSeparator) for i, kb := range bindings { if !kb.Enabled() { diff --git a/list/defaultitem.go b/list/defaultitem.go index ce98dd3..3f07cef 100644 --- a/list/defaultitem.go +++ b/list/defaultitem.go @@ -37,7 +37,7 @@ func NewDefaultItemStyles() (s DefaultItemStyles) { Foreground(lipgloss.AdaptiveColor{Light: "#1a1a1a", Dark: "#dddddd"}). Padding(0, 0, 0, 2) - s.NormalDesc = s.NormalTitle.Copy(). + s.NormalDesc = s.NormalTitle. Foreground(lipgloss.AdaptiveColor{Light: "#A49FA5", Dark: "#777777"}) s.SelectedTitle = lipgloss.NewStyle(). @@ -46,14 +46,14 @@ func NewDefaultItemStyles() (s DefaultItemStyles) { Foreground(lipgloss.AdaptiveColor{Light: "#EE6FF8", Dark: "#EE6FF8"}). Padding(0, 0, 0, 1) - s.SelectedDesc = s.SelectedTitle.Copy(). + s.SelectedDesc = s.SelectedTitle. Foreground(lipgloss.AdaptiveColor{Light: "#F793FF", Dark: "#AD58B4"}) s.DimmedTitle = lipgloss.NewStyle(). Foreground(lipgloss.AdaptiveColor{Light: "#A49FA5", Dark: "#777777"}). Padding(0, 0, 0, 2) - s.DimmedDesc = s.DimmedTitle.Copy(). + s.DimmedDesc = s.DimmedTitle. Foreground(lipgloss.AdaptiveColor{Light: "#C2B8C2", Dark: "#4D4D4D"}) s.FilterMatch = lipgloss.NewStyle().Underline(true) @@ -187,7 +187,7 @@ func (d DefaultDelegate) Render(w io.Writer, m Model, index int, item Item) { if isFiltered { // Highlight matches unmatched := s.SelectedTitle.Inline(true) - matched := unmatched.Copy().Inherit(s.FilterMatch) + matched := unmatched.Inherit(s.FilterMatch) title = lipgloss.StyleRunes(title, matchedRunes, matched, unmatched) } title = s.SelectedTitle.Render(title) @@ -196,7 +196,7 @@ func (d DefaultDelegate) Render(w io.Writer, m Model, index int, item Item) { if isFiltered { // Highlight matches unmatched := s.NormalTitle.Inline(true) - matched := unmatched.Copy().Inherit(s.FilterMatch) + matched := unmatched.Inherit(s.FilterMatch) title = lipgloss.StyleRunes(title, matchedRunes, matched, unmatched) } title = s.NormalTitle.Render(title) @@ -204,10 +204,10 @@ func (d DefaultDelegate) Render(w io.Writer, m Model, index int, item Item) { } if d.ShowDescription { - fmt.Fprintf(w, "%s\n%s", title, desc) + fmt.Fprintf(w, "%s\n%s", title, desc) //nolint: errcheck return } - fmt.Fprintf(w, "%s", title) + fmt.Fprintf(w, "%s", title) //nolint: errcheck } // ShortHelp returns the delegate's short help. diff --git a/list/list.go b/list/list.go index 573e76a..17e6e15 100644 --- a/list/list.go +++ b/list/list.go @@ -1049,7 +1049,7 @@ func (m Model) View() string { func (m Model) titleView() string { var ( view string - titleBarStyle = m.Styles.TitleBar.Copy() + titleBarStyle = m.Styles.TitleBar // We need to account for the size of the spinner, even if we don't // render it, to reserve some space for it should we turn it on later. @@ -1157,7 +1157,7 @@ func (m Model) paginationView() string { style := m.Styles.PaginationStyle if m.delegate.Spacing() == 0 && style.GetMarginTop() == 0 { - style = style.Copy().MarginTop(1) + style = style.MarginTop(1) } return style.Render(s) diff --git a/table/table.go b/table/table.go index e355b23..0bdd6d7 100644 --- a/table/table.go +++ b/table/table.go @@ -409,7 +409,7 @@ func (m *Model) FromValues(value, separator string) { type StyleFunc func(row, col int, value string) lipgloss.Style func (m Model) headersView() string { - var s = make([]string, 0, len(m.cols)) + s := make([]string, 0, len(m.cols)) for _, col := range m.cols { if col.Width <= 0 { continue @@ -422,7 +422,7 @@ func (m Model) headersView() string { } func (m *Model) renderRow(r int) string { - var s = make([]string, 0, len(m.cols)) + s := make([]string, 0, len(m.cols)) for i, value := range m.rows[r] { if m.cols[i].Width <= 0 { continue diff --git a/textarea/textarea.go b/textarea/textarea.go index 1e99437..0e868e0 100644 --- a/textarea/textarea.go +++ b/textarea/textarea.go @@ -30,8 +30,10 @@ const ( ) // Internal messages for clipboard operations. -type pasteMsg string -type pasteErrMsg struct{ error } +type ( + pasteMsg string + pasteErrMsg struct{ error } +) // KeyMap is the key bindings for different actions within the textarea. type KeyMap struct { @@ -606,8 +608,7 @@ func (m *Model) transposeLeft() { if m.col >= len(m.value[m.row]) { m.SetCursor(m.col - 1) } - m.value[m.row][m.col-1], m.value[m.row][m.col] = - m.value[m.row][m.col], m.value[m.row][m.col-1] + m.value[m.row][m.col-1], m.value[m.row][m.col] = m.value[m.row][m.col], m.value[m.row][m.col-1] if m.col < len(m.value[m.row]) { m.SetCursor(m.col + 1) } diff --git a/textinput/textinput.go b/textinput/textinput.go index 310ee30..93bc150 100644 --- a/textinput/textinput.go +++ b/textinput/textinput.go @@ -17,8 +17,10 @@ import ( ) // Internal messages for clipboard operations. -type pasteMsg string -type pasteErrMsg struct{ error } +type ( + pasteMsg string + pasteErrMsg struct{ error } +) // EchoMode sets the input behavior of the text input field. type EchoMode int diff --git a/viewport/viewport.go b/viewport/viewport.go index 960bfa4..e0a4cc3 100644 --- a/viewport/viewport.go +++ b/viewport/viewport.go @@ -378,7 +378,7 @@ func (m Model) View() string { MaxHeight(contentHeight). // truncate height if taller. MaxWidth(contentWidth). // truncate width if wider. Render(strings.Join(m.visibleLines(), "\n")) - return m.Style.Copy(). + return m.Style. UnsetWidth().UnsetHeight(). // Style size already applied in contents. Render(contents) } From 0b15a9fad1b094dab1bec5924eb204f2ef10551c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 17:02:51 -0400 Subject: [PATCH 14/14] feat(deps): bump github.com/charmbracelet/bubbletea (#533) Bumps [github.com/charmbracelet/bubbletea](https://github.com/charmbracelet/bubbletea) from 0.26.3 to 0.26.4. - [Release notes](https://github.com/charmbracelet/bubbletea/releases) - [Commits](https://github.com/charmbracelet/bubbletea/compare/v0.26.3...v0.26.4) --- updated-dependencies: - dependency-name: github.com/charmbracelet/bubbletea 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 1abad4c..4d7b1bb 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/MakeNowJust/heredoc v1.0.0 github.com/atotto/clipboard v0.1.4 - github.com/charmbracelet/bubbletea v0.26.3 + github.com/charmbracelet/bubbletea v0.26.4 github.com/charmbracelet/harmonica v0.2.0 github.com/charmbracelet/lipgloss v0.11.0 github.com/charmbracelet/x/ansi v0.1.2 diff --git a/go.sum b/go.sum index 4709f5d..41f2d1d 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,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 v0.26.3 h1:iXyGvI+FfOWqkB2V07m1DF3xxQijxjY2j8PqiXYqasg= -github.com/charmbracelet/bubbletea v0.26.3/go.mod h1:bpZHfDHTYJC5g+FBK+ptJRCQotRC+Dhh3AoMxa/2+3Q= +github.com/charmbracelet/bubbletea v0.26.4 h1:2gDkkzLZaTjMl/dQBpNVtnvcCxsh/FCkimep7FC9c40= +github.com/charmbracelet/bubbletea v0.26.4/go.mod h1:P+r+RRA5qtI1DOHNFn0otoNwB4rn+zNAzSj/EXz6xU0= 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.11.0 h1:UoAcbQ6Qml8hDwSWs0Y1cB5TEQuZkDPH/ZqwWWYTG4g=