-
Notifications
You must be signed in to change notification settings - Fork 93
✨ Minimap #33
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
Comments
This is do able just not sure where to do it or where to add it in the codebase |
Actually I'd prefer the minimap like Xcode rather than VScode. The minimap of Xcode contains more useful features and looks cleaner and much more beautiful. It will definitely take more work to make one like that, but I believe you'll love it too. |
@Yellow-GGG I agree the Xcode minimap is far more useful; however at the same time I think it may be wiser to ship a minimap with minimal functionality and then add complexity in future releases. |
@tjkohli I completely agree. We need to get something in place first, then we can iterate and improve. |
Hey @austincondiff, could you assign this to me? I already got some of the CodeEditorView code working: |
This is the current state of the minimap. Still a lot of bugs to fix, but I am getting there slowly... Screen.Recording.2023-04-11.at.13.17.24.mov@thecoolwinter I need to set the bounds of the visibleRange in |
Looks great! Where are we with this? |
Unfortunately, I have had little time recently, since I am currently working on my degree. I have decided that I am going re-implement the minimap in textkit2, instead of textkit1, since the resizing was very laggy. I have also encountered multiple issues like #184, which need to be resolved first, so that the minimap can work properly. |
@Eliulm are you willing to finish this? If not can you provide the code so we can pick up where you left off? Edit: I just realized this was done back when we were using STTextView. We are using our own text view. I'd still be interested in seeing what you have though if you still have it. |
I'm going to be taking this on, here's my basic plan (I'll be going a similar direction to CodeEditorView like mentioned above): The minimap is basically another TextView, except it lays out and renders it's lines using small dots. Because the layout manager is related to the text storage now, we can have the minimap and textview share a storage, but each have their own layout information. The outline of required changes:
|
### 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
### Description Adds a minimap to the editor. Specific changes: - Created a new `MinimapView`. This view acts as the container view for the entire minimap contents including the separator, text bubbles, and scroll view. - New classes for the minimap: - `MinimapContentView` Displays the real contents of the minimap. The layout manager and selection manager place views and draw into this view. - `MinimapLineRenderer` uses the new layout overriding APIs to render small bubbles rather than text for the minimap. This delegates all bubble calculation and drawing to a custom view `MinimapLineFragmentView`. - `MinimapLineFragmentView` is a subclass of `LineFragmentView` that calculates and draws bubbles instead of text based on the foreground color of the line fragment it displays. - Added a new `showMinimap` parameter to `TextViewController` and `CodeEditSourceEditor` types. - Moved all content inset calculation to two methods. - `updateContentInsets` updates all relevant content insets for the scroll view, find panel, and minimap in one central place. This method is deterministic and builds on work @austincondiff and I discussed. - `updateTextInsets` updates the text view's insets. Example app: - Added minimap toggle - Moved toggles and settings to it's own view, it was getting large. ### Related Issues * #33 ### Checklist - [x] Render minimap. - [x] Make minimap scrollable. - [x] Add 'visible pane' to minimap. - [x] Add selections to minimap. - [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 Demo resizing & toggling minimap with selections being drawn and responding to scrolling. https://github.com/user-attachments/assets/038187d0-df01-4d19-b51c-ce160a891607 Demo scrolling a long document https://github.com/user-attachments/assets/65a98f74-d201-443e-8f0a-3ee81361f54d Demo editing text, with selections, dragging, and syntax highlighting. Note that syntax highlights haven't been updated to highlight the *entire* minimap visible region. That will be done, but adding to this PR I think will complicate this PR too much. https://github.com/user-attachments/assets/6188d560-ffc5-4cef-b6b8-e3c711e8ca27
### Description The highlighter should now highlight all ‘visible’ text, including text that is visible in the minimap but not in the TextView. This PR merges the visible text in the minimap with the visible text in the TextView to highlight both. If the minimap is hidden, the highlighter will behave as before and only highlight the text visible in the TextView. ### Related Issues * #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 https://github.com/user-attachments/assets/4bb7ead0-947d-41bc-96c1-7c7c4df3ad8b
### Description Adds a minimap to CodeEdit's editor, as well as a new trailing editor accessory (that only appears when the selected document is a code document), a command to toggle the minimap, and a setting to toggle the minimap. ### 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 https://github.com/user-attachments/assets/07f21d48-23cf-42dc-b39a-02ba395956cb
Description
The Minimap provides a compact visual summary of your code, helping you quickly get a sense of the file’s structure and flow. It appears along the right edge of the editor and lets you instantly jump to different parts of the file by clicking or dragging within the highlighted view area.
Implement the visual display system for the Minimap in the source editor. The Minimap should provide a vertically compressed, non-interactive rendering of the entire file's syntax structure. It visually represents the document using color rectangles, offering users an overview for orientation and navigation.
Requirements
Display a vertical Minimap next to the code editor view
The Minimap should:
Scrolling and navigation:
Selection handling:
Integration with editor features:
Behavior and customization:
Implementation Details
Additional Context
This feature provides users with a consistent and performant way to understand the overall structure of their code. It is especially helpful in long files and serves as a complement to navigation and issue reporting systems in the editor.
This lays the foundation for future enhancements such as semantic structure previews, bookmarks, and inline annotations inside the Minimap.
Screenshots
Resources
Related Issues
The text was updated successfully, but these errors were encountered: