Table of Contents

Class TuiConfigurationBuilder

Namespace
Terminal.Gui.Configuration
Assembly
Terminal.Gui.dll

Builds and manages a Terminal.Gui MEC-based configuration, loading from all standard sources in the correct precedence order.

public class TuiConfigurationBuilder
Inheritance
TuiConfigurationBuilder
Inherited Members

Remarks

This is the MEC-based configuration entry point. It provides the same multi-source precedence (library defaults → app defaults → user files → environment variables → runtime config) using standard Microsoft.Extensions.Configuration.

App Developer Usage:

// Define your app settings POCO:
public class MyAppSettings
{
    public string Title { get; set; } = "My App";
    public bool DarkMode { get; set; }
    public static MyAppSettings Defaults { get; set; } = new ();
}

// In your app startup:
var builder = new TuiConfigurationBuilder ("MyApp");
builder.BindAppSettings<MyAppSettings> ("MyApp", s => MyAppSettings.Defaults = s);
builder.ApplyToStaticFacades ();

// Access settings:
string title = MyAppSettings.Defaults.Title;

To add custom configuration sources, use the MEC extension methods directly:

IConfigurationBuilder configBuilder = new ConfigurationBuilder ()
    .AddTuiLibraryDefaults ()
    .AddTuiUserFiles ("MyApp")
    .AddJsonFile ("custom-settings.json", optional: true);
IConfiguration config = configBuilder.Build ();

Constructors

TuiConfigurationBuilder(string?, string?)

Initializes a new instance of TuiConfigurationBuilder.

Properties

Configuration

Gets the built IConfiguration instance. Lazily built on first access. Rebuilt when RuntimeConfig changes.

RuntimeConfig

Gets or sets the runtime configuration JSON string (highest priority). Setting this invalidates the cached configuration, causing a rebuild on next access.

SchemeManager

Gets the MEC-backed scheme manager instance for this builder.

Shared

Process-wide builder used by ThemeManager and module initialization.

ThemeManager

Gets the MEC-backed theme manager instance for this builder.

Methods

ApplyActiveThemeOverlays()

Publishes ThemeScope Current values and schemes for Defaults.Theme. Does not re-read the Theme scalar from configuration.

ApplyToStaticFacades()

Applies configuration sources to SettingsScope facades, then publishes the active theme's overlays. Always raises ThemeChanged afterwards — the facades were re-published wholesale, so subscribers must re-render even when the theme name is unchanged (e.g. a hot reload that edits the current theme's colors).

BindAppSettings<T>(string, Action<T>)

Binds a custom application settings section from the configuration to a POCO instance. This is the MEC replacement for application-specific settings sections.

Build()

Builds the configuration from all sources in precedence order.

Reload()

Invalidates the cached configuration so the next access to Configuration rebuilds from all sources. Use after a configuration file changes on disk.