Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .claude/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ public class MyDialog : Runnable<string?>

**Disposal**: "Whoever creates it, owns it" - `Run<T>()` auto-disposes, `Run(instance)` requires manual disposal.

### RunnableWrapper<TView, TResult>

`RunnableWrapper<TView, TResult>` wraps a `View` as a runnable without adding prompt buttons.

- Clears wrapper `KeyBindings` and `MouseBindings` so the wrapped view handles input.
- Sets `CommandsToBubbleUp = [Command.Accept]`.
- On accept, extracts result via `ResultExtractor` if set, otherwise from `IValue<TResult>.Value` when implemented.
- Unlike `Prompt`, it does not add OK/Cancel buttons.

---

## View Hierarchy
Expand Down Expand Up @@ -443,6 +452,24 @@ using (IApplication app = Application.Create ().Init ())

## Quick Reference

### IValue<T> Pattern

All typed views expose values through `IValue<T>.Value`. Avoid guessing member names like `.Date`, `.Time`, or `.Color`.

| View | IValue<T> |
|------|-----------|
| TextField | `IValue<string>` |
| NumericUpDown<T> | `IValue<T>` |
| DatePicker | `IValue<DateTime>` |
| TimeEditor | `IValue<TimeSpan>` |
| ColorPicker | `IValue<Color?>` |
| AttributePicker | `IValue<Attribute?>` |
| CheckBox | `IValue<CheckState>` |
| OptionSelector | `IValue<int?>` |
| FlagSelector | `IValue<int?>` |

Implementing `IValue<T>` requires `ValueChanging`, `ValueChanged`, and `ValueChangedUntyped`.

### View Properties

| Property | Purpose |
Expand Down Expand Up @@ -478,3 +505,9 @@ DriverRegistry.Names.WINDOWS // "windows"
DriverRegistry.Names.UNIX // "unix"
DriverRegistry.Names.DOTNET // "dotnet"
```

### Gotchas

- `Terminal.Gui.Drawing.Attribute` may conflict with `System.Attribute` with implicit usings. Use `using TgAttribute = Terminal.Gui.Drawing.Attribute;` or fully qualify.
- `Color.TryParse (string, out Color?)` uses nullable out; `Color.TryParse (string?, IFormatProvider?, out Color)` uses non-nullable out.
- `OpenDialog` results are exposed through `FilePaths`; related state includes `AllowsMultipleSelection`, `Canceled`, and `OpenMode`.
35 changes: 32 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,32 @@ See `.claude/cookbook/` for common UI patterns:
|ViewArrangement|Enum|Movable,Resizable,Overlapped
```

### IValue<T> Pattern (Critical)

All typed views expose their data through `IValue<T>.Value`. Do not guess property-specific names such as `.Date`, `.Time`, or `.Color`.

| View | IValue<T> |
|------|-----------|
| TextField | `IValue<string>` |
| NumericUpDown<T> | `IValue<T>` |
| DatePicker | `IValue<DateTime>` |
| TimeEditor | `IValue<TimeSpan>` |
| ColorPicker | `IValue<Color?>` |
| AttributePicker | `IValue<Attribute?>` |
| CheckBox | `IValue<CheckState>` |
| OptionSelector | `IValue<int?>` |
| FlagSelector | `IValue<int?>` |

Implementing `IValue<T>` requires `ValueChanging`, `ValueChanged`, and `ValueChangedUntyped`.

### RunnableWrapper<TView, TResult>

- Wraps a `View` as a runnable with typed results.
- Clears wrapper `KeyBindings` and `MouseBindings` so the wrapped view handles input.
- Does not add OK/Cancel buttons (unlike `Prompt`).
- Sets `CommandsToBubbleUp = [Command.Accept]`.
- On accept, it extracts results via `ResultExtractor` if provided; otherwise via `IValue<TResult>.Value` when available.

### Terminal.Gui.Views (180+ types)
```
[Core Controls]
Expand All @@ -364,7 +390,7 @@ See `.claude/cookbook/` for common UI patterns:
|DropDownList|Class|Dropdown,Source,SelectedItem
|ProgressBar|Class|Fraction,BidirectionalMarquee
|ScrollBar|Class|Position,Size,Orientation
|NumericUpDown<T>|Class|Value,Increment,Min,Max
|NumericUpDown<T>|Class|Value,Increment

[Containers]
|Window|Class|Top-level,Title,MenuBar support
Expand All @@ -390,7 +416,7 @@ See `.claude/cookbook/` for common UI patterns:

[File Dialogs]
|FileDialog|Class|Base,Path,AllowedFileTypes
|OpenDialog|Class|OpenFile,AllowsMultipleSelection
|OpenDialog|Class|FilePaths,AllowsMultipleSelection,Canceled,OpenMode
|SaveDialog|Class|SaveFile,FileName

[Specialized]
Expand Down Expand Up @@ -429,6 +455,10 @@ See `.claude/cookbook/` for common UI patterns:
|Gradient|Class|Colors[],Spectrum
```

**Gotchas**
- `Terminal.Gui.Drawing.Attribute` can conflict with `System.Attribute` with implicit usings. Use `using TgAttribute = Terminal.Gui.Drawing.Attribute;` or fully qualify.
- `Color.TryParse (string, out Color?)` is nullable out. `Color.TryParse (string?, IFormatProvider?, out Color)` is non-nullable out.

### Terminal.Gui.Drivers (80+ types)
```
|IDriver|Interface|Init,End,Refresh,AddStr,Move
Expand Down Expand Up @@ -518,6 +548,5 @@ See `.claude/cookbook/` for common UI patterns:






Loading