瀏覽代碼

Add Mermaid diagrams visualizing the terminology proposal

Co-authored-by: tig <[email protected]>
copilot-swe-agent[bot] 1 月之前
父節點
當前提交
896f6d77cb
共有 3 個文件被更改,包括 345 次插入2 次删除
  1. 326 0
      TERMINOLOGY_DIAGRAMS.md
  2. 16 2
      TERMINOLOGY_INDEX.md
  3. 3 0
      TERMINOLOGY_PROPOSAL_SUMMARY.md

+ 326 - 0
TERMINOLOGY_DIAGRAMS.md

@@ -0,0 +1,326 @@
+# Terminology Proposal - Visual Diagrams
+
+This document provides visual diagrams to illustrate the proposed terminology changes for Terminal.Gui's `Application.Top` and related APIs.
+
+## Current vs Proposed Terminology
+
+```mermaid
+graph TB
+    subgraph Current["Current Terminology (Confusing)"]
+        A1[Application.Top]
+        A2[Application.TopLevels]
+        A3[Toplevel class]
+        
+        A1 -.->|"unclear relationship"| A2
+        A1 -.->|"what is 'Top'?"| A3
+        
+        style A1 fill:#ffcccc
+        style A2 fill:#ffcccc
+    end
+    
+    subgraph Proposed["Proposed Terminology (Clear)"]
+        B1[Application.Current]
+        B2[Application.RunStack]
+        B3[Toplevel class<br/>keep as-is]
+        
+        B1 -->|"top item in"| B2
+        B1 -.->|"returns instance of"| B3
+        
+        style B1 fill:#ccffcc
+        style B2 fill:#ccffcc
+        style B3 fill:#ffffcc
+    end
+    
+    Current -.->|"rename to"| Proposed
+```
+
+## Application.Current - Stack Relationship
+
+```mermaid
+graph TD
+    subgraph RunStack["Application.RunStack (ConcurrentStack&lt;Toplevel&gt;)"]
+        direction TB
+        Dialog[Dialog<br/>Modal: true]
+        Window[Window<br/>Modal: false]
+        MainView[Main Toplevel<br/>Modal: false]
+        
+        Dialog -->|"on top of"| Window
+        Window -->|"on top of"| MainView
+    end
+    
+    Current[Application.Current] -->|"returns top of stack"| Dialog
+    
+    style Current fill:#ccffcc,stroke:#339933,stroke-width:3px
+    style Dialog fill:#ffd6cc,stroke:#ff6633,stroke-width:2px
+    style Window fill:#cce6ff
+    style MainView fill:#cce6ff
+```
+
+## Before: Confusing Naming Pattern
+
+```mermaid
+sequenceDiagram
+    participant Dev as Developer
+    participant Code as Code
+    participant API as Application API
+    
+    Dev->>Code: Application.Top?
+    Code->>Dev: 🤔 Top of what?
+    
+    Dev->>Code: Application.TopLevels?
+    Code->>Dev: 🤔 How does Top relate to TopLevels?
+    
+    Dev->>Code: Is this the topmost view?
+    Code->>Dev: 🤔 Or the currently running one?
+    
+    Note over Dev,API: Requires documentation lookup
+    Dev->>API: Read docs...
+    API->>Dev: Top = currently active view
+```
+
+## After: Self-Documenting Pattern
+
+```mermaid
+sequenceDiagram
+    participant Dev as Developer
+    participant Code as Code
+    participant API as Application API
+    
+    Dev->>Code: Application.Current?
+    Code->>Dev: ✓ Obviously the current view!
+    
+    Dev->>Code: Application.RunStack?
+    Code->>Dev: ✓ Stack of running views!
+    
+    Dev->>Code: Current from RunStack?
+    Code->>Dev: ✓ Top item in the stack!
+    
+    Note over Dev,API: Self-documenting, no docs needed
+```
+
+## .NET Pattern Consistency
+
+```mermaid
+graph LR
+    subgraph NET[".NET Framework Patterns"]
+        T1[Thread.CurrentThread]
+        T2[HttpContext.Current]
+        T3[SynchronizationContext.Current]
+    end
+    
+    subgraph TG["Terminal.Gui (Proposed)"]
+        T4[Application.Current]
+    end
+    
+    NET -->|"follows established pattern"| TG
+    
+    style T4 fill:#ccffcc,stroke:#339933,stroke-width:3px
+    style T1 fill:#e6f3ff
+    style T2 fill:#e6f3ff
+    style T3 fill:#e6f3ff
+```
+
+## View Hierarchy and Run Stack
+
+```mermaid
+graph TB
+    subgraph ViewTree["View Hierarchy (SuperView/SubView)"]
+        direction TB
+        Top[Application.Current<br/>Window]
+        Menu[MenuBar]
+        Status[StatusBar]
+        Content[Content View]
+        Button1[Button]
+        Button2[Button]
+        
+        Top --> Menu
+        Top --> Status
+        Top --> Content
+        Content --> Button1
+        Content --> Button2
+    end
+    
+    subgraph Stack["Application.RunStack"]
+        direction TB
+        S1[Window<br/>Currently Active]
+        S2[Previous Toplevel<br/>Waiting]
+        S3[Base Toplevel<br/>Waiting]
+        
+        S1 -.-> S2 -.-> S3
+    end
+    
+    Top -.->|"same instance"| S1
+    
+    style Top fill:#ccffcc,stroke:#339933,stroke-width:3px
+    style S1 fill:#ccffcc,stroke:#339933,stroke-width:3px
+```
+
+## Usage Example Flow
+
+```mermaid
+sequenceDiagram
+    participant App as Application
+    participant Main as Main Window
+    participant Dialog as Dialog
+    
+    Note over App: Initially empty RunStack
+    
+    App->>Main: Run(mainWindow)
+    activate Main
+    Note over App: RunStack: [Main]<br/>Current: Main
+    
+    Main->>Dialog: Run(dialog)
+    activate Dialog
+    Note over App: RunStack: [Dialog, Main]<br/>Current: Dialog
+    
+    Dialog->>App: RequestStop()
+    deactivate Dialog
+    Note over App: RunStack: [Main]<br/>Current: Main
+    
+    Main->>App: RequestStop()
+    deactivate Main
+    Note over App: RunStack: []<br/>Current: null
+```
+
+## Terminology Evolution Path
+
+```mermaid
+graph LR
+    subgraph Current["v2 Current State"]
+        C1[Application.Top]
+        C2[Application.TopLevels]
+        C3[Toplevel class]
+    end
+    
+    subgraph Phase1["Phase 1: Add New APIs"]
+        P1[Application.Current]
+        P2[Application.RunStack]
+        P3[Toplevel class]
+        P1O["Application.Top<br/>[Obsolete]"]
+        P2O["Application.TopLevels<br/>[Obsolete]"]
+    end
+    
+    subgraph Phase2["Phase 2-4: Migration"]
+        M1[Application.Current]
+        M2[Application.RunStack]
+        M3[Toplevel class]
+        M1O["Application.Top<br/>[Obsolete Warning]"]
+        M2O["Application.TopLevels<br/>[Obsolete Warning]"]
+    end
+    
+    subgraph Future["Phase 5: Future State"]
+        F1[Application.Current]
+        F2[Application.RunStack]
+        F3["IRunnable interface"]
+        F4["Toplevel : IRunnable"]
+    end
+    
+    Current --> Phase1
+    Phase1 --> Phase2
+    Phase2 --> Future
+    
+    style P1 fill:#ccffcc
+    style P2 fill:#ccffcc
+    style M1 fill:#ccffcc
+    style M2 fill:#ccffcc
+    style F1 fill:#ccffcc
+    style F2 fill:#ccffcc
+    style F3 fill:#ffffcc
+    style P1O fill:#ffcccc
+    style P2O fill:#ffcccc
+    style M1O fill:#ffcccc
+    style M2O fill:#ffcccc
+```
+
+## Comparison: Code Clarity
+
+```mermaid
+graph TB
+    subgraph Before["Before: Application.Top"]
+        B1["var top = Application.Top;"]
+        B2{"What is 'Top'?"}
+        B3["Read documentation"]
+        B4["Understand: currently active view"]
+        
+        B1 --> B2 --> B3 --> B4
+    end
+    
+    subgraph After["After: Application.Current"]
+        A1["var current = Application.Current;"]
+        A2["✓ Immediately clear:<br/>currently active view"]
+        
+        A1 --> A2
+    end
+    
+    Before -.->|"improved to"| After
+    
+    style B2 fill:#ffcccc
+    style B3 fill:#ffcccc
+    style A2 fill:#ccffcc
+```
+
+## Migration Phases Overview
+
+```mermaid
+gantt
+    title Migration Timeline
+    dateFormat YYYY-MM
+    section API
+    Add new APIs (backward compatible)           :done, phase1, 2024-01, 1M
+    Update documentation                          :active, phase2, 2024-02, 1M
+    Refactor internal code                        :phase3, 2024-03, 2M
+    Enable deprecation warnings                   :phase4, 2024-05, 1M
+    Remove deprecated APIs (major version)        :phase5, 2025-01, 1M
+    
+    section IRunnable Evolution
+    Design IRunnable interface                    :future1, 2024-06, 3M
+    Implement IRunnable                           :future2, 2024-09, 3M
+    Migrate to IRunnable                          :future3, 2025-01, 6M
+```
+
+## Key Benefits Visualization
+
+```mermaid
+mindmap
+  root((Application.Current<br/>& RunStack))
+    Clarity
+      Self-documenting
+      No ambiguity
+      Immediate understanding
+    Consistency
+      Follows .NET patterns
+      Thread.CurrentThread
+      HttpContext.Current
+    Maintainability
+      Easier for new developers
+      Less documentation needed
+      Reduced cognitive load
+    Future-proof
+      Works with IRunnable
+      Supports evolution
+      Non-breaking changes
+    Migration
+      Backward compatible
+      Gradual deprecation
+      Clear upgrade path
+```
+
+## Summary
+
+These diagrams illustrate:
+
+1. **Clear Relationships**: The new terminology makes the relationship between `Current` and `RunStack` obvious
+2. **Self-Documenting**: Names that immediately convey their purpose without documentation
+3. **.NET Alignment**: Consistency with established .NET framework patterns
+4. **Migration Safety**: Backward-compatible approach with clear phases
+5. **Future-Proof**: Supports evolution toward `IRunnable` interface
+
+The proposed terminology (`Application.Current` and `Application.RunStack`) provides immediate clarity while maintaining compatibility and supporting future architectural improvements.
+
+---
+
+**See also:**
+- [TERMINOLOGY_PROPOSAL.md](TERMINOLOGY_PROPOSAL.md) - Complete detailed proposal
+- [TERMINOLOGY_PROPOSAL_SUMMARY.md](TERMINOLOGY_PROPOSAL_SUMMARY.md) - Quick reference
+- [TERMINOLOGY_BEFORE_AFTER.md](TERMINOLOGY_BEFORE_AFTER.md) - Code comparison examples
+- [TERMINOLOGY_INDEX.md](TERMINOLOGY_INDEX.md) - Navigation guide

+ 16 - 2
TERMINOLOGY_INDEX.md

@@ -13,7 +13,20 @@ Quick overview of the proposal with key recommendations in a table format. Best
 - Migration strategy overview
 - Quick code examples
 
-### 2. [TERMINOLOGY_BEFORE_AFTER.md](TERMINOLOGY_BEFORE_AFTER.md) 📊 **See the Difference**
+### 2. [TERMINOLOGY_DIAGRAMS.md](TERMINOLOGY_DIAGRAMS.md) 📊 **Visual Diagrams**
+Mermaid diagrams visualizing the proposal, relationships, and migration path.
+
+**Contents:**
+- Current vs Proposed terminology comparison
+- Stack relationship diagrams
+- Before/After naming patterns
+- .NET pattern consistency
+- View hierarchy and run stack
+- Usage flow examples
+- Evolution path timeline
+- Migration phases Gantt chart
+
+### 3. [TERMINOLOGY_BEFORE_AFTER.md](TERMINOLOGY_BEFORE_AFTER.md) 📝 **Code Examples**
 Side-by-side comparisons showing how the new terminology improves code clarity.
 
 **Contents:**
@@ -23,7 +36,7 @@ Side-by-side comparisons showing how the new terminology improves code clarity.
 - Consistency with .NET patterns
 - Summary comparison table
 
-### 3. [TERMINOLOGY_PROPOSAL.md](TERMINOLOGY_PROPOSAL.md) 📖 **Full Details**
+### 4. [TERMINOLOGY_PROPOSAL.md](TERMINOLOGY_PROPOSAL.md) 📖 **Full Details**
 Complete, comprehensive proposal with all analysis, rationale, and implementation details.
 
 **Contents:**
@@ -59,6 +72,7 @@ Complete, comprehensive proposal with all analysis, rationale, and implementatio
 **If you want to...**
 
 - 📋 **Get the gist quickly**: Read [TERMINOLOGY_PROPOSAL_SUMMARY.md](TERMINOLOGY_PROPOSAL_SUMMARY.md)
+- 🎨 **See visual diagrams**: Read [TERMINOLOGY_DIAGRAMS.md](TERMINOLOGY_DIAGRAMS.md)
 - 👀 **See concrete examples**: Read [TERMINOLOGY_BEFORE_AFTER.md](TERMINOLOGY_BEFORE_AFTER.md)
 - 🔍 **Understand all details**: Read [TERMINOLOGY_PROPOSAL.md](TERMINOLOGY_PROPOSAL.md)
 - 💡 **Implement the changes**: See implementation checklist in [TERMINOLOGY_PROPOSAL.md](TERMINOLOGY_PROPOSAL.md)

+ 3 - 0
TERMINOLOGY_PROPOSAL_SUMMARY.md

@@ -54,6 +54,9 @@ var focused = Application.Current.MostFocused;
 
 ## See Also
 
+- [Visual Diagrams](TERMINOLOGY_DIAGRAMS.md) - Mermaid diagrams visualizing the proposal
 - [Full Proposal Document](TERMINOLOGY_PROPOSAL.md) - Complete analysis and implementation details
+- [Before/After Examples](TERMINOLOGY_BEFORE_AFTER.md) - Side-by-side code comparisons
+- [Documentation Index](TERMINOLOGY_INDEX.md) - Navigation guide
 - Issue #4329 - Original issue requesting terminology improvements
 - Issue #2491 - Toplevel refactoring and `IRunnable` interface work