Skip to content

Expand Two-Way Editor State Bindings #337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

thecoolwinter
Copy link
Collaborator

@thecoolwinter thecoolwinter commented Jun 19, 2025

Description

Right now, the SwiftUI API exposes one two-way binding for the editor's state: the current cursor positions. This change aims to expand the available bindings to allow developers to further control and customize the user experience.

Detailed Changes

  • Adds new SourceEditorState struct, that organizes the bindings we publish into one place.
    • New Binding: scrollPosition - matches the scroll view's scroll origin.
    • New Binding: findText - matches the find panel text.
    • New Binding: replaceText - matches the find panel replace text.
    • New Binding: findPanelVisible - matches the visibility of the find panel.
  • Adds new notifications to the find model and find controller, published when the find panel's text changes and when visibility is toggled.
  • Adds a new notification to the text view controller that publishes whenever the scroll view changes.
  • Updates the SourceEditor.Coordinator to receive the new notifications and update the state struct.
  • Updates SourceEditor to update the editor's state when receiving an updated state struct.
  • Updated README and related documentation to include usage examples.

Related Issues

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

From the updated demo app, with interactive visuals for each new two-way binding.

Screen.Recording.2025-06-19.at.3.14.45.PM.mov

@thecoolwinter thecoolwinter marked this pull request as draft June 19, 2025 21:32
@thecoolwinter thecoolwinter marked this pull request as ready for review June 23, 2025 15:55
@thecoolwinter thecoolwinter merged commit da5168b into CodeEditApp:main Jun 24, 2025
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.

3 participants