on main help sign in
fix(tui): permission: make sure the fetch content has the correct background color
653c6a5Ayman Bagabas
internal/tui/components/dialogs/permissions/permissions.go+18−2
@@ -16,6 +16,7 @@ import (
16 "github.com/charmbracelet/crush/internal/tui/styles"
16 "github.com/charmbracelet/crush/internal/tui/styles"
17 "github.com/charmbracelet/crush/internal/tui/util"
17 "github.com/charmbracelet/crush/internal/tui/util"
18 "github.com/charmbracelet/lipgloss/v2"
18 "github.com/charmbracelet/lipgloss/v2"
19+ uv "github.com/charmbracelet/ultraviolet"
19 "github.com/charmbracelet/x/ansi"
20 "github.com/charmbracelet/x/ansi"
20)
21)
21
22
@@ -395,7 +396,22 @@ func (p *permissionDialogCmp) generateFetchContent() string {
395 Width(p.contentViewPort.Width()).
396 Width(p.contentViewPort.Width()).
396 Render(renderedContent)
397 Render(renderedContent)
397
398
398− return finalContent
399+ // We render the content into a buffer with the size of the viewport
400+ // width and height of the content. Then we make sure each cell has the
401+ // appropriate background color.
402+ ss := uv.NewStyledString(finalContent)
403+ scr := uv.NewScreenBuffer(p.contentViewPort.Width(), lipgloss.Height(finalContent))
404+ ss.Draw(scr, scr.Bounds())
405+ for y := 0; y < scr.Height(); y++ {
406+ for x := 0; x < scr.Width(); x++ {
407+ cell := scr.CellAt(x, y)
408+ if cell != nil {
409+ cell.Style.Bg = t.BgSubtle
410+ }
411+ }
412+ }
413+
414+ return scr.Render()
399 }
415 }
400 return ""
416 return ""
401}
417}
@@ -452,8 +468,8 @@ func (p *permissionDialogCmp) render() string {
452 if p.supportsDiffView() {
468 if p.supportsDiffView() {
453 contentHelp = help.New().View(p.keyMap)
469 contentHelp = help.New().View(p.keyMap)
454 }
470 }
455− // Calculate content height dynamically based on window size
456
471
472+ // Calculate content height dynamically based on window size
457 strs := []string{
473 strs := []string{
458 title,
474 title,
459 "",
475 "",