Allow /theme command to return current theme - Add empty args to return theme name on /theme call - Improve help string docs for /theme
| @@ -2968,7 +2968,13 @@ function setAvgBG() { | ||
| 2968 | 2968 | return ''; |
| 2969 | 2969 | } |
| 2970 | 2970 | |
| 2971 | 2971 | async function setThemeCallback(_, textthemeName) { |
| 2972 | + if (!themeName) { | |
| 2973 | + // allow reporting of the theme name if called without args | |
| 2974 | + // for use in ST Scripts via pipe | |
| 2975 | + return power_user.theme; | |
| 2976 | + } | |
| 2977 | + | |
| 2972 | 2978 | // @ts-ignore |
| 2973 | 2979 | const fuse = new Fuse(themes, { |
| 2974 | 2980 | keys: [ |
| @@ -2976,12 +2982,12 @@ async function setThemeCallback(_, text) { | ||
| 2976 | 2982 | ], |
| 2977 | 2983 | }); |
| 2978 | 2984 | |
| 2979 | 2985 | const results = fuse.search(textthemeName); |
| 2980 | 2986 | console.debug('Theme fuzzy search results for ' + textthemeName, results); |
| 2981 | 2987 | const theme = results[0]?.item; |
| 2982 | 2988 | |
| 2983 | 2989 | if (!theme) { |
| 2984 | 2990 | toastr.warning(`Could not find theme with name: ${textthemeName}`); |
| 2985 | 2991 | return; |
| 2986 | 2992 | } |
| 2987 | 2993 | |
| @@ -4056,13 +4062,30 @@ $(document).ready(() => { | ||
| 4056 | 4062 | callback: setThemeCallback, |
| 4057 | 4063 | unnamedArgumentList: [ |
| 4058 | 4064 | SlashCommandArgument.fromProps({ |
| 4059 | 4065 | description: 'theme name', |
| 4060 | 4066 | typeList: [ARGUMENT_TYPE.STRING], |
| 4061 | - isRequired: true, | |
| 4062 | 4067 | enumProvider: () => themes.map(theme => new SlashCommandEnumValue(theme.name)), |
| 4063 | 4068 | }), |
| 4064 | 4069 | ], |
| 4065 | - helpString: 'sets a UI theme by name', | |
| 4070 | + helpString: ` | |
| 4071 | + <div> | |
| 4072 | + Sets a UI theme by name. | |
| 4073 | + </div> | |
| 4074 | + <div> | |
| 4075 | + If no theme name is is provided, this will return the currently active theme. | |
| 4076 | + </div> | |
| 4077 | + <div> | |
| 4078 | + <strong>Example:</strong> | |
| 4079 | + <ul> | |
| 4080 | + <li> | |
| 4081 | + <pre><code>/theme Cappuccino</code></pre> | |
| 4082 | + </li> | |
| 4083 | + <li> | |
| 4084 | + <pre><code>/theme</code></pre> | |
| 4085 | + </li> | |
| 4086 | + </ul> | |
| 4087 | + </div> | |
| 4088 | + `, | |
| 4066 | 4089 | })); |
| 4067 | 4090 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 4068 | 4091 | name: 'movingui', |