Skip to content

Instantly share code, notes, and snippets.

View jhoughjr's full-sized avatar
🎯
Focusing

Jimmy Hough Jr. jhoughjr

🎯
Focusing
View GitHub Profile
//: Playground - noun: a place where people can play
var num = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15].map { (i) -> String in
let fizz = (i % 3) == 0
let buzz = (i % 5) == 0
let fizzBuzz = fizz && buzz
let char = String("\(i)")
if fizzBuzz { return "FizzBuzz" } else
func collapseToHeight(height:CGFloat) {
if attached {
return
}
isCollapsed = true
var newFrame = frame
newFrame.size.height = height
newFrame.origin.y += (frame.height - height)
XCGLogger.error(newFrame.origin)
extension NSFont {
func isBold() -> Bool {
return NSFontManager.sharedFontManager().traitsOfFont(self).contains(.BoldFontMask)
}
func isItalic() -> Bool {
return NSFontManager.sharedFontManager().traitsOfFont(self).contains(.ItalicFontMask)
}
func toggleTaskListOverRange(range:NSRange) {
((textView?.textStorage?.string)! as NSString).enumerateSubstringsInRange(range, options:.ByLines) { (line, lineRange, rangeWithTerminators, nil) in
if let attributedLine = (self.textView?.textStorage?.attributedSubstringFromRange(rangeWithTerminators)) {
if attributedLine.rangeOfCheckedBox().location != NSNotFound {
func toggleTaskListOverRange(range:NSRange) {
((textView?.textStorage?.string)! as NSString).enumerateSubstringsInRange(range, options: .ByLines) { (line, lineRange, rangeWithTerminators, nil) in
if (self.textView?.textStorage?.attributedSubstringFromRange(lineRange)) != nil {
}
}
}
var doc:Document? {
didSet {
if let myDoc = doc {
textField?.lineBreakMode = .ByTruncatingMiddle
textField?.stringValue = myDoc.note.docID
toolTip = myDoc.note.docID
let appIcon = AppIconProvider.iconImagefor(myDoc.note.appBundleID)
let genericAppIconTiff = NSWorkspace.sharedWorkspace().iconForFileType(NSFileTypeForHFSTypeCode(OSType(kGenericApplicationIcon))).TIFFRepresentation
import Foundation
import Cocoa
protocol SplitViewCollapseable: NSSplitViewDelegate {
var splitView:CustomSplitView? { get set}
var masterListExpandedWidth:CGFloat? { get set}
var masterListCollapsedWidth:CGFloat? { get set }
func collapseMasterList()
func handleTaskAdded(notif:NSNotification) {
tasksTableView?.reloadData()
if let tableView = tasksTableView, addedTask = notif.object as? Task {
tableView.enumerateAvailableRowViewsUsingBlock({ (rowView, row) in
print("enumerated \(row)")
if row != 0 {
if let cell = rowView.viewAtColumn(0) as? TaskCell {
if let cellTask = cell.task?.id {
func tableView(tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
if row == 0 {
return 36.0
}
return 53.0
}
func tableView(tableView: NSTableView, didAddRowView rowView: NSTableRowView, forRow row: Int) {
func tableViewSelectionDidChange(notification: NSNotification) {
let tv = notification.object as! NSTableView
let view = tv.viewAtColumn(0, row: tv.selectedRow, makeIfNecessary: false) as? TaskListCell
let rowView = view?.superview as? NSTableRowView
if rowView?.selected == true {
view?.textField?.textColor = NSColor.blueColor()