Skip to content

Commit

Permalink
Merge pull request #395 from Desbeers/dev
Browse files Browse the repository at this point in the history
SwiftUI wrapper: smoother browsing of ‘versions’.
  • Loading branch information
sciurius committed Jul 20, 2024
2 parents 6d492b9 + dc87c7b commit 98dc33a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ public extension ChordProEditor {
do {
try await Task.sleep(nanoseconds: 1_000_000_000)
parent.text = textView.string
/// Remove the task so we allow external updates of the text binding again
self.task = nil
} catch { }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extension ChordProEditor {
/// The font style of the editor
public var fontStyle: FontStyle = .monospaced

/// The calculated font for the editor
public var font: NSFont {
return fontStyle.nsFont(size: fontSize)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,7 @@ extension ChordProEditor {
}()

/// The `NSRulerView`
//lazy private var lineNumbers = NSRulerView()
lazy var lineNumbers: LineNumbersView = {
let lineNumbersView = LineNumbersView()
return lineNumbersView
}()
lazy private var lineNumbers = LineNumbersView()

public override func viewWillDraw() {
super.viewWillDraw()
Expand All @@ -106,7 +102,7 @@ extension ChordProEditor {
lineNumbers.scrollView = scrollView
lineNumbers.orientation = .verticalRuler
lineNumbers.clientView = textView
lineNumbers.ruleThickness = 40
lineNumbers.ruleThickness = (textView.font?.pointSize ?? 14) * 4

scrollView.verticalRulerView = lineNumbers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public struct ChordProEditor: NSViewRepresentable {
wrapper.delegate = context.coordinator
wrapper.textView.directives = directives
wrapper.textView.parent = self
wrapper.textView.font = settings.font
wrapper.textView.string = text
/// Wait for next cycle and set the textview as first responder
Task { @MainActor in
Expand Down

0 comments on commit 98dc33a

Please sign in to comment.