Skip to content

EditorMenuBar and EditorStatusBar — composable pre-wired controls for Editor #205

@tig

Description

@tig

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

  • Type exists with single-editor and Func<Editor> constructors
  • File menu commands wire to Editor (New/Open/Save/SaveAs/Quit)
  • Edit menu commands wire to undo/redo/clipboard/selection
  • View menu checkboxes toggle Editor properties (GutterOptions, word wrap, etc.)
  • ExtraMenuItems allows appending custom menus
  • ShowOpenDialog / ShowSaveDialog allow dialog customization

EditorStatusBar

  • Type exists with single-editor and Func<Editor> constructors
  • Language, Ln/Col, OVR/INS indicators update from Editor state
  • Theme dropdown switches themes
  • Load progress spinner shows during streaming load
  • ExtraShortcuts allows appending custom indicators

Integration

  • Ted refactored to use both types
  • Another consumer can get full menu + status bar with ~5 lines of code

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions