Commit Graph

6 Commits

Author SHA1 Message Date
Tig
e9976da95e Reapply "Merge branch 'v2_develop' of tig:gui-cs/Terminal.Gui into v2_develop"
This reverts commit 845c05ff47.
2026-02-06 08:57:29 -07:00
Tig
845c05ff47 Revert "Merge branch 'v2_develop' of tig:gui-cs/Terminal.Gui into v2_develop"
This reverts commit 8c4030aed6, reversing
changes made to 280d6a5c1f.
2026-02-06 08:41:02 -07:00
Tig
8ef82e7a82 Add AI agent context for app developers (#4650)
This enhances AI agent documentation to better support developers building
Terminal.Gui applications (vs. contributing to the library itself).

New files:
- llms.txt: Standard AI-readable project context file
- .claude/tasks/build-app.md: Step-by-step app development guide
- .claude/cookbook/common-patterns.md: UI recipes (forms, lists, menus, etc.)

Updated files:
- AGENTS.md: Links to API specs and distinguishes app builder vs contributor
- CLAUDE.md: Quick routing based on task type (building vs contributing)
- .claude/REFRESH.md: References to new task/cookbook resources

https://claude.ai/code/session_01N7etZEx4kzWejVyd2SL2v7

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-30 08:09:21 -07:00
Tig
258529c05d Modernize UICatalog scenarios and fix ReSharper warnings (#4544)
* Modernize ContextMenus scenario and add upgrade guide

- Add #nullable enable to ContextMenus.cs
- Move _cultureInfos initialization after Application.Init()
- Replace var with explicit types for Label
- Convert if statements to switch statement with not-null patterns
- Change local constants to SCREAMING_CASE per project conventions
- Add SCENARIO_UPGRADE_GUIDE.md with modernization checklist

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Modernize TextInputControls scenario

- Add #nullable enable and fix all nullable warnings
- Use modern IApplication pattern with using IApplication app
- Replace var with explicit types for non-built-in types
- Use target-typed new () syntax throughout
- Add null checks for nullable fields and parameters
- Fix event handler sender parameter nullability
- Remove Application.Shutdown() (handled by IApplication disposal)
- Run ReSharper full cleanup for formatting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix ReSharper hints in TextInputControls and modernize Editor

TextInputControls.cs:
- Fix captured variable issue by using sender parameter
- Rename local function to camelCase (textViewDrawContent)
- Replace unused lambda parameters with discards (_)
- Convert List initializer to collection expression
- Remove unnecessary null check

Editor.cs:
- Add modern IApplication pattern with using IApplication app
- Replace Application.Run with app.Run
- Replace Application.RequestStop with _appWindow?.RequestStop
- Remove Application.Shutdown() (handled by IApplication disposal)
- Run ReSharper full cleanup for formatting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Update SCENARIO_UPGRADE_GUIDE with ReSharper hint fixes

Add guidance for:
- Lambda parameter discards (replace unused with _)
- Captured variable closures (use sender or disable warning)
- Local function naming (camelCase)
- Collection expressions (use [...] syntax)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Restructure AI guidance for drift prevention

Create .claude/ directory with focused rule files:
- REFRESH.md - Pre-edit checklist (read before every file)
- rules/type-declarations.md - No var except built-in types
- rules/target-typed-new.md - Use new() syntax
- rules/terminology.md - SubView/SuperView vs Parent/Child
- rules/event-patterns.md - Lambdas, closures, handlers
- rules/collection-expressions.md - [...] syntax
- rules/cwp-pattern.md - Cancellable Workflow Pattern
- tasks/scenario-modernization.md - Moved from Examples/

Simplify CLAUDE.md to reference .claude/ structure instead of
duplicating detailed guidance. This helps AI agents stay on track
by providing focused, re-readable micro-documents.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add Claude Code settings to .gitignore

These are user-local settings files that shouldn't be tracked.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add code layout guidance for ReSharper backing field bug

Document known ReSharper bug (RSRP-484963) where "Properties w/
Backing Field" layout doesn't work. AI agents must manually place
backing fields immediately before their associated properties.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix ReSharper warnings across UICatalog scenarios

- Replace `is { }` with `is not null` for simple null checks
- Fix unused lambda parameters: `(s, e)` → `(_, _)` or `(_, e)`
- Change `var` to explicit types (Label, Window, FrameView, etc.)
- Remove redundant null-forgiving operators and self-assignments
- Modernize Application.Init pattern with `using IApplication app`
- Use pattern matching: `if (sender is not OptionSelector x)`
- Preserve `is { } variable` pattern matching where variable capture needed

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fixed two scenarios.

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 12:39:15 -07:00
Tig
6ee92acb6e Fixes #4145. Add automatic hotkey assignment feature to View base class (#4531)
* Fixes #4145. Add automatic hotkey assignment feature to View base class

Move the automatic hotkey assignment feature from SelectorBase to the
View base class, making it available to all View subclasses.

New features added to View:
- AssignHotKeys property: When true, automatically assigns unique
  hotkeys to subviews when they are added
- UsedHotKeys property: Tracks assigned hotkeys to prevent conflicts
- AssignHotKeysToSubViews(): Manually triggers hotkey assignment
- AssignHotKeyToView(): Assigns a hotkey to a single view

The implementation:
- Preserves existing hotkeys defined via HotKeySpecifier in titles
- Preserves programmatically set hotkeys
- Skips spaces and control characters
- Removes hotkeys from UsedHotKeys when subviews are removed

SelectorBase has been refactored to use the base class implementation.

* Fix CWP order and add terminology guidance to CLAUDE.md

- Move hotkey assignment BEFORE OnSubViewAdded/SubViewAdded CWP events
  so observers see the assigned hotkey
- Add Terminology section to CLAUDE.md with SubView/SuperView guidance
- Add CWP pattern guidance to CLAUDE.md
- Add reference to lexicon.md in Key Architecture Concepts

* Fix duplicate hotkey assignment in SelectorBase

Remove the explicit AssignUniqueHotKeys() call from CreateSubViews()
since the base class now handles hotkey assignment automatically when
SubViews are added via Add(). This was causing hotkeys to be assigned
twice, with the second assignment seeing the first as a "conflict".

* Update HotKeys scenario to demonstrate automatic hotkey assignment

- Add FrameView demonstrating AssignHotKeys feature with auto-assigned
  and manually preserved hotkeys
- Upgrade to modern instance-based Application pattern (using IApplication)
- Use explicit types with target-typed new ()
- Use descriptive variable names
- Use proper multi-line formatting for object initializers
- Add #nullable enable

* Update test variable naming to use SuperView terminology

Rename 'container' to 'superView' throughout the test file to follow
the project's standard terminology (SubView/SuperView, not child/parent/container).

* Update Terminal.Gui/Views/Selectors/SelectorBase.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Terminal.Gui/ViewBase/View.Keyboard.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Refactor keyboard command and hotkey handling logic

- Replaced InvokeCommands with InvokeCommandsBoundToKey for clearer keyboard command invocation.
- Consolidated and simplified command invocation methods.
- Improved hotkey assignment logic and uniqueness enforcement.
- Fixed FlagSelector handling for "None" (0) value and null checks.
- Simplified SelectorBase.DefaultMouseHighlightStates property.
- Cleaned up SelectorBase layout logic for vertical orientation.
- Updated Selectors scenario to use using statements and new app.Run pattern.
- Performed minor code cleanups and updated related tests.

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-06 15:41:08 -07:00
Tig
8e2cf5e2db Add CLAUDE.md with AI agent guidance (#4530)
Create a concise reference file for Claude when working with the
Terminal.Gui codebase, extracted from CONTRIBUTING.md. Includes
build/test commands, coding conventions, and key architecture concepts.

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-04 20:33:36 -07:00