PhraseEditorUI // Make the line height static.
This commit is contained in:
parent
d4f6bc4d11
commit
495270c4da
|
@ -130,11 +130,8 @@ public struct TextEditorEX: NSViewRepresentable {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate lazy var textStorage = NSTextStorage()
|
|
||||||
fileprivate lazy var layoutManager = NSLayoutManager()
|
|
||||||
fileprivate lazy var textContainer = NSTextContainer()
|
|
||||||
fileprivate lazy var textView: NSTextView = {
|
fileprivate lazy var textView: NSTextView = {
|
||||||
let result = NSTextView(frame: CGRect(), textContainer: textContainer)
|
let result = NSTextView(frame: CGRect())
|
||||||
result.font = NSFont.systemFont(ofSize: 13, weight: .regular)
|
result.font = NSFont.systemFont(ofSize: 13, weight: .regular)
|
||||||
result.allowsUndo = true
|
result.allowsUndo = true
|
||||||
return result
|
return result
|
||||||
|
@ -145,8 +142,10 @@ public struct TextEditorEX: NSViewRepresentable {
|
||||||
public func createTextViewStack() -> NSScrollView {
|
public func createTextViewStack() -> NSScrollView {
|
||||||
let contentSize = scrollview.contentSize
|
let contentSize = scrollview.contentSize
|
||||||
|
|
||||||
textContainer.containerSize = CGSize(width: contentSize.width, height: CGFloat.greatestFiniteMagnitude)
|
if let n = textView.textContainer {
|
||||||
textContainer.widthTracksTextView = true
|
n.containerSize = CGSize(width: contentSize.width, height: CGFloat.greatestFiniteMagnitude)
|
||||||
|
n.widthTracksTextView = true
|
||||||
|
}
|
||||||
|
|
||||||
textView.minSize = CGSize(width: 0, height: 0)
|
textView.minSize = CGSize(width: 0, height: 0)
|
||||||
textView.maxSize = CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude)
|
textView.maxSize = CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude)
|
||||||
|
@ -159,9 +158,6 @@ public struct TextEditorEX: NSViewRepresentable {
|
||||||
scrollview.hasVerticalScroller = true
|
scrollview.hasVerticalScroller = true
|
||||||
scrollview.documentView = textView
|
scrollview.documentView = textView
|
||||||
|
|
||||||
textStorage.addLayoutManager(layoutManager)
|
|
||||||
layoutManager.addTextContainer(textContainer)
|
|
||||||
|
|
||||||
return scrollview
|
return scrollview
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue