Skip to content

Move inspector and canvas text logic into VisuStructCore - #12

Merged
code4teaching merged 36 commits into
xcode-synced-foldersfrom
core-text-logic
Oct 19, 2026
Merged

code4teaching merged 36 commits into
xcode-synced-foldersfrom
core-text-logic

Conversation

@code4teaching

Copy link
Copy Markdown
Owner

Requested by Holger · project thread

Before: the string handling behind the inspector's line editor (input:/output: prefixes, keyword stripping while typing, typographic quotes, for-loop fields) and the canvas display text (added if/while/switch, until → while, bold keyword split) lived as private functions in ContentView and DiagramCanvasView, untested.

After: the same logic lives in VisuStructCore as VisuStructLineEditorText and VisuStructDiagramText, with tests. The views call it. No behavior change. ContentView loses ~140 lines, DiagramCanvasView ~70. Two helpers that had no callers (stripLineEditorPrefix, stripKeywordPrefix) are removed. StatementIOMode is now a typealias for the core enum.

How: functions moved verbatim (renamed to Swift API style), placeholder texts for empty tiles stay in the canvas because they are localized. Step 2 of the refactoring plan; stacked on the synchronized-folder PR.


Generated by Claude Code

IO-prefix handling, keyword stripping for the line editor, quote
normalization and for-loop field handling move from ContentView into
VisuStructLineEditorText; the canvas display text (added keywords,
until -> while, keyword split) moves into VisuStructDiagramText. Both
are now covered by swift test. Removes two unused helpers
(stripLineEditorPrefix, stripKeywordPrefix). No behavior change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
@code4teaching code4teaching self-assigned this Oct 18, 2026
@code4teaching
code4teaching marked this pull request as ready for review October 18, 2026 22:17
- VisuStructCore: VisuStructEditHistory (undo/redo stacks, 80-step limit)
  and VisuStructDocumentEditing.sanitizedSelection, with tests.
- DiagramSheetTab keeps a VisuStructEditHistory instead of two arrays.
- DiagramSheetTabsModel+Editing: currentTab, updateCurrentTab,
  commitDocument, resetHistoryAndDocument, undo, redo,
  selectAndClearError, setErrorOnCurrentTab.
- ContentView uses these instead of copying tabs by hand at each site.

No behavior change intended.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
claude added 24 commits October 18, 2026 22:22
The engine, play/pause task, input text and the simulation mode flag
move from ContentView @State into an @observable SimulationController.
The step delay and highlight mode are read from UserDefaults at each
step, as the @AppStorage values were before.

No behavior change intended.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
- Palette/PaletteActionList.swift: palette rows, drag preview and the
  action buttons below; actions come in as closures.
- Simulation/SimulationDetailView.swift: canvas plus state panel layout
  for simulation mode, driven by SimulationController.
- ContentView keeps the action logic (toggleSimulationMode,
  openCodeGenerator) and the simulation canvas.

No behavior change intended.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
- VisuStructCore: VisuStructDocumentEditing.multiwayAncestorPath and
  caseIndex(of:inMultiwayAt:), with tests.
- Inspector/InspectorElementHints.swift: line editor placeholder and
  condition hint line per element type.
- Remove the unused statementIOModeIfApplicable().

No behavior change intended.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
The four export actions in ContentView each rendered the diagram and
mapped errors themselves. Export/DiagramExporter.swift now does that;
ContentView only stores the share payloads it returns.

No behavior change intended.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
- DiagramCanvasView.swift: inputs, state, layout and body, clipboard.
- DiagramCanvasDropZones.swift: drop bands, tap insert targets and
  applying drops.
- DiagramCanvasRenderer.swift: Canvas drawing of cells, lines and text.

The two new files are extensions of DiagramCanvasView, so members they
share lose their `private`. Code is moved unchanged otherwise.

No behavior change intended.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
Carries the portrait simulation layout from main into
SimulationDetailView.swift.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
Carries the VoiceOver block labels from main into
DiagramCanvasDropZones.swift.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
claude and others added 9 commits October 19, 2026 07:30
# Conflicts:
#	VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/ContentView.swift
Split DiagramCanvasView into view, drop zones and renderer
Bundle PNG, file, PDF and print export in DiagramExporter
Move inspector hints and Fallauswahl path helpers out of ContentView
Extract PaletteActionList and SimulationDetailView from ContentView
Move simulation state and controls into SimulationController
Move undo/redo and tab editing out of ContentView
@code4teaching
code4teaching merged commit bd9510d into xcode-synced-folders Oct 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants