Skip to content

Commit 61bfe2f

Browse files
committed
Renamed property. Updated conceptual docs.
1 parent c23e9dd commit 61bfe2f

File tree

6 files changed

+32
-73
lines changed

6 files changed

+32
-73
lines changed

Example/Example.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
using System;
77
using Terminal.Gui;
88

9+
// Override the default configuraiton for the application to use the Light theme
10+
ConfigurationManager.RuntimeConfig = """{ "Theme": "Light" }""";
11+
912
Application.Run<ExampleWindow> ().Dispose ();
1013

1114
// Before the application exits, reset Terminal.Gui for clean shutdown

Terminal.Gui/Configuration/ConfigLocations.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ public enum ConfigLocations
4848
AppHome = 0b_0010_0000,
4949

5050
/// <summary>
51-
/// Settings in <see cref="ConfigurationManager.MemoryConfig"/>.
51+
/// Settings in the <see cref="ConfigurationManager.RuntimeConfig"/> static property.
5252
/// </summary>
53-
Memory = 0b_0100_0000,
53+
Runtime = 0b_0100_0000,
5454

5555
/// <summary>This constant is a combination of all locations</summary>
5656
All = 0b_1111_1111

Terminal.Gui/Configuration/ConfigurationManager.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ public static string GetEmptyJson ()
221221
}
222222

223223
/// <summary>
224-
/// Gets or sets the in-memory config.json. See <see cref="ConfigLocations.Memory"/>.
224+
/// Gets or sets the in-memory config.json. See <see cref="ConfigLocations.Runtime"/>.
225225
/// </summary>
226-
public static string? Memory { get; set; }
226+
public static string? RuntimeConfig { get; set; }
227227

228228
/// <summary>
229229
/// Loads all settings found in the configuration storage locations (<see cref="ConfigLocations"/>). Optionally, resets
@@ -285,9 +285,9 @@ public static void Load (bool reset = false)
285285
Settings?.Update ($"~/.tui/{AppName}.{_configFilename}");
286286
}
287287

288-
if (Locations.HasFlag (ConfigLocations.Memory) && !string.IsNullOrEmpty (Memory))
288+
if (Locations.HasFlag (ConfigLocations.Runtime) && !string.IsNullOrEmpty (RuntimeConfig))
289289
{
290-
Settings?.Update (Memory, "ConfigurationManager.Memory");
290+
Settings?.Update (RuntimeConfig, "ConfigurationManager.Memory");
291291
}
292292

293293
ThemeManager.SelectedTheme = Settings!["Theme"].PropertyValue as string ?? "Default";

UnitTests/Application/ApplicationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,10 @@ public void Init_KeyBindings_Set_To_Defaults ()
539539
public void Init_KeyBindings_Set_To_Custom ()
540540
{
541541
// arrange
542-
Locations = ConfigLocations.Memory;
542+
Locations = ConfigLocations.Runtime;
543543
ThrowOnJsonErrors = true;
544544

545-
Memory = """
545+
RuntimeConfig = """
546546
{
547547
"Application.QuitKey": "Ctrl-Q"
548548
}

UnitTests/Configuration/ConfigurationMangerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public void Load_Loads_Custom_Json ()
220220
Assert.Equal (Key.Esc, (Key)Settings! ["Application.QuitKey"].PropertyValue);
221221

222222
// act
223-
Memory = """
223+
RuntimeConfig = """
224224
225225
{
226226
"Application.QuitKey": "Ctrl-Q"

docfx/docs/config.md

Lines changed: 20 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@ Settings that will apply to all applications (global settings) reside in files n
1212

1313
Settings are applied using the following precedence (higher precedence settings overwrite lower precedence settings):
1414

15-
1. App-specific settings in the users's home directory (`~/.tui/appname.config.json`). -- Highest precedence.
15+
1. @Terminal.Gui.ConfigLocations.Runtime - Settings stored in the @Terminal.Gui.ConfigurationManager.RuntimeConfig static property --- Hightest precedence.
1616

17-
2. App-specific settings in the directory the app was launched from (`./.tui/appname.config.json`).
17+
2. @Terminal.Gui.ConfigLocations.AppHome - App-specific settings in the users's home directory (`~/.tui/appname.config.json`).
1818

19-
3. App settings in app resources (`Resources/config.json`).
19+
3. @Terminal.Gui.ConfigLocations.AppCurrent - App-specific settings in the directory the app was launched from (`./.tui/appname.config.json`).
2020

21-
4. Global settings in the the user's home directory (`~/.tui/config.json`).
21+
4. @Terminal.Gui.ConfigLocations.AppResources - App settings in app resources (`Resources/config.json`).
2222

23-
5. Global settings in the directory the app was launched from (`./.tui/config.json`).
23+
5. @Terminal.Gui.ConfigLocations.GlobalHome - Global settings in the the user's home directory (`~/.tui/config.json`).
2424

25-
6. Default settings in the Terminal.Gui assembly -- Lowest precedence.
25+
6. @Terminal.Gui.ConfigLocations.GlobalCurrent - Global settings in the directory the app was launched from (`./.tui/config.json`).
26+
27+
7. @Terminal.Gui.ConfigLocations.Default - Default settings in the Terminal.Gui assembly -- Lowest precedence.
2628

2729
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.
2830

@@ -67,71 +69,25 @@ A Theme is a named collection of settings that impact the visual style of Termin
6769

6870
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.
6971

70-
# Example Configuration File
71-
72-
```json
73-
{
74-
"$schema": "https://gui-cs.github.io/Terminal.Gui/schemas/tui-config-schema.json",
75-
"Application.QuitKey": {
76-
"Key": "Esc"
77-
},
78-
"AppSettings": {
79-
"UICatalog.StatusBar": false
80-
},
81-
"Theme": "UI Catalog Theme",
82-
"Themes": [
83-
{
84-
"UI Catalog Theme": {
85-
"ColorSchemes": [
86-
{
87-
"UI Catalog Scheme": {
88-
"Normal": {
89-
"Foreground": "White",
90-
"Background": "Green"
91-
},
92-
"Focus": {
93-
"Foreground": "Green",
94-
"Background": "White"
95-
},
96-
"HotNormal": {
97-
"Foreground": "Blue",
98-
"Background": "Green"
99-
},
100-
"HotFocus": {
101-
"Foreground": "BrightRed",
102-
"Background": "White"
103-
},
104-
"Disabled": {
105-
"Foreground": "BrightGreen",
106-
"Background": "Gray"
107-
}
108-
}
109-
},
110-
{
111-
"TopLevel": {
112-
"Normal": {
113-
"Foreground": "DarkGray",
114-
"Background": "White"
115-
...
116-
}
117-
}
118-
}
119-
],
120-
"Dialog.DefaultEffect3D": false
121-
}
122-
}
123-
]
124-
}
125-
```
12672

12773
# Key Bindings
12874

12975
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:
13076

131-
- `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.
77+
- `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.
13278

13379
# Configuration File Schema
13480

135-
Settings are defined in JSON format, according to the schema found here:
81+
Settings are defined in JSON format, according to the schema found here:
13682

13783
https://gui-cs.github.io/Terminal.Gui/schemas/tui-config-schema.json
84+
85+
## Schema
86+
87+
[!code-json[tui-config-schema.json](../schemas/tui-config-schema.json)]
88+
89+
# The Default Config File
90+
91+
To illustrate the syntax, the below is the `config.json` file found in `Terminal.Gui.dll`:
92+
93+
[!code-json[config.json](../../Terminal.Gui/Resources/config.json)]

0 commit comments

Comments
 (0)