-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add STTextFinderBarContainer to handle text finder bar
Move responsibility for managing the text finder bar from STTextView to a new STTextFinderBarContainer class that implements NSTextFinderBarContainer. This allows properly positioning the gutter view below the find bar when it is shown/hidden. Update STTextView to: - Create the text finder client, bar container and finder in init - Connect the text finder client and bar container - Remove code to set up the text finder when moving to a window - Scope some enclosing scroll view accesses
- Loading branch information
1 parent
00a4241
commit 828dd6f
Showing
3 changed files
with
61 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import AppKit | ||
|
||
final class STTextFinderBarContainer: NSObject, NSTextFinderBarContainer { | ||
|
||
// Forward NSTextFinderBarContainer to enclosing NSScrollView (for now at least) | ||
weak var client: STTextView? | ||
|
||
var findBarView: NSView? { | ||
get { | ||
client?.scrollView?.findBarView | ||
} | ||
|
||
set { | ||
client?.scrollView?.findBarView = newValue | ||
|
||
// Rearrange gutter view position in NSScrollView hierarchy | ||
Task { @MainActor in | ||
if let scrollView = client?.scrollView, let gutterView = client?.gutterView { | ||
gutterView.removeFromSuperviewWithoutNeedingDisplay() | ||
scrollView.addSubview(gutterView, positioned: .below, relativeTo: scrollView.findBarView) | ||
} | ||
} | ||
} | ||
} | ||
|
||
var isFindBarVisible: Bool { | ||
get { | ||
client?.scrollView?.isFindBarVisible ?? false | ||
} | ||
|
||
set { | ||
client?.scrollView?.isFindBarVisible = newValue | ||
} | ||
} | ||
|
||
func contentView() -> NSView? { | ||
client?.contentView | ||
} | ||
|
||
func findBarViewDidChangeHeight() { | ||
client?.scrollView?.findBarViewDidChangeHeight() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters