Fixes #2597. Enables standard glyphs to be set via ConfigurationManager (#2595)

* initial

* basically working

* removed test settings

* removed extra usings

* Improved API docs

* Renamed glyphs to be consistent and use unicode names; use char literals

* Refactored Glyphs class & Json format to not be static (startup perf)

* Refactored Glyphs class & Json format to not be static (startup perf)

* Fixed a bunch of API doc errors

* Switched checked/selected to glyhps from box drawing range

* Switched button glyphs to nicer looking ones that seem to work on standard fonts

* Upgraded LineDrawing scenario

* CrossHair->Cross

* Fixed unit tests

* Fixed unit tests; moved Glyphs from Application to ConfigurationManager; added CM global using alias

* Found and replaced all other special glyphs; fixed more unit tests
This commit is contained in:
Tig
2023-05-07 07:34:02 +02:00
committed by GitHub
parent 16e2fc2ac1
commit dea5f0fe03
75 changed files with 1804 additions and 1477 deletions

View File

@@ -1,12 +1,12 @@
# Configuration Management
Terminal.Gui provides configuration and theme management for Terminal.Gui applications via the [`ConfigurationManager`](~/api/Terminal.Gui/Terminal.Gui.Configuration.
Terminal.Gui provides configuration and theme management for Terminal.Gui applications via the [`ConfigurationManager`](~/api/Terminal.Gui/Terminal.Gui.
1) **Settings**. Settings are applied to the [`Application`](~/api/Terminal.Gui/Terminal.Gui.Application.yml) class. Settings are accessed via the `Settings` property of the [`ConfigurationManager`](~/api/Terminal.Gui/Terminal.Gui.Configuration.ConfigurationManager.yml) class.
1) **Settings**. Settings are applied to the [`Application`](~/api/Terminal.Gui/Terminal.Gui.Application.yml) class. Settings are accessed via the `Settings` property of the [`ConfigurationManager`](~/api/Terminal.Gui/Terminal.Gui.ConfigurationManager.yml) class.
2) **Themes**. Themes are a named collection of settings impacting how applications look. The default theme is named "Default". The built-in configuration stored within the Terminal.Gui library defines two additional themes: "Dark", and "Light". Additional themes can be defined in the configuration files.
3) **AppSettings**. AppSettings allow applicaitons to use the [`ConfigurationManager`](~/api/Terminal.Gui/Terminal.Gui.Configuration.ConfigurationManager.yml) to store and retrieve application-specific settings.
3) **AppSettings**. AppSettings allow applicaitons to use the [`ConfigurationManager`](~/api/Terminal.Gui/Terminal.Gui.ConfigurationManager.yml) to store and retrieve application-specific settings.
The The [`ConfigurationManager`](~/api/Terminal.Gui/Terminal.Gui.Configuration.ConfigurationManager.yml) will look for configuration files in the `.tui` folder in the user's home directory (e.g. `C:/Users/username/.tui` or `/usr/username/.tui`), the folder where the Terminal.Gui application was launched from (e.g. `./.tui`), or as a resource within the Terminal.Gui application's main assembly.
The The [`ConfigurationManager`](~/api/Terminal.Gui/Terminal.Gui.ConfigurationManager.yml) will look for configuration files in the `.tui` folder in the user's home directory (e.g. `C:/Users/username/.tui` or `/usr/username/.tui`), the folder where the Terminal.Gui application was launched from (e.g. `./.tui`), or as a resource within the Terminal.Gui application's main assembly.
Settings that will apply to all applications (global settings) reside in files named config.json. Settings that will apply to a specific Terminal.Gui application reside in files named appname.config.json, where appname is the assembly name of the application (e.g. `UICatalog.config.json`).
@@ -24,19 +24,39 @@ Settings are applied using the following precedence (higher precedence settings
6. Default settings defined in the Terminal.Gui assembly -- Lowest precedence.
The `UI Catalog` application provides an example of how to use the [`ConfigurationManager`](~/api/Terminal.Gui/Terminal.Gui.Configuration.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/Terminal.Gui.Configuration.ConfigurationManager.yml) to reaload 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/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/Terminal.Gui.ConfigurationManager.yml) to reaload them; allowing users to change settings without having to restart the application.
# What Can Be Configured
## Settings
Settings for the [`Application`](~/api/Terminal.Gui/Terminal.Gui.Application.yml) class.
* [QuitKey](~/api/Terminal.Gui/Terminal.Gui.Application.yml#QuitKey)
* [AlternateForwardKey](~/api/Terminal.Gui/Terminal.Gui.Application.yml#AlternateForwardKey)
* [AlternateBackwardKey](~/api/Terminal.Gui/Terminal.Gui.Application.yml#AlternateBackwardKey)
* [UseSystemConsole](~/api/Terminal.Gui/Terminal.Gui.Application.yml#UseSystemConsole)
* [IsMouseDisabled](~/api/Terminal.Gui/Terminal.Gui.Application.yml#IsMouseDisabled)
* [HeightAsBuffer](~/api/Terminal.Gui/Terminal.Gui.Application.yml#HeightAsBuffer)
(Note, this list may not be complete; search the source code for `SerializableConfigurationProperty` to find all settings that can be configured.)
* [Application.QuitKey](~/api/Terminal.Gui/Terminal.Gui.Application.yml#Terminal_Gui_Application_QuitKey)
* [Application.AlternateForwardKey](~/api/Terminal.Gui/Terminal.Gui.Application.yml#Terminal_Gui_Application_AlternateForwardKey)
* [Application.AlternateBackwardKey](~/api/Terminal.Gui/Terminal.Gui.Application.yml#Terminal_Gui_Application_AlternateBackwardKey)
* [Application.UseSystemConsole](~/api/Terminal.Gui/Terminal.Gui.Application.yml#Terminal_Gui_Application_UseSystemConsole)
* [Application.IsMouseDisabled](~/api/Terminal.Gui/Terminal.Gui.Application.yml#Terminal_Gui_Application_IsMouseDisabled)
* [Application.EnableConsoleScrolling](~/api/Terminal.Gui/Terminal.Gui.Application.yml#Terminal_Gui_Application_EnableConsoleScrolling)
## Glyphs
Defines the standard set of glyphs used for standard views (e.g. the default indicator for [Button](~/api/Terminal.Gui/Terminal.Gui.Button.yml)) and line drawing (e.g. [LineCanvas](~/api/Terminal.Gui/Terminal.Gui.LineCanvas.yml)).
The value can be either a decimal number or a string. The string may be:
- A unicode char (e.g. "☑")
- A hex value in U+ format (e.g. "U+2611")
- A hex value in UTF-16 format (e.g. "\\u2611")
```json
"Glyphs": {
"RightArrow": "►",
"LeftArrow": "U+25C4",
"DownArrow": "\\u25BC",
"UpArrow": 965010
}
```
## Themes