Mercurial > yakumo_izuru > aya
comparison vendor/github.com/alecthomas/chroma/v2/styles/api.go @ 66:787b5ee0289d draft
Use vendored modules
Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>
author | yakumo.izuru |
---|---|
date | Sun, 23 Jul 2023 13:18:53 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
65:6d985efa0f7a | 66:787b5ee0289d |
---|---|
1 package styles | |
2 | |
3 import ( | |
4 "sort" | |
5 | |
6 "github.com/alecthomas/chroma/v2" | |
7 ) | |
8 | |
9 // Registry of Styles. | |
10 var Registry = map[string]*chroma.Style{} | |
11 | |
12 // Fallback style. Reassign to change the default fallback style. | |
13 var Fallback = SwapOff | |
14 | |
15 // Register a chroma.Style. | |
16 func Register(style *chroma.Style) *chroma.Style { | |
17 Registry[style.Name] = style | |
18 return style | |
19 } | |
20 | |
21 // Names of all available styles. | |
22 func Names() []string { | |
23 out := []string{} | |
24 for name := range Registry { | |
25 out = append(out, name) | |
26 } | |
27 sort.Strings(out) | |
28 return out | |
29 } | |
30 | |
31 // Get named style, or Fallback. | |
32 func Get(name string) *chroma.Style { | |
33 if style, ok := Registry[name]; ok { | |
34 return style | |
35 } | |
36 return Fallback | |
37 } |