-
Notifications
You must be signed in to change notification settings - Fork 92
Minimap #302
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
base: main
Are you sure you want to change the base?
Minimap #302
Conversation
This is nearly ready, I've discovered some odd behavior when using the minimap in CodeEdit. I'm going to mark this as a draft again until I can resolve those. |
Looks amazing! Can you also provide a screen recording of scrolling through a long file? Also, does the position update when opening the find panel? |
Yes and yes! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, very impressive! I can see a lot of consideration went into this. Great work!
There are just a few minor issues I have noted.
@@ -9,15 +9,6 @@ | |||
"version" : "0.1.20" | |||
} | |||
}, | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this removed? I think this is also causing tests to fail.
cursorPositions: $cursorPositions, | ||
useThemeBackground: true, | ||
highlightProviders: [treeSitterClient], | ||
contentInsets: NSEdgeInsets(top: proxy.safeAreaInsets.top, left: 0, bottom: 28.0, right: 0), | ||
useSystemCursor: useSystemCursor | ||
additionalTextInsets: NSEdgeInsets(top: 1, left: 0, bottom: 1, right: 0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why just 1pt on the top and bottom?
@@ -0,0 +1,119 @@ | |||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am glad to see this being separated out. I was going to do this but didn't get around to it. I might however call this StatusBar.swift since it exists at the bottom. It does contain configuration, but mostly line number and language being used.
@@ -9,15 +9,6 @@ | |||
"version" : "0.1.20" | |||
} | |||
}, | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I don't think this should have been removed.
@@ -16,8 +16,9 @@ let package = Package( | |||
dependencies: [ | |||
// A fast, efficient, text view for code. | |||
.package( | |||
url: "https://github.com/CodeEditApp/CodeEditTextView.git", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh I see, looks like you accidentally committed dev code.
@@ -10,13 +10,11 @@ import CodeEditTextView | |||
|
|||
extension TextViewController: FindPanelTarget { | |||
func findPanelWillShow(panelHeight: CGFloat) { | |||
scrollView.contentInsets.top += panelHeight |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool!
minimapView = MinimapView(textView: textView, theme: theme) | ||
minimapView.postsFrameChangedNotifications = true | ||
minimapView.isHidden = !showMinimap | ||
scrollView.addFloatingSubview(minimapView, for: .vertical) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we follow the convention of setUpHighlighter()
and setUpTextFormation()
and break this into a setUpMinimap()
function? We might do this same with the findPanel with setUpFindPanel()
. Idk if it is that cut and dry though.
Description
Note
Requires CodeEditApp/CodeEditTextView#84 to work.
Adds a minimap to the editor.
Specific changes:
MinimapView
. This view acts as the container view for the entire minimap contents including the separator, text bubbles, and scroll view.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 viewMinimapLineFragmentView
.MinimapLineFragmentView
is a subclass ofLineFragmentView
that calculates and draws bubbles instead of text based on the foreground color of the line fragment it displays.showMinimap
parameter toTextViewController
andCodeEditSourceEditor
types.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:
Related Issues
Checklist
Screenshots
Demo resizing & toggling minimap with selections being drawn and responding to scrolling.
Screen.Recording.2025-04-17.at.10.19.14.AM.mov
Demo scrolling a long document
minimap-long-demo.mp4
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.
minimap-editing-demo.mp4