Skip to content

Commit

Permalink
! Allow exporting all syntax highlight styles by holding down Shift k…
Browse files Browse the repository at this point in the history
…ey before pressing Export button (#313)
  • Loading branch information
wmjordan committed Aug 29, 2024
1 parent f04dfe0 commit 5dbd5d8
Show file tree
Hide file tree
Showing 7 changed files with 580 additions and 463 deletions.
12 changes: 9 additions & 3 deletions Codist/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public static void ResetWrapTexts(List<WrapText> wrapTexts) {
});
}

public void SaveConfig(string path, bool stylesOnly = false) {
public void SaveConfig(string path, bool stylesOnly = false, bool allStyles = false) {
path = path ?? ConfigPath;
try {
var d = Path.GetDirectoryName(path);
Expand All @@ -342,16 +342,17 @@ public void SaveConfig(string path, bool stylesOnly = false) {
}
object o;
bool isDarkStyle = ServicesHelper.Instance.EditorFormatMap.GetEditorFormatMap(Constants.CodeText).GetBackgroundColor().IsDark();
var styles = allStyles ? GetAllStyles() : GetCustomizedStyles();
if (stylesOnly) {
o = new {
Version = CurrentVersion,
Styles = GetCustomizedStyles()
Styles = styles
};
}
else {
o = this;
Version = CurrentVersion;
Styles = GetCustomizedStyles().ToList();
Styles = styles.ToList();
}
File.WriteAllText(path, JsonConvert.SerializeObject(
o,
Expand All @@ -373,6 +374,11 @@ public void SaveConfig(string path, bool stylesOnly = false) {
Styles = null;
}

IEnumerable<SyntaxStyle> GetAllStyles() {
return FormatStore.GetAllStyles()
.Select(i => new SyntaxStyle(i.Key, i.Value));
}

IEnumerable<SyntaxStyle> GetCustomizedStyles() {
return FormatStore.GetStyles()
.Where(i => i.Value?.IsSet == true)
Expand Down
3 changes: 2 additions & 1 deletion Codist/Options/SyntaxHighlightCustomizationWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1291,8 +1291,9 @@ void ExportTheme() {
catch (System.Security.SecurityException) { }
}
try {
var fullExport = WpfHelper.IsShiftDown;
if (d.ShowDialog() == true) {
Config.Instance.SaveConfig(d.FileName, true);
Config.Instance.SaveConfig(d.FileName, true, fullExport);
_ThemeFolder = System.IO.Path.GetDirectoryName(d.FileName);
}
}
Expand Down
21 changes: 20 additions & 1 deletion Codist/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 28 additions & 21 deletions Codist/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,13 @@ Shift: Paste and select next (whole word)</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Dark" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Dark Codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
<value>..\Resources\Dark Codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="Light" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Light Codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
<value>..\Resources\Light Codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="Simple" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Simple Codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
<value>..\Resources\Simple Codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="T_AsParameter" xml:space="preserve">
<value> as parameter</value>
Expand Down Expand Up @@ -822,6 +822,12 @@ Use space to separate keywords.</value>
<data name="OT_AdditionalQuickInfoNote" xml:space="preserve">
<value>The following options allow adding more items to the Quick Info</value>
</data>
<data name="OT_AddShowActiveWindowProperties" xml:space="preserve">
<value>Add "Show Active Window Properties" command to File menu</value>
</data>
<data name="OT_AddShowActiveWindowPropertiesTip" xml:space="preserve">
<value>Displays comprehensive information about the active window pane and its document</value>
</data>
<data name="OT_AddShowSyntaxClassifcationInfo" xml:space="preserve">
<value>Add "Show Syntax Classification Info" command to Smart Bar</value>
</data>
Expand Down Expand Up @@ -1464,7 +1470,8 @@ Ctrl+1, Ctrl+3: Edit.SearchDeclarationInProject</value>
<value>Confirm changes</value>
</data>
<data name="CMDT_SaveTheme" xml:space="preserve">
<value>Save syntax highlight theme...</value>
<value>Save syntax highlight theme...
Shift: Save built-in default styles as well</value>
</data>
<data name="CMDT_SimpleTheme" xml:space="preserve">
<value>Load a predefined simple theme</value>
Expand Down Expand Up @@ -1556,6 +1563,9 @@ Ctrl+1, Ctrl+3: Edit.SearchDeclarationInProject</value>
<data name="OT_TypeCastBraces" xml:space="preserve">
<value>Type cast parentheses</value>
</data>
<data name="T_ApplyTo" xml:space="preserve">
<value>Apply to:</value>
</data>
<data name="T_Background" xml:space="preserve">
<value>Background</value>
</data>
Expand Down Expand Up @@ -1778,10 +1788,10 @@ Use space to separate multiple search terms.
<value>Pale Light</value>
</data>
<data name="PaleLight" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\light pale codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
<value>..\resources\light pale codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="PaleDark" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\dark pale codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
<value>..\resources\dark pale codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="T_Binary" xml:space="preserve">
<value>BIN</value>
Expand Down Expand Up @@ -2120,6 +2130,9 @@ Sent or received bytes per second through all network interfaces</value>
<data name="OT_TaskManagerParameter" xml:space="preserve">
<value>Task manager program parameter (optional):</value>
</data>
<data name="CMD_DeleteContainingStatement" xml:space="preserve">
<value>Delete Containing Statement</value>
</data>
<data name="CMD_WrapInIf" xml:space="preserve">
<value>Wrap in &lt;if&gt;</value>
</data>
Expand Down Expand Up @@ -2411,9 +2424,6 @@ Expression too long</value>
<data name="CMD_SetNextStatement" xml:space="preserve">
<value>Set Next Statement</value>
</data>
<data name="T_ApplyTo" xml:space="preserve">
<value>Apply to:</value>
</data>
<data name="T_FilePath" xml:space="preserve">
<value>FilePath</value>
</data>
Expand All @@ -2423,12 +2433,6 @@ Expression too long</value>
<data name="OT_ShowSeeContainingTypeTip" xml:space="preserve">
<value>Displays containing type for cross referenced symbols in XML Doc</value>
</data>
<data name="OT_AddShowActiveWindowProperties" xml:space="preserve">
<value>Add "Show Active Window Properties" command to File menu</value>
</data>
<data name="OT_AddShowActiveWindowPropertiesTip" xml:space="preserve">
<value>Displays comprehensive information about the active window pane and its document</value>
</data>
<data name="T_TakenAddress" xml:space="preserve">
<value>Taken Address (Unsafe): </value>
</data>
Expand Down Expand Up @@ -2456,9 +2460,6 @@ Expression too long</value>
<data name="T_Squiggle" xml:space="preserve">
<value>Squiggle</value>
</data>
<data name="CMD_DeleteContainingStatement" xml:space="preserve">
<value>Delete Containing Statement</value>
</data>
<data name="CMD_OpenOutputFolder" xml:space="preserve">
<value>Open Output Folder</value>
</data>
Expand Down Expand Up @@ -2777,14 +2778,14 @@ Ctrl: toggle and select next</value>
<value>Ctrl: Explicit assignment only
Shift: Assign by default only</value>
</data>
<data name="CMD_ExtractLinesContainingSelection" xml:space="preserve">
<value>Extract Lines Containing Selection</value>
</data>
<data name="CMDT_ExtractLinesContainingSelection" xml:space="preserve">
<value>Copy all lines containing current selection into a new window
Shift: Match whole word
Ctrl: Match case</value>
</data>
<data name="CMD_ExtractLinesContainingSelection" xml:space="preserve">
<value>Extract Lines Containing Selection</value>
</data>
<data name="T_Code" xml:space="preserve">
<value>Code</value>
</data>
Expand All @@ -2795,6 +2796,12 @@ Ctrl: Convert underscore("_") separated words to capitalized words</value>
<data name="F_Html" xml:space="preserve">
<value>HTML files|*.html|All files|*.*</value>
</data>
<data name="T_SpecifyLocation" xml:space="preserve">
<value>Specify the location for saving the transformed markdown file</value>
</data>
<data name="T_TransformFailed" xml:space="preserve">
<value>Transformation for file &lt;NAME&gt; failed.</value>
</data>
<data name="T_DiscardUnsavedChanges" xml:space="preserve">
<value>&lt;NAME&gt; is not saved.
Discard its changes?</value>
Expand Down
19 changes: 13 additions & 6 deletions Codist/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,13 @@ Shift: Paste and select next (whole word)</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Dark" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Dark Codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
<value>..\Resources\Dark Codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="Light" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Light Codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
<value>..\Resources\Light Codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="Simple" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Simple Codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
<value>..\Resources\Simple Codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="T_AsParameter" xml:space="preserve">
<value> as parameter</value>
Expand Down Expand Up @@ -1470,7 +1470,8 @@ Ctrl+1, Ctrl+3: Edit.SearchDeclarationInProject</value>
<value>Confirm changes</value>
</data>
<data name="CMDT_SaveTheme" xml:space="preserve">
<value>Save syntax highlight theme...</value>
<value>Save syntax highlight theme...
Shift: Save built-in default styles as well</value>
</data>
<data name="CMDT_SimpleTheme" xml:space="preserve">
<value>Load a predefined simple theme</value>
Expand Down Expand Up @@ -1787,10 +1788,10 @@ Use space to separate multiple search terms.
<value>Pale Light</value>
</data>
<data name="PaleLight" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\light pale codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
<value>..\resources\light pale codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="PaleDark" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\dark pale codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
<value>..\resources\dark pale codist.json;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="T_Binary" xml:space="preserve">
<value>BIN</value>
Expand Down Expand Up @@ -2795,6 +2796,12 @@ Ctrl: Convert underscore("_") separated words to capitalized words</value>
<data name="F_Html" xml:space="preserve">
<value>HTML files|*.html|All files|*.*</value>
</data>
<data name="T_SpecifyLocation" xml:space="preserve">
<value>Specify the location for saving the transformed markdown file</value>
</data>
<data name="T_TransformFailed" xml:space="preserve">
<value>Transformation for file &lt;NAME&gt; failed.</value>
</data>
<data name="T_DiscardUnsavedChanges" xml:space="preserve">
<value>&lt;NAME&gt; is not saved.
Discard its changes?</value>
Expand Down
Loading

0 comments on commit 5dbd5d8

Please sign in to comment.