summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-10-28 19:53:50 +0800
committerruki <[email protected]>2019-10-28 19:53:50 +0800
commitf3702d9b8d278142fdce0426187b4f9503e43f55 (patch)
tree833659139e39c2574256fbb9904d8d9faee37be9
parent2f623aed782cd56f9cdd28e94e258c854cbfeab8 (diff)
fix set theme
-rw-r--r--xmake/actions/global/main.lua7
-rw-r--r--xmake/core/main.lua8
-rw-r--r--xmake/core/sandbox/modules/import/core/theme/theme.lua9
3 files changed, 19 insertions, 5 deletions
diff --git a/xmake/actions/global/main.lua b/xmake/actions/global/main.lua
index b7e927e98..cf57d51a4 100644
--- a/xmake/actions/global/main.lua
+++ b/xmake/actions/global/main.lua
@@ -21,6 +21,7 @@
-- imports
import("core.base.option")
import("core.base.global")
+import("core.theme.theme")
import("menuconf", {alias = "menuconf_show"})
-- main
@@ -62,6 +63,12 @@ function main()
if changed or option.get("clean") then
global.check()
end
+
+ -- load and check theme
+ local themename = option.get("theme")
+ if themename then
+ theme.load(themename)
+ end
-- save it
global.save()
diff --git a/xmake/core/main.lua b/xmake/core/main.lua
index 7c0c75f3f..0183599e5 100644
--- a/xmake/core/main.lua
+++ b/xmake/core/main.lua
@@ -181,12 +181,10 @@ function main.entry()
end
-- load theme
- local theme_inst, errors = theme.load(global.get("theme") or "default")
- if not theme_inst then
- utils.error(errors)
- return -1
+ local theme_inst = theme.load(global.get("theme")) or theme.load("default")
+ if theme_inst then
+ colors.theme_set(theme_inst)
end
- colors.theme_set(theme_inst)
-- init option
ok, errors = option.init(menu)
diff --git a/xmake/core/sandbox/modules/import/core/theme/theme.lua b/xmake/core/sandbox/modules/import/core/theme/theme.lua
index e6d1b1c8c..090435cd2 100644
--- a/xmake/core/sandbox/modules/import/core/theme/theme.lua
+++ b/xmake/core/sandbox/modules/import/core/theme/theme.lua
@@ -35,6 +35,15 @@ function sandbox_core_theme.instance()
end
end
+-- load the given theme
+function sandbox_core_theme.load(name)
+ local instance, errors = theme.load(name)
+ if not instance then
+ raise("load theme(%s) failed, %s", name, errors)
+ end
+ return instance
+end
+
-- get the theme configuration
function sandbox_core_theme.get(name)
local value = theme.get(name)