Fixes #5304. Create a TextViewEditor that wraps Editor with a TextView-compatible API#5305
Fixes #5304. Create a TextViewEditor that wraps Editor with a TextView-compatible API#5305Copilot wants to merge 5 commits into
Conversation
…ompatible API Introduces a new Terminal.Gui.TextViewEditor project that provides a TextViewEditor class wrapping the Terminal.Gui.Editor package's Editor view with an API compatible with TextView. This eases migration from TextView to gui-cs/Editor. Key features: - Text property (get/set full document content) - CurrentRow/CurrentColumn/InsertionPoint for cursor position - ReadOnly, TabWidth properties - IsSelecting, SelectedText, SelectedLength for selection - Load(string path) and Load(Stream) for file loading - SelectAll/ClearSelection methods - ContentsChanged, CaretChanged, SelectionChanged events - UnderlyingEditor property for advanced Editor access Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/597eda9c-4689-4846-830e-4c7f9d2d04af Co-authored-by: tig <585482+tig@users.noreply.github.com>
Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/597eda9c-4689-4846-830e-4c7f9d2d04af Co-authored-by: tig <585482+tig@users.noreply.github.com>
|
@copilot Prove this works by porting the Notepad Scenario to use TextViewEditor. |
|
@copilot TextViewEditor should not be a new project, just a new View-derived class in ./Views. |
Demonstrates that TextViewEditor is a drop-in replacement for TextView in a real-world scenario. The NotepadEditor scenario mirrors the original Notepad scenario but uses TextViewEditor instead of TextView for all text editing functionality. Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/8d6fc3c8-1415-477d-8663-fefae033d836 Co-authored-by: tig <585482+tig@users.noreply.github.com>
Done in 90fd1aa. Added a
The scenario demonstrates that |
Moving The separate project ( Would you like me to:
|
Sensible decision. That makes much more sense. |
|
@copilot keep separte project. I do not want a new scenario; I wanted you to ugprade the existing Notepad scenario. |
…se TextViewEditor Agent-Logs-Url: https://github.com/gui-cs/Terminal.Gui/sessions/5992c475-34d5-4941-8f1e-c499738e2721 Co-authored-by: tig <585482+tig@users.noreply.github.com>
Done in 430b0de. Removed the |
|
@copilot What would it take to just have TextView wrap Editor? |
The main blocker is the circular dependency:
The most practical path: vendor the Editor source into |
|
@copilot I've long wanted to move ./Views to a separate assembly (or assemblies). One, to enforce that they can't use internal APIs. Two, to help reduce the size of the main TG assembly. Help me suss out a strategy for doing this where it's possible for some of the Views (like Editor, Markdown, TableView, ...) could be in their own repos. |
Here's a strategy for splitting Views into separate assemblies: Proposed Assembly Layering: Step 1 — Audit internal API usage. I checked and Views mostly declare their own internal helpers (e.g., Markdown has 17 internal types/members, all self-contained). Only 2 cases in all of Step 2 — Promote or replace the few needed internals. Options:
Step 3 — Define the split criteria. Views stay in Core if they are:
Views move out if they are:
Step 4 — Package structure (two models, pick one): (A) Mono-repo, multi-project — Views live in this repo as separate csproj's referencing (B) Multi-repo — Like Editor today. Each view repo references Recommended hybrid: Start with (A) for first-party views (TableView, TreeView, Markdown, FileDialogs, GraphView). Use (B) only for community-maintained views (Editor already proves this works). A meta-package Step 5 — Migration path:
This keeps backward compatibility while enforcing that Views only use public API. |
Fixes
Proposed Changes/Todos
New
Terminal.Gui.TextViewEditorproject wrapping theTerminal.Gui.EditorNuGet package with aTextView-compatible API surface to ease incremental migration. The project is kept separate fromTerminal.Guito avoid a circular dependency (Terminal.Gui→Terminal.Gui.Editor→Terminal.Gui).Wrapper API exposed:
Text,CurrentRow,CurrentColumn,InsertionPoint,LinesReadOnly,TabWidthIsSelecting,SelectedText,SelectedLength,SelectAll(),ClearSelection()IsDirtyLoad(string path),Load(Stream)CaretChanged,SelectionChanged,ContentsChangedeventsUnderlyingEditor/Documentescape hatches for advanced usageInfrastructure:
Terminal.Gui.Editorv2.1.1-develop.75 toDirectory.Packages.propsnuget.configpackage source mapping to allowTerminal.Gui.Editorfrom nuget.orgTests/TextViewEditorTests) with 21 unit testsNotepad scenario upgraded:
Notepadscenario to useTextViewEditorinstead ofTextViewTextView→TextViewEditortype swap,TabKeyAddsTab = falseremoved (Editor handles tab behavior viaIndentationSize)TextViewEditorAPIUsage:
Pull Request checklist:
CTRL-K-Dto automatically reformat your files before committing.dotnet testbefore commit///style comments)