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 |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
|
@copilot study all uses of TextView in the codebase. Identify specific places where simply renaming TextView to TextViewEditor would break something. IOW, how far off is TextViewEditor from TextView. |
Here's the full gap analysis. TextViewEditor currently exposes ~13 of TextView's ~75 public members. ✅ Safe to rename (already in TextViewEditor):
❌ Would break — 62+ missing members grouped by category:
Specific scenario breakage if you renamed today:
Bottom line: TextViewEditor covers the basics (text get/set, cursor position, dirty tracking, file I/O). It's ~17% of the public surface. The remaining 83% falls into Editor's own API accessible via |
|
Closing as a bad idea. See #5322 instead. |
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)