「テーマのトグル」の版間の差分
編集の要約なし |
編集の要約なし |
||
| 3行目: | 3行目: | ||
== 動作環境 == | == 動作環境 == | ||
Mery Ver 3.7 | * Mery Ver 3.8.0 以降 | ||
* Windows 7 以降 | |||
== 使用方法 == | == 使用方法 == | ||
| 25行目: | 26行目: | ||
== 変更履歴 == | == 変更履歴 == | ||
* 2026-01-11 | |||
** QuickJS で実行するようにした | |||
* 2025-12-26 | * 2025-12-26 | ||
** パフォーマンスの改善 | ** パフォーマンスの改善 | ||
| 46行目: | 49行目: | ||
<syntaxhighlight lang="javascript" copy> | <syntaxhighlight lang="javascript" copy> | ||
#fonticon = "\uE790", #4d82b8, #dddddd | #fonticon = "\uE790", #4d82b8, #dddddd | ||
#language = "quickjs" | |||
#title = "テーマのトグル" | #title = "テーマのトグル" | ||
const currentTheme = editor.ReadSettingString("Themes", "ThemeName", ""); | |||
let newTheme; | |||
switch (currentTheme) { | switch (currentTheme) { | ||
| 62行目: | 66行目: | ||
} | } | ||
const getItems = () => { | |||
let iniFullName = editor.FullName.replace(/\.exe$/i, ".ini"); | |||
if (!shell.FileExists(iniFullName)) { | if (!shell.FileExists(iniFullName)) { | ||
iniFullName = shell.GetEnv("APPDATA") + "\\Mery" + iniFullName.slice(iniFullName.lastIndexOf("\\")); | iniFullName = shell.GetEnv("APPDATA") + "\\Mery" + iniFullName.slice(iniFullName.lastIndexOf("\\")); | ||
} | } | ||
const iniText = shell.Exec(`cmd.exe /c type "${iniFullName}"`).stdOut; | |||
const iniLines = iniText.split("\r\n"); | |||
const sectionStart = iniLines.indexOf(`[Theme\\${newTheme}]`); | |||
if (sectionStart === -1) { | if (sectionStart === -1) { | ||
return; | return; | ||
} | } | ||
const sectionEnd = iniLines.indexOf("", sectionStart); | |||
return iniLines.slice(sectionStart + 1, sectionEnd).map(item => item.split("=")); | |||
}; | }; | ||
const items = getItems(); | |||
if (items) { | if (items) { | ||
const statusText = Status; | |||
editor.ExecuteMacro( | editor.ExecuteMacro( | ||
"Status = 'テーマ切り替え中...しばらくお待ちください';" + | "Status = 'テーマ切り替え中...しばらくお待ちください';" + | ||
| 92行目: | 93行目: | ||
editor.WriteSettingString("Themes", "ThemeName", newTheme); | editor.WriteSettingString("Themes", "ThemeName", newTheme); | ||
for ( | for (const [ident, value] of items) { | ||
editor.WriteSettingString("Display", | editor.WriteSettingString("Display", ident, value); | ||
} | } | ||
| 100行目: | 101行目: | ||
ShowTip("", meShowTipHide); | ShowTip("", meShowTipHide); | ||
} else { | } else { | ||
Alert(newTheme | Alert(`${newTheme} という名前でテーマを保存してください`); | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
スポンサーリンク