Overview
Phases 2 & 3 of the composable Editor building blocks (follow-up to #178 Phase 1, completed in PR #199).
Introduce EditorMenuBar : MenuBar and EditorStatusBar : StatusBar — optional, composable controls that wire themselves to an Editor instance so consumers don't need to duplicate ~170 lines of menu + status bar construction.
Design Principles
| Principle |
Implication |
| Consumer owns the Runnable |
No EditorWindow base class. Just a Window/Toplevel. |
| Canned parts are optional |
Skip EditorMenuBar / EditorStatusBar freely. |
| Parts take an Editor reference |
Wire to Editor's commands/events/properties. No global state. |
| Consumer calls Add() |
Full control over layout, z-order, additional views. |
| Extra items via composition |
Append without subclassing. |
| No forced settings persistence |
Consumer handles config. |
| No static state on View |
Per CLAUDE.md. |
EditorMenuBar
namespace Terminal.Gui.Editor;
public class EditorMenuBar : MenuBar
{
public EditorMenuBar (Editor editor);
public EditorMenuBar (Func<Editor> activeEditorProvider); // multi-file
public IList<MenuBarItem> ExtraMenuItems { get; }
public Func<string?>? ShowOpenDialog { get; set; }
public Func<string?>? ShowSaveDialog { get; set; }
}
Built-in menus:
- File: New, Open, Save, Save As, Quit
- Edit: Undo, Redo, Cut, Copy, Paste, Select All, Find, Replace
- View: Line Numbers (checkbox), Fold Indicators (checkbox), Word Wrap (checkbox), Show Tabs (checkbox), Scrollbars (checkbox)
All toggle states bind to Editor properties. No settings persistence.
EditorStatusBar
namespace Terminal.Gui.Editor;
public class EditorStatusBar : StatusBar
{
public EditorStatusBar (Editor editor);
public EditorStatusBar (Func<Editor> activeEditorProvider); // multi-file
public IList<Shortcut> ExtraShortcuts { get; }
}
Built-in indicators:
- Language name (from
HighlightingDefinition)
- Theme dropdown (from
ThemeManager)
- Load progress spinner (streaming I/O)
- OVR/INS mode
- Ln/Col position
What Ted becomes
Ted refactors to use both types, adding only its custom items (About dialog, Markdown Preview menu item, app-specific shortcuts) via the Extra* collections. Constructor shrinks from ~350 lines to ~50.
Multi-file support
Both types accept Func<Editor> for multi-file scenarios (TabView, split panes). The consumer owns the tab/split UX; the canned controls track the active editor via the delegate.
Acceptance Criteria
EditorMenuBar
EditorStatusBar
Integration
Dependencies
Overview
Phases 2 & 3 of the composable Editor building blocks (follow-up to #178 Phase 1, completed in PR #199).
Introduce
EditorMenuBar : MenuBarandEditorStatusBar : StatusBar— optional, composable controls that wire themselves to anEditorinstance so consumers don't need to duplicate ~170 lines of menu + status bar construction.Design Principles
EditorWindowbase class. Just aWindow/Toplevel.EditorMenuBar/EditorStatusBarfreely.EditorMenuBar
Built-in menus:
All toggle states bind to Editor properties. No settings persistence.
EditorStatusBar
Built-in indicators:
HighlightingDefinition)ThemeManager)What Ted becomes
Ted refactors to use both types, adding only its custom items (About dialog, Markdown Preview menu item, app-specific shortcuts) via the
Extra*collections. Constructor shrinks from ~350 lines to ~50.Multi-file support
Both types accept
Func<Editor>for multi-file scenarios (TabView, split panes). The consumer owns the tab/split UX; the canned controls track the active editor via the delegate.Acceptance Criteria
EditorMenuBar
Func<Editor>constructorsExtraMenuItemsallows appending custom menusShowOpenDialog/ShowSaveDialogallow dialog customizationEditorStatusBar
Func<Editor>constructorsExtraShortcutsallows appending custom indicatorsIntegration
Dependencies