|
@@ -1,438 +1,319 @@
|
|
|
# Application.Run Terminology - Visual Guide
|
|
# Application.Run Terminology - Visual Guide
|
|
|
|
|
|
|
|
-This document provides visual representations of the Application execution lifecycle to clarify the terminology.
|
|
|
|
|
|
|
+## The Two Problems
|
|
|
|
|
|
|
|
-## Current Terminology (Confusing)
|
|
|
|
|
-
|
|
|
|
|
-### The Problem: "Run" Everywhere
|
|
|
|
|
|
|
+### Problem 1: RunState Sounds Like State Data
|
|
|
|
|
|
|
|
```
|
|
```
|
|
|
-โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
-โ Application.Run() โ โ High-level API
|
|
|
|
|
-โ โ
|
|
|
|
|
-โ "Run" means the complete lifecycle โ
|
|
|
|
|
-โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ
|
|
|
|
|
- โผ
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ Application.Begin(toplevel) โ โ "Begin" what?
|
|
|
|
|
- โ โ
|
|
|
|
|
- โ Returns: RunState โ โ Sounds like state data
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ
|
|
|
|
|
- โผ
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ Application.RunLoop(runState) โ โ "Run" again? Run vs RunLoop?
|
|
|
|
|
- โ โ
|
|
|
|
|
- โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
|
|
- โ โ while (running) โ โ
|
|
|
|
|
- โ โ RunIteration() โ โ โ "Run" again? What's the difference?
|
|
|
|
|
- โ โ ProcessInput() โ โ
|
|
|
|
|
- โ โ Layout/Draw() โ โ
|
|
|
|
|
- โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ
|
|
|
|
|
- โผ
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ Application.End(runState) โ โ "End" what?
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
-
|
|
|
|
|
-Issues:
|
|
|
|
|
-โ "Run" appears 4 times meaning different things
|
|
|
|
|
-โ RunState sounds like state, but it's a token
|
|
|
|
|
-โ Begin/End don't clarify what's beginning/ending
|
|
|
|
|
-โ RunLoop vs RunIteration relationship unclear
|
|
|
|
|
|
|
+Current (Confusing):
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ RunState rs = Begin(window); โ โ "State"? What state does it hold?
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ Application.RunLoop(rs); โ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ Application.End(rs); โ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+
|
|
|
|
|
+Users think: "What state information does RunState contain?"
|
|
|
|
|
+Reality: It's a token/handle for the Begin/End pairing
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+Proposed (Clear):
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ RunToken token = Begin(window); โ โ
Clear: it's a token, not state
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ Application.RunLoop(token); โ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ Application.End(token); โ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+
|
|
|
|
|
+Users understand: "It's a token for the Begin/End pairing"
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
-## Proposed Terminology - Option 1: Session-Based โญ
|
|
|
|
|
-
|
|
|
|
|
-### The Solution: Clear, Explicit Names
|
|
|
|
|
-
|
|
|
|
|
-```
|
|
|
|
|
-โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
-โ Application.Run() โ โ High-level (unchanged)
|
|
|
|
|
-โ โ
|
|
|
|
|
-โ Complete lifecycle: Begin + ProcessEvents + End โ
|
|
|
|
|
-โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ
|
|
|
|
|
- โผ
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ Application.BeginSession(toplevel) โ โ
Clear: starting a session
|
|
|
|
|
- โ โ
|
|
|
|
|
- โ Returns: ToplevelSession โ โ
Clear: it's a session token
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ
|
|
|
|
|
- โผ
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ Application.ProcessEvents(session) โ โ
Clear: processing events
|
|
|
|
|
- โ โ
|
|
|
|
|
- โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
|
|
- โ โ while (running) โ โ
|
|
|
|
|
- โ โ ProcessEventsIteration() โ โ โ
Clear: one iteration of processing
|
|
|
|
|
- โ โ ProcessInput() โ โ
|
|
|
|
|
- โ โ Layout/Draw() โ โ
|
|
|
|
|
- โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ
|
|
|
|
|
- โผ
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ Application.EndSession(session) โ โ
Clear: ending the session
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
-
|
|
|
|
|
-Benefits:
|
|
|
|
|
-โ
"Session" clearly indicates bounded execution
|
|
|
|
|
-โ
"ProcessEvents" describes the action
|
|
|
|
|
-โ
BeginSession/EndSession are unambiguous
|
|
|
|
|
-โ
Terminology is consistent and clear
|
|
|
|
|
-```
|
|
|
|
|
-
|
|
|
|
|
-## Lifecycle Comparison
|
|
|
|
|
-
|
|
|
|
|
-### Application Lifecycle (Init/Shutdown) vs Session Lifecycle (Begin/ProcessEvents/End)
|
|
|
|
|
|
|
+### Problem 2: EndAfterFirstIteration Confuses End() with Loop Control
|
|
|
|
|
|
|
|
```
|
|
```
|
|
|
-โโโโโโโโโโโโโโโโโโโโโโโโโโโ Application Lifetime โโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
-โ โ
|
|
|
|
|
-โ Application.Init() โ Initialize once per application โ
|
|
|
|
|
-โ โโ Create driver โ
|
|
|
|
|
-โ โโ Initialize screen โ
|
|
|
|
|
-โ โโ Setup subsystems โ
|
|
|
|
|
-โ โ
|
|
|
|
|
-โ โโโโโโโโโโโโโโโโโโโโโโโโโ Session 1 โโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
|
|
-โ โ Application.BeginSession(window1) โ session1 โ โ
|
|
|
|
|
-โ โ โโ Initialize window1 โ โ
|
|
|
|
|
-โ โ โโ Layout window1 โ โ
|
|
|
|
|
-โ โ โโ Draw window1 โ โ
|
|
|
|
|
-โ โ โ โ
|
|
|
|
|
-โ โ Application.ProcessEvents(session1) โ โ
|
|
|
|
|
-โ โ โโ Event loop until RequestStop() โ โ
|
|
|
|
|
-โ โ โ โ
|
|
|
|
|
-โ โ Application.EndSession(session1) โ โ
|
|
|
|
|
-โ โ โโ Cleanup window1 โ โ
|
|
|
|
|
-โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
|
|
-โ โ
|
|
|
|
|
-โ โโโโโโโโโโโโโโโโโโโโโโโโโ Session 2 โโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
|
|
-โ โ Application.BeginSession(dialog) โ session2 โ โ
|
|
|
|
|
-โ โ Application.ProcessEvents(session2) โ โ
|
|
|
|
|
-โ โ Application.EndSession(session2) โ โ
|
|
|
|
|
-โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
|
|
-โ โ
|
|
|
|
|
-โ Application.Shutdown() โ Cleanup once per application โ
|
|
|
|
|
-โ โโ Dispose driver โ
|
|
|
|
|
-โ โโ Restore terminal โ
|
|
|
|
|
-โ โ
|
|
|
|
|
-โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
-
|
|
|
|
|
-Key Insight: Multiple sessions within one application lifetime
|
|
|
|
|
|
|
+Current (Confusing):
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ EndAfterFirstIteration = true; โ โ "End"? Like End() method?
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ RunState rs = Begin(window); โ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ RunLoop(rs); // Stops after 1 iterationโ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ End(rs); // This is "End" โ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+
|
|
|
|
|
+Users think: "Does EndAfterFirstIteration call End()?"
|
|
|
|
|
+Reality: It controls RunLoop() behavior, not End()
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+Proposed (Clear):
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ StopAfterFirstIteration = true; โ โ
Clear: controls loop stopping
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ RunToken token = Begin(window); โ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ RunLoop(token); // Stops after 1 iter โ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ End(token); // Cleanup โ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+
|
|
|
|
|
+Users understand: "Stop controls the loop, End cleans up"
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
-## Event Flow During ProcessEvents
|
|
|
|
|
|
|
+## Understanding RunLoop vs RunIteration
|
|
|
|
|
|
|
|
-### Current (Confusing)
|
|
|
|
|
|
|
+**This distinction is valuable and should be preserved:**
|
|
|
|
|
|
|
|
```
|
|
```
|
|
|
-RunLoop(runState)
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> while (toplevel.Running)
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> RunIteration(runState) โ What's the difference?
|
|
|
|
|
- โ โ
|
|
|
|
|
- โ โโ> MainLoop.RunIteration()
|
|
|
|
|
- โ โ โโ> Process driver events
|
|
|
|
|
- โ โ
|
|
|
|
|
- โ โโ> Layout (if needed)
|
|
|
|
|
- โ โโ> Draw (if needed)
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> (repeat)
|
|
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ RunLoop(token) โ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ Starts the driver's MainLoop โ
|
|
|
|
|
+โ Loops until stopped: โ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
|
|
+โ โ while (toplevel.Running) โ โ
|
|
|
|
|
+โ โ { โ โ
|
|
|
|
|
+โ โ RunIteration(ref token); โโโโโโโโโโโโ โ โ
|
|
|
|
|
+โ โ RunIteration(ref token); โโโโโโโโโโโโค โ โ
|
|
|
|
|
+โ โ RunIteration(ref token); โโโโโโโโโโโโค โ โ
|
|
|
|
|
+โ โ ... โ โ โ
|
|
|
|
|
+โ โ } โ โ โ
|
|
|
|
|
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+ โ
|
|
|
|
|
+ โ
|
|
|
|
|
+ โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโ
|
|
|
|
|
+ โ RunIteration(ref token) โ
|
|
|
|
|
+ โ โ
|
|
|
|
|
+ โ Processes ONE iteration: โ
|
|
|
|
|
+ โ 1. Process driver events โ
|
|
|
|
|
+ โ 2. Layout (if needed) โ
|
|
|
|
|
+ โ 3. Draw (if needed) โ
|
|
|
|
|
+ โ โ
|
|
|
|
|
+ โ Returns immediately โ
|
|
|
|
|
+ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+
|
|
|
|
|
+Key Insight:
|
|
|
|
|
+- RunLoop = The LOOP itself (blocking, manages iterations)
|
|
|
|
|
+- RunIteration = ONE iteration (immediate, processes events)
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
-### Proposed (Clear)
|
|
|
|
|
|
|
+## Complete Lifecycle Visualization
|
|
|
|
|
|
|
|
```
|
|
```
|
|
|
-ProcessEvents(session)
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> while (toplevel.Running)
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> ProcessEventsIteration(session) โ
Clear: one iteration of event processing
|
|
|
|
|
- โ โ
|
|
|
|
|
- โ โโ> MainLoop.RunIteration()
|
|
|
|
|
- โ โ โโ> Process driver events
|
|
|
|
|
- โ โ
|
|
|
|
|
- โ โโ> Layout (if needed)
|
|
|
|
|
- โ โโ> Draw (if needed)
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> (repeat)
|
|
|
|
|
|
|
+Application.Run(window)
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ 1. Begin(window) โ RunToken โ
|
|
|
|
|
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
|
|
+โ โ โข Initialize window โ โ
|
|
|
|
|
+โ โ โข Layout views โ โ
|
|
|
|
|
+โ โ โข Draw to screen โ โ
|
|
|
|
|
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ 2. RunLoop(token) โ
|
|
|
|
|
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
|
|
+โ โ Start driver's MainLoop โ โ
|
|
|
|
|
+โ โ โ โ
|
|
|
|
|
+โ โ while (Running) { โ โ
|
|
|
|
|
+โ โ RunIteration(ref token) โ โ
|
|
|
|
|
+โ โ โโ Process events โ โ
|
|
|
|
|
+โ โ โโ Layout (if needed) โ โ
|
|
|
|
|
+โ โ โโ Draw (if needed) โ โ
|
|
|
|
|
+โ โ } โ โ
|
|
|
|
|
+โ โ โ โ
|
|
|
|
|
+โ โ Exits when: โ โ
|
|
|
|
|
+โ โ - RequestStop() called โ โ
|
|
|
|
|
+โ โ - StopAfterFirstIteration=true โ โ
|
|
|
|
|
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ 3. End(token) โ
|
|
|
|
|
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
|
|
+โ โ โข Cleanup window โ โ
|
|
|
|
|
+โ โ โข Dispose token โ โ
|
|
|
|
|
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
## Manual Control Pattern
|
|
## Manual Control Pattern
|
|
|
|
|
|
|
|
-When you need fine-grained control over the event loop:
|
|
|
|
|
-
|
|
|
|
|
-### Current (Confusing)
|
|
|
|
|
|
|
+When you need fine-grained control:
|
|
|
|
|
|
|
|
```
|
|
```
|
|
|
-RunState rs = Begin(toplevel); โ Begin what?
|
|
|
|
|
-EndAfterFirstIteration = true; โ End what?
|
|
|
|
|
-
|
|
|
|
|
-while (!done)
|
|
|
|
|
-{
|
|
|
|
|
- RunIteration(ref rs, first); โ Run what? How does this relate to RunLoop?
|
|
|
|
|
- first = false;
|
|
|
|
|
-
|
|
|
|
|
- // Custom processing
|
|
|
|
|
- DoMyCustomStuff();
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-End(rs); โ End what?
|
|
|
|
|
-```
|
|
|
|
|
-
|
|
|
|
|
-### Proposed (Clear)
|
|
|
|
|
-
|
|
|
|
|
-```
|
|
|
|
|
-ToplevelSession session = BeginSession(toplevel); โ
Clear: starting a session
|
|
|
|
|
-StopAfterFirstIteration = true; โ
Clear: stop after one iteration
|
|
|
|
|
-
|
|
|
|
|
-while (!done)
|
|
|
|
|
-{
|
|
|
|
|
- ProcessEventsIteration(ref session, first); โ
Clear: process one iteration
|
|
|
|
|
- first = false;
|
|
|
|
|
-
|
|
|
|
|
- // Custom processing
|
|
|
|
|
- DoMyCustomStuff();
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-EndSession(session); โ
Clear: ending the session
|
|
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ RunToken token = Begin(window); โ
|
|
|
|
|
+โ StopAfterFirstIteration = true; โ โ
Clear: stop after one iter
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ while (!myCondition) โ
|
|
|
|
|
+โ { โ
|
|
|
|
|
+โ // Process one iteration โ
|
|
|
|
|
+โ RunIteration(ref token, first); โ
|
|
|
|
|
+โ first = false; โ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ // Your custom logic here โ
|
|
|
|
|
+โ DoCustomProcessing(); โ
|
|
|
|
|
+โ } โ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ End(token); โ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+
|
|
|
|
|
+vs Old (Confusing):
|
|
|
|
|
+
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ RunState rs = Begin(window); โ
|
|
|
|
|
+โ EndAfterFirstIteration = true; โ โ Confusing: sounds like End()
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ while (!myCondition) โ
|
|
|
|
|
+โ { โ
|
|
|
|
|
+โ RunIteration(ref rs, first); โ
|
|
|
|
|
+โ first = false; โ
|
|
|
|
|
+โ DoCustomProcessing(); โ
|
|
|
|
|
+โ } โ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ End(rs); โ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
## RequestStop Flow
|
|
## RequestStop Flow
|
|
|
|
|
|
|
|
-### Current
|
|
|
|
|
-
|
|
|
|
|
-```
|
|
|
|
|
-User Action (e.g., Quit Key)
|
|
|
|
|
- โ
|
|
|
|
|
- โผ
|
|
|
|
|
-Application.RequestStop(toplevel)
|
|
|
|
|
- โ
|
|
|
|
|
- โผ
|
|
|
|
|
-Sets toplevel.Running = false
|
|
|
|
|
- โ
|
|
|
|
|
- โผ
|
|
|
|
|
-RunLoop detects !Running
|
|
|
|
|
- โ
|
|
|
|
|
- โผ
|
|
|
|
|
-RunLoop exits
|
|
|
|
|
- โ
|
|
|
|
|
- โผ
|
|
|
|
|
-Application.End() cleans up
|
|
|
|
|
-```
|
|
|
|
|
-
|
|
|
|
|
-### Proposed (Same flow, clearer names)
|
|
|
|
|
-
|
|
|
|
|
```
|
|
```
|
|
|
User Action (e.g., Quit Key)
|
|
User Action (e.g., Quit Key)
|
|
|
- โ
|
|
|
|
|
- โผ
|
|
|
|
|
-Application.StopProcessingEvents(toplevel) โ
Clear: stops event processing
|
|
|
|
|
- โ
|
|
|
|
|
- โผ
|
|
|
|
|
-Sets toplevel.Running = false
|
|
|
|
|
- โ
|
|
|
|
|
- โผ
|
|
|
|
|
-ProcessEvents detects !Running
|
|
|
|
|
- โ
|
|
|
|
|
- โผ
|
|
|
|
|
-ProcessEvents exits
|
|
|
|
|
- โ
|
|
|
|
|
- โผ
|
|
|
|
|
-Application.EndSession() cleans up
|
|
|
|
|
|
|
+ โ
|
|
|
|
|
+ โผ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ RequestStop(window) โ โ
Keep: "Request" is clear
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+ โ
|
|
|
|
|
+ โผ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ window.Running=false โ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+ โ
|
|
|
|
|
+ โผ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ RunLoop exits โ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+ โ
|
|
|
|
|
+ โผ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ End() cleans up โ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
-## Nested Sessions (Modal Dialogs)
|
|
|
|
|
|
|
+## What We're Keeping
|
|
|
|
|
|
|
|
```
|
|
```
|
|
|
-โโโโโโโโโโโโโโโ Main Window Session โโโโโโโโโโโโโโโ
|
|
|
|
|
-โ โ
|
|
|
|
|
-โ session1 = BeginSession(mainWindow) โ
|
|
|
|
|
-โ โ
|
|
|
|
|
-โ ProcessEvents(session1) starts... โ
|
|
|
|
|
-โ โ โ
|
|
|
|
|
-โ โ User clicks "Open Dialog" button โ
|
|
|
|
|
-โ โ โ
|
|
|
|
|
-โ โโ> โโโโโโโโโ Dialog Session โโโโโโโ โ
|
|
|
|
|
-โ โ โ โ โ
|
|
|
|
|
-โ โ โ session2 = BeginSession(dialog) โ
|
|
|
|
|
-โ โ โ โ โ
|
|
|
|
|
-โ โ โ ProcessEvents(session2) โ โ
|
|
|
|
|
-โ โ โ (blocks until dialog closes) โ โ
|
|
|
|
|
-โ โ โ โ โ
|
|
|
|
|
-โ โ โ EndSession(session2) โ โ
|
|
|
|
|
-โ โ โ โ โ
|
|
|
|
|
-โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
|
|
|
-โ โ โ
|
|
|
|
|
-โ โ (returns to main window) โ
|
|
|
|
|
-โ โ โ
|
|
|
|
|
-โ ...ProcessEvents continues โ
|
|
|
|
|
-โ โ
|
|
|
|
|
-โ EndSession(session1) โ
|
|
|
|
|
-โ โ
|
|
|
|
|
-โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
-
|
|
|
|
|
-Key Insight: Sessions can be nested (modal dialogs)
|
|
|
|
|
|
|
+โ
KEEP AS-IS:
|
|
|
|
|
+
|
|
|
|
|
+Begin/End
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ Begin(window) โ ... โ End(token) โ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+ โ โ
|
|
|
|
|
+ โ โ
|
|
|
|
|
+ Clear, concise Clear, concise
|
|
|
|
|
+ Not wordy Not wordy
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+RequestStop
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ RequestStop() โ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+ โ
|
|
|
|
|
+ โ
|
|
|
|
|
+ "Request" appropriately
|
|
|
|
|
+ conveys non-blocking
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+RunLoop / RunIteration
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ RunLoop() โ โ RunIteration() โ
|
|
|
|
|
+โ (the loop) โ โ (one iteration) โ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+ โ โ
|
|
|
|
|
+ โ โ
|
|
|
|
|
+ Distinction is important and valuable
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
-## Complete Example Flow
|
|
|
|
|
-
|
|
|
|
|
-### Simple Application
|
|
|
|
|
|
|
+## Side-by-Side Summary
|
|
|
|
|
|
|
|
```
|
|
```
|
|
|
-START
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> Application.Init() [Application Lifecycle]
|
|
|
|
|
- โ โโ> Initialize driver, screen
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> window = new Window()
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> Application.Run(window) [High-level API]
|
|
|
|
|
- โ โ
|
|
|
|
|
- โ โโ> BeginSession(window) [Session begins]
|
|
|
|
|
- โ โ โโ> Initialize, layout, draw
|
|
|
|
|
- โ โ
|
|
|
|
|
- โ โโ> ProcessEvents(session) [Event processing]
|
|
|
|
|
- โ โ โโ> Loop until stopped
|
|
|
|
|
- โ โ
|
|
|
|
|
- โ โโ> EndSession(session) [Session ends]
|
|
|
|
|
- โ โโ> Cleanup
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> window.Dispose()
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> Application.Shutdown() [Application Lifecycle]
|
|
|
|
|
- โโ> Restore terminal
|
|
|
|
|
-END
|
|
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฆโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ CURRENT โ PROPOSED โ
|
|
|
|
|
+โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
|
|
|
|
|
+โ RunState rs = Begin(window); โ RunToken token = Begin(window); โ
|
|
|
|
|
+โ EndAfterFirstIteration = true; โ StopAfterFirstIteration = true; โ
|
|
|
|
|
+โ RunLoop(rs); โ RunLoop(token); โ
|
|
|
|
|
+โ End(rs); โ End(token); โ
|
|
|
|
|
+โ โ โ
|
|
|
|
|
+โ โ "State" misleading โ โ
"Token" clear โ
|
|
|
|
|
+โ โ "End" confuses with End() โ โ
"Stop" aligns with RequestStopโ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
-### Application with Manual Control
|
|
|
|
|
|
|
+## Terminology Mapping
|
|
|
|
|
|
|
|
```
|
|
```
|
|
|
-START
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> Application.Init()
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> window = new Window()
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> session = Application.BeginSession(window) [Manual Session Control]
|
|
|
|
|
- โ โโ> Initialize, layout, draw
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> Application.StopAfterFirstIteration = true
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> while (!done) [Custom Event Loop]
|
|
|
|
|
- โ โ
|
|
|
|
|
- โ โโ> Application.ProcessEventsIteration(ref session, first)
|
|
|
|
|
- โ โ โโ> Process one iteration
|
|
|
|
|
- โ โ
|
|
|
|
|
- โ โโ> DoCustomProcessing()
|
|
|
|
|
- โ โ
|
|
|
|
|
- โ โโ> first = false
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> Application.EndSession(session) [Manual Session Control]
|
|
|
|
|
- โ โโ> Cleanup
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> window.Dispose()
|
|
|
|
|
- โ
|
|
|
|
|
- โโ> Application.Shutdown()
|
|
|
|
|
-END
|
|
|
|
|
-```
|
|
|
|
|
-
|
|
|
|
|
-## Terminology Mapping Summary
|
|
|
|
|
-
|
|
|
|
|
-### API Name Changes
|
|
|
|
|
-
|
|
|
|
|
-```
|
|
|
|
|
-CURRENT PROPOSED
|
|
|
|
|
-โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
-
|
|
|
|
|
-Application.Run() โ Application.Run() (unchanged)
|
|
|
|
|
-
|
|
|
|
|
-RunState โ ToplevelSession โ
Clear: session token
|
|
|
|
|
-
|
|
|
|
|
-Application.Begin() โ Application.BeginSession() โ
Clear: begin a session
|
|
|
|
|
-
|
|
|
|
|
-Application.RunLoop() โ Application.ProcessEvents() โ
Clear: processes events
|
|
|
|
|
-
|
|
|
|
|
-Application.RunIteration() โ Application.ProcessEventsIteration() โ
Clear: one iteration
|
|
|
|
|
-
|
|
|
|
|
-Application.End() โ Application.EndSession() โ
Clear: end the session
|
|
|
|
|
-
|
|
|
|
|
-Application.RequestStop() โ Application.StopProcessingEvents() โ
Clear: stops processing
|
|
|
|
|
-
|
|
|
|
|
-EndAfterFirstIteration โ StopAfterFirstIteration โ
Consistent naming
|
|
|
|
|
-
|
|
|
|
|
-NotifyNewRunState โ NotifyNewSession โ
Consistent naming
|
|
|
|
|
-
|
|
|
|
|
-NotifyStopRunState โ NotifyStopSession โ
Consistent naming
|
|
|
|
|
-
|
|
|
|
|
-RunStateEventArgs โ ToplevelSessionEventArgs โ
Consistent naming
|
|
|
|
|
|
|
+CHANGE (2 names):
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+RunState โ RunToken
|
|
|
|
|
+EndAfterFirstIteration โ StopAfterFirstIteration
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+KEEP UNCHANGED:
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+Begin โ Begin โ
|
|
|
|
|
+End โ End โ
|
|
|
|
|
+RequestStop โ RequestStop โ
|
|
|
|
|
+RunLoop โ RunLoop โ
|
|
|
|
|
+RunIteration โ RunIteration โ
|
|
|
|
|
+Run โ Run โ
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
## Benefits Visualized
|
|
## Benefits Visualized
|
|
|
|
|
|
|
|
-### Before: Confusion
|
|
|
|
|
-
|
|
|
|
|
```
|
|
```
|
|
|
-User thinks:
|
|
|
|
|
-"What's the difference between Run, RunLoop, and RunIteration?"
|
|
|
|
|
-"Is RunState storing state or just a handle?"
|
|
|
|
|
-"What am I Beginning and Ending?"
|
|
|
|
|
-
|
|
|
|
|
- โโโโโโโโโโโโโโโ
|
|
|
|
|
- โ Run() โ โ What does "Run" mean exactly?
|
|
|
|
|
- โโโโโโโโโโโโโโโ
|
|
|
|
|
- โ
|
|
|
|
|
- โโโโโโโโโโโโโโโ
|
|
|
|
|
- โ Begin() โ โ Begin what?
|
|
|
|
|
- โโโโโโโโโโโโโโโ
|
|
|
|
|
- โ
|
|
|
|
|
- โโโโโโโโโโโโโโโ
|
|
|
|
|
- โ RunLoop() โ โ Is this the same as Run?
|
|
|
|
|
- โโโโโโโโโโโโโโโ
|
|
|
|
|
- โ
|
|
|
|
|
- โโโโโโโโโโโโโโโ
|
|
|
|
|
- โ End() โ โ End what?
|
|
|
|
|
- โโโโโโโโโโโโโโโ
|
|
|
|
|
-
|
|
|
|
|
-Result: User confusion, slower learning curve
|
|
|
|
|
|
|
+Before:
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ Users think: โ
|
|
|
|
|
+โ โข "What state does RunState hold?" โ
|
|
|
|
|
+โ โข "Does EndAfterFirstIteration call โ
|
|
|
|
|
+โ End()?" โ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ Result: Confusion, questions โ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+
|
|
|
|
|
+After:
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
+โ Users understand: โ
|
|
|
|
|
+โ โข "RunToken is a token" โ
|
|
|
|
|
+โ โข "StopAfterFirstIteration controls โ
|
|
|
|
|
+โ the loop" โ
|
|
|
|
|
+โ โ
|
|
|
|
|
+โ Result: Clear, self-documenting โ
|
|
|
|
|
+โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
-### After: Clarity
|
|
|
|
|
|
|
+## Summary
|
|
|
|
|
|
|
|
-```
|
|
|
|
|
-User understands:
|
|
|
|
|
-"Run() does the complete lifecycle"
|
|
|
|
|
-"BeginSession/EndSession manage a session"
|
|
|
|
|
-"ProcessEvents processes events until stopped"
|
|
|
|
|
-"ToplevelSession is a token for the session"
|
|
|
|
|
-
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ Run() โ โ
Complete lifecycle
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ BeginSession() โ โ
Start a session
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ ProcessEvents() โ โ
Process events
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
- โ EndSession() โ โ
End the session
|
|
|
|
|
- โโโโโโโโโโโโโโโโโโโ
|
|
|
|
|
-
|
|
|
|
|
-Result: Clear understanding, faster learning curve
|
|
|
|
|
-```
|
|
|
|
|
|
|
+**2 Changes Only:**
|
|
|
|
|
+- `RunState` โ `RunToken` (clear it's a token)
|
|
|
|
|
+- `EndAfterFirstIteration` โ `StopAfterFirstIteration` (clear it controls loop)
|
|
|
|
|
+
|
|
|
|
|
+**Everything Else Stays:**
|
|
|
|
|
+- `Begin` / `End` - Clear and concise
|
|
|
|
|
+- `RequestStop` - Appropriately non-blocking
|
|
|
|
|
+- `RunLoop` / `RunIteration` - Valuable distinction
|
|
|
|
|
|
|
|
-## See Also
|
|
|
|
|
|
|
+**Result:**
|
|
|
|
|
+- โ
Addresses confusion at the source
|
|
|
|
|
+- โ
Minimal disruption (2 names)
|
|
|
|
|
+- โ
Preserves what works well
|
|
|
|
|
+- โ
Respects maintainer feedback
|
|
|
|
|
|
|
|
-- [TERMINOLOGY_PROPOSAL.md](TERMINOLOGY_PROPOSAL.md) - Full proposal with rationale
|
|
|
|
|
-- [TERMINOLOGY_QUICK_REFERENCE.md](TERMINOLOGY_QUICK_REFERENCE.md) - Quick comparison tables
|
|
|
|
|
-- [TERMINOLOGY_INDUSTRY_COMPARISON.md](TERMINOLOGY_INDUSTRY_COMPARISON.md) - Industry patterns
|
|
|
|
|
|
|
+See [TERMINOLOGY_PROPOSAL.md](TERMINOLOGY_PROPOSAL.md) for complete analysis.
|