From ff393734ea5590a423baa0cf90b6058f144ed114 Mon Sep 17 00:00:00 2001 From: Cyano Hao Date: Sun, 31 Mar 2024 08:47:37 +0800 Subject: [PATCH] Fix lua themes (#356) * fix lua themes * fix project files * fix project files --- .gitattributes | 2 +- RedPandaIDE/RedPandaIDE.pro | 2 +- RedPandaIDE/resources/themes/one_dark.lua | 13 ++----- RedPandaIDE/xmake.lua | 9 ++--- addon/gen.sh | 2 +- addon/theme/one_dark.tl | 44 +++++++++++++++++++++++ 6 files changed, 54 insertions(+), 18 deletions(-) create mode 100644 addon/theme/one_dark.tl diff --git a/.gitattributes b/.gitattributes index 0fe1f6f5..7eb625de 100644 --- a/.gitattributes +++ b/.gitattributes @@ -30,4 +30,4 @@ # generated files compiler_hint.lua eol=lf -/RedPandaIDE/themes/*.lua eol=lf +/RedPandaIDE/resources/themes/*.lua eol=lf diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index f910c833..08937cd0 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -609,7 +609,7 @@ iconsets_files.files += $$files(resources/iconsets/*.svg, true) iconsets_files.files += $$files(resources/iconsets/*.json, true) ENABLE_LUA_ADDON { - theme_files.files += $$files(themes/*.lua, false) + theme_files.files += $$files(resources/themes/*.lua, false) } else { theme_files.files += $$files(resources/themes/*.json, false) } diff --git a/RedPandaIDE/resources/themes/one_dark.lua b/RedPandaIDE/resources/themes/one_dark.lua index 120f4c88..c39dbcc4 100644 --- a/RedPandaIDE/resources/themes/one_dark.lua +++ b/RedPandaIDE/resources/themes/one_dark.lua @@ -6,18 +6,9 @@ function apiVersion() } end -local nameMap = { - en_US = "One Dark", - pt_BR = "One Dark", - zh_CN = "One Dark", - zh_TW = "One Dark", -} - function main() - local lang = C_Desktop.language() - return { - ["name"] = nameMap[lang] or nameMap.en_US, + ["name"] = "One Dark", ["style"] = "RedPandaDarkFusion", ["default scheme"] = "One Dark", ["default iconset"] = "contrast", @@ -46,7 +37,7 @@ function main() PaletteBrightText = "#E0E1E3", PaletteDark = "#282c34", PaletteMid = "#282c34", - PaletteMidLight = "#282c34", + PaletteMidlight = "#282c34", PaletteLight = "#282c34", }, } diff --git a/RedPandaIDE/xmake.lua b/RedPandaIDE/xmake.lua index 26328299..345855a5 100644 --- a/RedPandaIDE/xmake.lua +++ b/RedPandaIDE/xmake.lua @@ -179,8 +179,9 @@ target("RedPandaIDE") add_files( "resources/iconsets/**.svg", "resources/iconsets/**.json", - "themes/*.png", - "colorschemes/*.scheme", + "resources/themes/*.png", + "resources/colorschemes/*.scheme", + "resources/fonts/asciicontrol.ttf", {rule = "RedPandaIDE.auto_qrc"}) if is_os("windows") then @@ -199,12 +200,12 @@ target("RedPandaIDE") "addon/executor.cpp", "addon/runtime.cpp") add_files( - "themes/*.lua", + "resources/themes/*.lua", {rule = "RedPandaIDE.auto_qrc"}) add_links("lua") else add_files( - "themes/*.json", + "resources/themes/*.json", {rule = "RedPandaIDE.auto_qrc"}) end diff --git a/addon/gen.sh b/addon/gen.sh index 04d7a556..f7bd2b2d 100755 --- a/addon/gen.sh +++ b/addon/gen.sh @@ -5,7 +5,7 @@ set -euo pipefail function gen-theme() { local file="$1" local bn="$(basename $file)" - local out="RedPandaIDE/themes/${bn%.tl}.lua" + local out="RedPandaIDE/resources/themes/${bn%.tl}.lua" echo -e "\033[1;33mChecking $file\033[0m" tl check --include-dir addon --global-env-def defs/theme --quiet "$file" echo -e "\033[1;32mCompiling $file\033[0m" diff --git a/addon/theme/one_dark.tl b/addon/theme/one_dark.tl new file mode 100644 index 00000000..50fea3e1 --- /dev/null +++ b/addon/theme/one_dark.tl @@ -0,0 +1,44 @@ +global function apiVersion(): ApiVersion + return { + kind = "theme", + major = 0, + minor = 1, + } +end + +global function main(): Theme + return { + ["name"] = "One Dark", -- do not translate + ["style"] = "RedPandaDarkFusion", + ["default scheme"] = "One Dark", + ["default iconset"] = "contrast", + ["palette"] = { + PaletteWindow = "#282c34", + PaletteWindowDisabled = "#21252B", + PaletteWindowText = "#9da5b4", + PaletteWindowTextDisabled = "#676D7B", + PaletteBase = "#21252B", + PaletteBaseDisabled = "#1d2026", + PaletteAlternateBase = "#282c34", + PaletteToolTipBase = "#21252B", + PaletteToolTipText = "#9da5b4", + PaletteText = "#b4b4b4", + PaletteTextDisabled = "#676D7B", + PaletteButton = "#2c313c", + PaletteButtonDisabled = "#21252B", + PaletteButtonText = "#9da5b4", + PaletteButtonTextDisabled = "#676D7B", + PaletteHighlight = "#3b4048", + PaletteHighlightDisabled = "#21252B", + PaletteHighlightedText = "#d7dae0", + PaletteHighlightedTextDisabled = "#676D7B", + PaletteLink = "#98c379", + PaletteLinkVisited = "#c9c900", + PaletteBrightText = "#E0E1E3", + PaletteDark = "#282c34", + PaletteMid = "#282c34", + PaletteMidlight = "#282c34", + PaletteLight = "#282c34", + }, + } +end