mirror of
https://github.com/sst/opencode.git
synced 2025-08-31 10:17:26 +00:00
fix(tui): find dialog bg color
This commit is contained in:
parent
8d0350d923
commit
229a280652
3 changed files with 31 additions and 9 deletions
|
@ -54,7 +54,9 @@ func (cg *filesContextGroup) getGitFiles() []dialog.CompletionItemI {
|
|||
Value: file.Path,
|
||||
ProviderID: cg.GetId(),
|
||||
Raw: file,
|
||||
})
|
||||
},
|
||||
dialog.WithBackgroundColor(t.BackgroundPanel()),
|
||||
)
|
||||
items = append(items, item)
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +102,9 @@ func (cg *filesContextGroup) GetChildEntries(
|
|||
Value: file,
|
||||
ProviderID: cg.GetId(),
|
||||
Raw: file,
|
||||
})
|
||||
},
|
||||
dialog.WithBackgroundColor(theme.CurrentTheme().BackgroundPanel()),
|
||||
)
|
||||
items = append(items, item)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/charmbracelet/bubbles/v2/textarea"
|
||||
tea "github.com/charmbracelet/bubbletea/v2"
|
||||
"github.com/charmbracelet/lipgloss/v2"
|
||||
"github.com/charmbracelet/lipgloss/v2/compat"
|
||||
"github.com/lithammer/fuzzysearch/fuzzy"
|
||||
"github.com/muesli/reflow/truncate"
|
||||
"github.com/sst/opencode/internal/components/list"
|
||||
|
@ -18,10 +19,11 @@ import (
|
|||
)
|
||||
|
||||
type CompletionItem struct {
|
||||
Title string
|
||||
Value string
|
||||
ProviderID string
|
||||
Raw any
|
||||
Title string
|
||||
Value string
|
||||
ProviderID string
|
||||
Raw any
|
||||
backgroundColor *compat.AdaptiveColor
|
||||
}
|
||||
|
||||
type CompletionItemI interface {
|
||||
|
@ -38,8 +40,13 @@ func (ci *CompletionItem) Render(selected bool, width int) string {
|
|||
|
||||
truncatedStr := truncate.String(string(ci.DisplayValue()), uint(width-4))
|
||||
|
||||
backgroundColor := t.BackgroundElement()
|
||||
if ci.backgroundColor != nil {
|
||||
backgroundColor = *ci.backgroundColor
|
||||
}
|
||||
|
||||
itemStyle := baseStyle.
|
||||
Background(t.BackgroundElement()).
|
||||
Background(backgroundColor).
|
||||
Padding(0, 1)
|
||||
|
||||
if selected {
|
||||
|
@ -66,7 +73,18 @@ func (ci *CompletionItem) GetRaw() any {
|
|||
return ci.Raw
|
||||
}
|
||||
|
||||
func NewCompletionItem(completionItem CompletionItem) CompletionItemI {
|
||||
type CompletionItemOption func(*CompletionItem)
|
||||
|
||||
func WithBackgroundColor(color compat.AdaptiveColor) CompletionItemOption {
|
||||
return func(ci *CompletionItem) {
|
||||
ci.backgroundColor = &color
|
||||
}
|
||||
}
|
||||
|
||||
func NewCompletionItem(completionItem CompletionItem, opts ...CompletionItemOption) CompletionItemI {
|
||||
for _, opt := range opts {
|
||||
opt(&completionItem)
|
||||
}
|
||||
return &completionItem
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ func (f *findDialogComponent) View() string {
|
|||
listView := f.list.View()
|
||||
return styles.NewStyle().
|
||||
Height(12).
|
||||
Background(t.BackgroundElement()).
|
||||
Background(t.BackgroundPanel()).
|
||||
Width(f.width - 4).
|
||||
Render(inputView + "\n" + listView)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue