You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Description
Introduces an API to override how text is laid out by the layout manager. An API consumer can implement an object conforming to the `TextLayoutManagerRenderDelegate` protocol to provide custom behavior.
Introduces tests for new APIs.
Specific changes:
- Created a new `TextLayoutManagerRenderDelegate` which contains optional methods to override layout behavior. All methods are optional, and default to the default implementation.
- Updates the layout manager to use these methods where relevant.
- Estimated height, line height.
- Finding `x` position in a line fragment.
- Creating a view to render a line fragment (`LineFragmentView` by default, but the render delegate can give a custom one).
- Makes lots of variables and methods public that weren't previously. Since we're allowing using the layout manager outside the context of a text view, these are necessarily public.
- `LineFragmentView` is now an `open` class to allow for overriding methods.
- Two methods on `LineFragment` have been marked as depreciated (`xPos` and `rectFor`). These were moved to the `TextLayoutManger` to ensure that the new render delegate can inject it's own behavior for both those methods if available.
- `TextSelectionManager`
- `draw` method is now public, for drawing selections in a custom context.
- Updates some methods that were calculating drawing rects to use the layout manager information, rather than text view information. This allows the selection manager's behavior to reflect overridden layout manager behavior.
- Documented exactly what `layoutLines` does in `TextLayoutManager`.
- Removed two misleading methods. `ensureLayoutUntil` was used once, and it was not being used correctly. `preparePositionForDisplay` was only used by that method. Both of these methods destroyed layout information without recourse, sometimes causing text to just disappear despite a perfectly valid layout pass.
- `ensureLayoutUntil` could be added back, but needs to be implemented in a way that's additive, rather than removing layout information.
- Removing these changes didn't effect the ability to jump to scroll positions, or emphasize text ranges.
### Related Issues
* CodeEditApp/CodeEditSourceEditor#33
### Checklist
- [x] I read and understood the [contributing guide](https://github.com/CodeEditApp/CodeEdit/blob/main/CONTRIBUTING.md) as well as the [code of conduct](https://github.com/CodeEditApp/CodeEdit/blob/main/CODE_OF_CONDUCT.md)
- [x] The issues this PR addresses are related to each other
- [x] My changes generate no new warnings
- [x] My code builds and runs on my machine
- [x] My changes are all related to the related issue above
- [x] I documented my code
### Screenshots
0 commit comments