package theme_test import ( "fmt" "codeberg.org/turbo-editors/turbo-core/theme" ) // Reading a style out of a theme, and the fallback that makes a partial theme // usable. func ExampleTheme_Style() { th, err := theme.Parse([]byte(` name = "Minimal" [colors] default = { fg = "white", bg = "navy" } syntax = { fg = "aqua" } `), "") if err != nil { panic(err) } // "syntax.keyword" is not set, so the lookup walks up to "syntax". fg, bg, _ := th.Style(theme.KeySyntaxKeyword).Decompose() fmt.Println(fg, bg) // Nothing matches "menu.bar" at all, so it lands on "default". fg, _, _ = th.Style(theme.KeyMenuBar).Decompose() fmt.Println(fg) // Output: // aqua navy // white } // Listing what the user can choose from in the Options menu. The directory is // where the user's own themes live; "" offers the embedded ones alone. func ExampleAvailable() { for _, name := range theme.Available("") { th, err := theme.Load(name, "") if err != nil { continue } fmt.Printf("%s — %s\n", name, th.Name()) } }