on main help sign in
fix kitty issues
2c24bfbKujtim Hoxha
internal/tui/layout/overlay.go+4−40
@@ -1,16 +1,15 @@
1package layout
1package layout
2
2
3import (
3import (
4− "bytes"
5 "strings"
4 "strings"
6
5
7 "github.com/charmbracelet/lipgloss"
6 "github.com/charmbracelet/lipgloss"
8− "github.com/opencode-ai/opencode/internal/tui/styles"
7+ chAnsi "github.com/charmbracelet/x/ansi"
9− "github.com/opencode-ai/opencode/internal/tui/util"
10− "github.com/mattn/go-runewidth"
11 "github.com/muesli/ansi"
8 "github.com/muesli/ansi"
12 "github.com/muesli/reflow/truncate"
9 "github.com/muesli/reflow/truncate"
13 "github.com/muesli/termenv"
10 "github.com/muesli/termenv"
11+ "github.com/opencode-ai/opencode/internal/tui/styles"
12+ "github.com/opencode-ai/opencode/internal/tui/util"
14)
13)
15
14
16// Most of this code is borrowed from
15// Most of this code is borrowed from
@@ -117,42 +116,7 @@ func PlaceOverlay(
117// cutLeft cuts printable characters from the left.
116// cutLeft cuts printable characters from the left.
118// This function is heavily based on muesli's ansi and truncate packages.
117// This function is heavily based on muesli's ansi and truncate packages.
119func cutLeft(s string, cutWidth int) string {
118func cutLeft(s string, cutWidth int) string {
120− var (
119+ return chAnsi.Cut(s, cutWidth, lipgloss.Width(s))
121− pos int
122− isAnsi bool
123− ab bytes.Buffer
124− b bytes.Buffer
125− )
126− for _, c := range s {
127− var w int
128− if c == ansi.Marker || isAnsi {
129− isAnsi = true
130− ab.WriteRune(c)
131− if ansi.IsTerminator(c) {
132− isAnsi = false
133− if bytes.HasSuffix(ab.Bytes(), []byte("[0m")) {
134− ab.Reset()
135− }
136− }
137− } else {
138− w = runewidth.RuneWidth(c)
139− }
140−
141− if pos >= cutWidth {
142− if b.Len() == 0 {
143− if ab.Len() > 0 {
144− b.Write(ab.Bytes())
145− }
146− if pos-cutWidth > 1 {
147− b.WriteByte(' ')
148− continue
149− }
150− }
151− b.WriteRune(c)
152− }
153− pos += w
154− }
155− return b.String()
156}
120}
157
121
158func max(a, b int) int {
122func max(a, b int) int {