mirror of
https://github.com/VladimirMarkelov/clui.git
synced 2025-05-01 13:48:49 +08:00
closes #26 - load only *.theme files as theme one
This commit is contained in:
parent
221b3bc613
commit
0dc0e012e1
9
theme.go
9
theme.go
@ -26,6 +26,8 @@ type ThemeManager struct {
|
|||||||
version string
|
version string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const themeSuffix = ".theme"
|
||||||
|
|
||||||
// ThemeInfo is a detailed information about theme:
|
// ThemeInfo is a detailed information about theme:
|
||||||
// title, author, version number
|
// title, author, version number
|
||||||
type ThemeInfo struct {
|
type ThemeInfo struct {
|
||||||
@ -201,8 +203,9 @@ func (s *ThemeManager) ThemeNames() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
if !f.IsDir() {
|
name := f.Name()
|
||||||
str = append(str, f.Name())
|
if !f.IsDir() && strings.HasSuffix(name, themeSuffix) {
|
||||||
|
str = append(str, strings.TrimSuffix(name, themeSuffix))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +264,7 @@ func (s *ThemeManager) LoadTheme(name string) {
|
|||||||
theme.colors = make(map[string]term.Attribute, 0)
|
theme.colors = make(map[string]term.Attribute, 0)
|
||||||
theme.objects = make(map[string]string, 0)
|
theme.objects = make(map[string]string, 0)
|
||||||
|
|
||||||
file, err := os.Open(s.themePath + string(os.PathSeparator) + name)
|
file, err := os.Open(s.themePath + string(os.PathSeparator) + name + themeSuffix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("Failed to open theme " + name + " : " + err.Error())
|
panic("Failed to open theme " + name + " : " + err.Error())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user