mirror of
https://github.com/anotherhadi/ilovetui.git
synced 2026-10-05 19:08:25 +02:00
Change overlay display to allow bubblezone to work
Signed-off-by: Hadi <[email protected]>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package style
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/charmbracelet/x/ansi"
|
||||
)
|
||||
|
||||
func Overlay(base, top string, x, y int) string {
|
||||
baseLines := strings.Split(base, "\n")
|
||||
topLines := strings.Split(top, "\n")
|
||||
|
||||
for i, tl := range topLines {
|
||||
row := y + i
|
||||
if row < 0 || row >= len(baseLines) {
|
||||
continue
|
||||
}
|
||||
bl := baseLines[row]
|
||||
tw := ansi.StringWidth(tl)
|
||||
left := ansi.Cut(bl, 0, x)
|
||||
right := ansi.Cut(bl, x+tw, ansi.StringWidth(bl))
|
||||
baseLines[row] = left + tl + right
|
||||
}
|
||||
|
||||
return strings.Join(baseLines, "\n")
|
||||
}
|
||||
Reference in New Issue
Block a user