Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Example/Highlightr/SampleCode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SampleCode: UIViewController
let layoutManager = NSLayoutManager()
textStorage.addLayoutManager(layoutManager)

let textContainer = NSTextContainer(size: view.bounds.size)
let textContainer = NSTextContainer()
layoutManager.addTextContainer(textContainer)

textView = UITextView(frame: viewPlaceholder.bounds, textContainer: textContainer)
Expand Down
30 changes: 23 additions & 7 deletions Example/Highlightr_OSX_Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import Highlightr
class AppDelegate: NSObject, NSApplicationDelegate {

@IBOutlet weak var window: NSWindow!


var scrollview : NSScrollView!
var textView : NSTextView!
let textStorage = CodeAttributedString()

Expand All @@ -30,16 +31,31 @@ class AppDelegate: NSObject, NSApplicationDelegate {
let layoutManager = NSLayoutManager()
textStorage.addLayoutManager(layoutManager)

let textContainer = NSTextContainer(size:(window.contentView?.bounds.size)!)
let textContainer = NSTextContainer()
layoutManager.addTextContainer(textContainer)



// Setting Up the Scroll View
scrollview = NSScrollView(frame: (window.contentView?.bounds)!)
scrollview.borderType = .noBorder
scrollview.hasVerticalScroller = true
scrollview.hasHorizontalScroller = false
scrollview.autoresizingMask = [.width,.height]

let contentSize = scrollview.contentSize

textView = NSTextView(frame: (window.contentView?.bounds)!, textContainer: textContainer)
textView.autoresizingMask = [.width,.height]
textView.translatesAutoresizingMaskIntoConstraints = true
textView.minSize = NSMakeSize(0.0, contentSize.height)
textView.maxSize = NSMakeSize(CGFloat.greatestFiniteMagnitude, CGFloat.greatestFiniteMagnitude)
textView.isVerticallyResizable = true
textView.isHorizontallyResizable = false
textView.autoresizingMask = [.width]
textView.textContainer!.containerSize = NSMakeSize(contentSize.width, CGFloat.greatestFiniteMagnitude)
textView.textContainer!.widthTracksTextView = true
textView.backgroundColor = (textStorage.highlightr.theme.themeBackgroundColor)!
textView.insertionPointColor = NSColor.white
window.contentView?.addSubview(textView)

scrollview.documentView = textView;
window.contentView?.addSubview(scrollview)

}

Expand Down