You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -278,12 +283,84 @@ SchemeManager.AddScheme("MyScheme", new Scheme
278
283
Normal=newAttribute(Color.White, Color.Blue),
279
284
Focus=newAttribute(Color.Black, Color.Cyan)
280
285
});
286
+
```
287
+
288
+
#### Custom Schemes for Individual Views
289
+
290
+
Any view can be given a named scheme by setting `View.SchemeName`. When set, `GetScheme()` looks up that name in the active theme and uses it if found. If the name is not found in the current theme, it falls back through the normal resolution chain (SuperView → `"Base"` → hard-coded `"Base"`) rather than throwing.
281
291
282
-
// Listen for scheme changes
283
-
SchemeManager.CollectionChanged+= (sender, e) =>
292
+
```csharp
293
+
// 1. Register the custom scheme (call before Application.Init or after ConfigurationManager.Apply)
| 5 |`"Base"` exists in active theme | Active theme's `"Base"` scheme |
355
+
| 6 |*(last resort)*| Hard-coded `"Base"` — always available |
356
+
357
+
When writing code that looks up a scheme by name, prefer `SchemeManager.TryGetScheme()` over `SchemeManager.GetScheme(string)` — the `Try` variant returns `false` instead of throwing `KeyNotFoundException` when the name is not found.
358
+
359
+
```csharp
360
+
if (SchemeManager.TryGetScheme("Highlight", outScheme? scheme))
361
+
{
362
+
// use scheme
363
+
}
287
364
```
288
365
289
366
#### Scheme Structure
@@ -312,6 +389,26 @@ Each [Scheme](~/api/Terminal.Gui.Drawing.Scheme.yml) maps [VisualRole](~/api/Ter
312
389
"Background": "Cyan",
313
390
"Style": "Underline"
314
391
},
392
+
"Active": {
393
+
"Foreground": "White",
394
+
"Background": "DarkCyan"
395
+
},
396
+
"HotActive": {
397
+
"Foreground": "Yellow",
398
+
"Background": "DarkCyan"
399
+
},
400
+
"Highlight": {
401
+
"Foreground": "Black",
402
+
"Background": "BrightGreen"
403
+
},
404
+
"Editable": {
405
+
"Foreground": "White",
406
+
"Background": "DarkBlue"
407
+
},
408
+
"ReadOnly": {
409
+
"Foreground": "Gray",
410
+
"Background": "Black"
411
+
},
315
412
"Disabled": {
316
413
"Foreground": "DarkGray",
317
414
"Background": "Black",
@@ -458,35 +555,36 @@ The ConfigurationManager provides events to track configuration changes:
458
555
Raised after configuration is applied to the application:
459
556
460
557
```csharp
461
-
ConfigurationManager.Applied+= (sender, e) =>
558
+
ConfigurationManager.Applied+= (_, _) =>
462
559
{
463
560
// Configuration has been applied
464
561
// Update UI or refresh views
465
562
};
466
563
```
467
564
468
-
### ThemeChanged Event
565
+
### Updated Event
469
566
470
-
Raised when the active theme changes:
567
+
Raised after configuration is loaded from a source or reset (before `Apply()` is called):
471
568
472
569
```csharp
473
-
ThemeManager.ThemeChanged+= (sender, e) =>
570
+
ConfigurationManager.Updated+= (_, _) =>
474
571
{
475
-
// Theme has changed
476
-
// Refresh all views to use new theme
477
-
// From within a View, use: App?.Current?.SetNeedsDraw();
478
-
// Or access via IApplication instance: app.Current?.SetNeedsDraw();
572
+
// Configuration has been loaded or reset
573
+
// Inspect ConfigurationManager.Settings if needed
479
574
};
480
575
```
481
576
482
-
### CollectionChanged Event
577
+
### ThemeChanged Event
483
578
484
-
Raised when schemes collection changes:
579
+
Raised when the active theme changes:
485
580
486
581
```csharp
487
-
SchemeManager.CollectionChanged+= (sender, e) =>
582
+
ThemeManager.ThemeChanged+= (_, e) =>
488
583
{
489
-
// Schemes have changed
584
+
// e.Value is the new theme name
585
+
// Refresh all views to use new theme
586
+
// From within a View, use: App?.Current?.SetNeedsDraw();
587
+
// Or access via IApplication instance: app.Current?.SetNeedsDraw();
490
588
};
491
589
```
492
590
@@ -501,7 +599,7 @@ System-wide settings from [SettingsScope](~/api/Terminal.Gui.Configuration.Setti
0 commit comments