Browse Source

Renamed property. Updated conceptual docs.

Tig 8 months ago
parent
commit
61bfe2f537

+ 3 - 0
Example/Example.cs

@@ -6,6 +6,9 @@
 using System;
 using System;
 using Terminal.Gui;
 using Terminal.Gui;
 
 
+// Override the default configuraiton for the application to use the Light theme
+ConfigurationManager.RuntimeConfig = """{ "Theme": "Light" }""";
+
 Application.Run<ExampleWindow> ().Dispose ();
 Application.Run<ExampleWindow> ().Dispose ();
 
 
 // Before the application exits, reset Terminal.Gui for clean shutdown
 // Before the application exits, reset Terminal.Gui for clean shutdown

+ 2 - 2
Terminal.Gui/Configuration/ConfigLocations.cs

@@ -48,9 +48,9 @@ public enum ConfigLocations
     AppHome = 0b_0010_0000,
     AppHome = 0b_0010_0000,
 
 
     /// <summary>
     /// <summary>
-    ///     Settings in <see cref="ConfigurationManager.MemoryConfig"/>.
+    ///     Settings in the <see cref="ConfigurationManager.RuntimeConfig"/> static property.
     /// </summary>
     /// </summary>
-    Memory = 0b_0100_0000,
+    Runtime = 0b_0100_0000,
 
 
     /// <summary>This constant is a combination of all locations</summary>
     /// <summary>This constant is a combination of all locations</summary>
     All = 0b_1111_1111
     All = 0b_1111_1111

+ 4 - 4
Terminal.Gui/Configuration/ConfigurationManager.cs

@@ -221,9 +221,9 @@ public static class ConfigurationManager
     }
     }
 
 
     /// <summary>
     /// <summary>
-    ///     Gets or sets the in-memory config.json. See <see cref="ConfigLocations.Memory"/>.
+    ///     Gets or sets the in-memory config.json. See <see cref="ConfigLocations.Runtime"/>.
     /// </summary>
     /// </summary>
-    public static string? Memory { get; set; }
+    public static string? RuntimeConfig { get; set; }
 
 
     /// <summary>
     /// <summary>
     ///     Loads all settings found in the configuration storage locations (<see cref="ConfigLocations"/>). Optionally, resets
     ///     Loads all settings found in the configuration storage locations (<see cref="ConfigLocations"/>). Optionally, resets
@@ -285,9 +285,9 @@ public static class ConfigurationManager
             Settings?.Update ($"~/.tui/{AppName}.{_configFilename}");
             Settings?.Update ($"~/.tui/{AppName}.{_configFilename}");
         }
         }
 
 
-        if (Locations.HasFlag (ConfigLocations.Memory) && !string.IsNullOrEmpty (Memory))
+        if (Locations.HasFlag (ConfigLocations.Runtime) && !string.IsNullOrEmpty (RuntimeConfig))
         {
         {
-            Settings?.Update (Memory, "ConfigurationManager.Memory");
+            Settings?.Update (RuntimeConfig, "ConfigurationManager.Memory");
         }
         }
 
 
         ThemeManager.SelectedTheme = Settings!["Theme"].PropertyValue as string ?? "Default";
         ThemeManager.SelectedTheme = Settings!["Theme"].PropertyValue as string ?? "Default";

+ 2 - 2
UnitTests/Application/ApplicationTests.cs

@@ -539,10 +539,10 @@ public class ApplicationTests
     public void Init_KeyBindings_Set_To_Custom ()
     public void Init_KeyBindings_Set_To_Custom ()
     {
     {
         // arrange
         // arrange
-        Locations = ConfigLocations.Memory;
+        Locations = ConfigLocations.Runtime;
         ThrowOnJsonErrors = true;
         ThrowOnJsonErrors = true;
 
 
-        Memory = """
+        RuntimeConfig = """
                          {
                          {
                                "Application.QuitKey": "Ctrl-Q"
                                "Application.QuitKey": "Ctrl-Q"
                          }
                          }

+ 1 - 1
UnitTests/Configuration/ConfigurationMangerTests.cs

@@ -220,7 +220,7 @@ public class ConfigurationManagerTests
         Assert.Equal (Key.Esc, (Key)Settings! ["Application.QuitKey"].PropertyValue);
         Assert.Equal (Key.Esc, (Key)Settings! ["Application.QuitKey"].PropertyValue);
 
 
         // act
         // act
-        Memory = """
+        RuntimeConfig = """
                    
                    
                            {
                            {
                                  "Application.QuitKey": "Ctrl-Q"
                                  "Application.QuitKey": "Ctrl-Q"

+ 20 - 64
docfx/docs/config.md

@@ -12,17 +12,19 @@ Settings that will apply to all applications (global settings) reside in files n
 
 
 Settings are applied using the following precedence (higher precedence settings overwrite lower precedence settings):
 Settings are applied using the following precedence (higher precedence settings overwrite lower precedence settings):
 
 
-1. App-specific settings in the users's home directory (`~/.tui/appname.config.json`). -- Highest precedence.
+1. @Terminal.Gui.ConfigLocations.Runtime - Settings stored in the @Terminal.Gui.ConfigurationManager.RuntimeConfig static property --- Hightest precedence.
 
 
-2. App-specific settings in the directory the app was launched from (`./.tui/appname.config.json`).
+2. @Terminal.Gui.ConfigLocations.AppHome - App-specific settings in the users's home directory (`~/.tui/appname.config.json`). 
 
 
-3. App settings in app resources (`Resources/config.json`).
+3. @Terminal.Gui.ConfigLocations.AppCurrent - App-specific settings in the directory the app was launched from (`./.tui/appname.config.json`).
 
 
-4. Global settings in the the user's home directory (`~/.tui/config.json`).
+4. @Terminal.Gui.ConfigLocations.AppResources - App settings in app resources (`Resources/config.json`).
 
 
-5. Global settings in the directory the app was launched from (`./.tui/config.json`).
+5. @Terminal.Gui.ConfigLocations.GlobalHome - Global settings in the the user's home directory (`~/.tui/config.json`).
 
 
-6. Default settings in the Terminal.Gui assembly -- Lowest precedence.
+6. @Terminal.Gui.ConfigLocations.GlobalCurrent - Global settings in the directory the app was launched from (`./.tui/config.json`).
+
+7. @Terminal.Gui.ConfigLocations.Default - Default settings in the Terminal.Gui assembly -- Lowest precedence.
 
 
 The `UI Catalog` application provides an example of how to use the [`ConfigurationManager`](~/api/Terminal.Gui.ConfigurationManager.yml) class to load and save configuration files. The `Configuration Editor` scenario provides an editor that allows users to edit the configuration files. UI Catalog also uses a file system watcher to detect changes to the configuration files to tell [`ConfigurationManager`](~/api/Terminal.Gui.ConfigurationManager.yml) to reload them; allowing users to change settings without having to restart the application.
 The `UI Catalog` application provides an example of how to use the [`ConfigurationManager`](~/api/Terminal.Gui.ConfigurationManager.yml) class to load and save configuration files. The `Configuration Editor` scenario provides an editor that allows users to edit the configuration files. UI Catalog also uses a file system watcher to detect changes to the configuration files to tell [`ConfigurationManager`](~/api/Terminal.Gui.ConfigurationManager.yml) to reload them; allowing users to change settings without having to restart the application.
 
 
@@ -67,71 +69,25 @@ A Theme is a named collection of settings that impact the visual style of Termin
 
 
 Themes support defining ColorSchemes as well as various default settings for Views. Both the default color schemes and user-defined color schemes can be configured. See [ColorSchemes](~/api/Terminal.Gui.Colors.yml) for more information.
 Themes support defining ColorSchemes as well as various default settings for Views. Both the default color schemes and user-defined color schemes can be configured. See [ColorSchemes](~/api/Terminal.Gui.Colors.yml) for more information.
 
 
-# Example Configuration File
-
-```json
-{
-  "$schema": "https://gui-cs.github.io/Terminal.Gui/schemas/tui-config-schema.json",
-  "Application.QuitKey": {
-    "Key": "Esc"
-  },
-  "AppSettings": {
-    "UICatalog.StatusBar": false
-  },
-  "Theme": "UI Catalog Theme",
-  "Themes": [
-    {
-      "UI Catalog Theme": {
-        "ColorSchemes": [
-          {
-            "UI Catalog Scheme": {
-              "Normal": {
-                "Foreground": "White",
-                "Background": "Green"
-              },
-              "Focus": {
-                "Foreground": "Green",
-                "Background": "White"
-              },
-              "HotNormal": {
-                "Foreground": "Blue",
-                "Background": "Green"
-              },
-              "HotFocus": {
-                "Foreground": "BrightRed",
-                "Background": "White"
-              },
-              "Disabled": {
-                "Foreground": "BrightGreen",
-                "Background": "Gray"
-              }
-            }
-          },
-          {
-            "TopLevel": {
-              "Normal": {
-                "Foreground": "DarkGray",
-                "Background": "White"
-              ...
-              }
-            }
-          }
-        ],
-        "Dialog.DefaultEffect3D": false
-      }
-    }
-  ]
-}
-```
 
 
 # Key Bindings
 # Key Bindings
 
 
 Key bindings are defined in the `KeyBindings` property of the configuration file. The value is an array of objects, each object defining a key binding. The key binding object has the following properties:
 Key bindings are defined in the `KeyBindings` property of the configuration file. The value is an array of objects, each object defining a key binding. The key binding object has the following properties:
 
 
-- `Key`: The key to bind to. The format is a string describing the key (e.g. "q", "Q,  "Ctrl-Q"). Function keys are specified as "F1", "F2", etc. 
+- `Key`: The key to bind to. The format is a string describing the key (e.g. "q", "Q,  "Ctrl+Q"). Function keys are specified as "F1", "F2", etc. 
 
 
 # Configuration File Schema
 # Configuration File Schema
 
 
-Settings are defined in JSON format, according to the schema found here: 
+Settings are defined in JSON format, according to the schema found here:
 
 
 https://gui-cs.github.io/Terminal.Gui/schemas/tui-config-schema.json
 https://gui-cs.github.io/Terminal.Gui/schemas/tui-config-schema.json
+
+## Schema
+
+[!code-json[tui-config-schema.json](../schemas/tui-config-schema.json)]
+
+# The Default Config File
+
+To illustrate the syntax, the below is the `config.json` file found in `Terminal.Gui.dll`:
+
+[!code-json[config.json](../../Terminal.Gui/Resources/config.json)]