Force true color
This commit is contained in:
parent
2c8ea907b4
commit
4ed91206ca
14
main.go
14
main.go
|
@ -3,12 +3,22 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os"
|
||||
|
||||
"github.com/charmbracelet/bubbles/list"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/muesli/termenv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
p := tea.NewProgram(initialModel(), tea.WithOutput(os.Stderr))
|
||||
items := []list.Item{
|
||||
item("/home/user/Workspace"),
|
||||
item("/home/user/Downloads"),
|
||||
}
|
||||
|
||||
lipgloss.DefaultRenderer().SetColorProfile(termenv.TrueColor)
|
||||
p := tea.NewProgram(initialModel(items), tea.WithOutput(os.Stderr))
|
||||
m, err := p.Run();
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
12
tui.go
12
tui.go
|
@ -11,10 +11,9 @@ import (
|
|||
"github.com/charmbracelet/bubbles/list"
|
||||
)
|
||||
|
||||
|
||||
type item string
|
||||
|
||||
func (i item) FilterValue() string { return "" }
|
||||
|
||||
type itemDelegate struct{}
|
||||
|
||||
func (d itemDelegate) Height() int { return 1 }
|
||||
|
@ -31,7 +30,7 @@ func (d itemDelegate) Render(w io.Writer, m list.Model, index int, listItem list
|
|||
fn := lipgloss.NewStyle().PaddingLeft(2).Render
|
||||
if index == m.Index() {
|
||||
fn = func(s ...string) string {
|
||||
return lipgloss.NewStyle().PaddingLeft(0).Foreground(lipgloss.Color("170")).Render("> " + strings.Join(s, " "))
|
||||
return lipgloss.NewStyle().PaddingLeft(0).PaddingRight(1).Background(lipgloss.Color("#0F7FCF")).Render("> " + strings.Join(s, " "))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,12 +98,7 @@ type model struct {
|
|||
err error
|
||||
}
|
||||
|
||||
func initialModel() model {
|
||||
items := []list.Item{
|
||||
item("/home/user/Workspace"),
|
||||
item("/home/user/Downloads"),
|
||||
}
|
||||
|
||||
func initialModel(items []list.Item) model {
|
||||
const defaultWidth = 20
|
||||
|
||||
l := list.New(items, itemDelegate{}, defaultWidth, 14)
|
||||
|
|
Loading…
Reference in New Issue