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
// https://stackoverflow.com/a/32671117/310159 | |
/// Abstract custom text storage | |
class CustomTextStorage: NSTextStorage | |
{ | |
var contents: NSMutableAttributedString | |
override var string: String { return contents.string } | |
override init(attributedString attrStr: NSAttributedString) |
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
import Foundation | |
protocol IntAndString: RawRepresentable where RawValue == (Int, String) | |
{ | |
static var invalidInt: Int { get } | |
static var invalidString: String { get } | |
} | |
extension IntAndString | |
{ |
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
import Foundation | |
extension XTRepository | |
{ | |
/// Branches is a sequence, not a collection, because the API does not provide | |
/// a count or indexed access. | |
public struct BranchSequence<BranchType: Branch>: Sequence | |
{ | |
public typealias Element = BranchType | |
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
import Cocoa | |
class AppDelegate: NSObject, NSApplicationDelegate { | |
let viewController = ViewController() | |
let window = NSWindow(contentRect: NSMakeRect(0, 0, NSScreen.main()!.frame.size.width, NSScreen.main()!.frame.size.height), styleMask: [.titled, .closable, .miniaturizable, .resizable], backing: NSBackingStoreType.buffered, defer: false) | |
func applicationDidFinishLaunching(_ aNotification: Notification) { | |
viewController.view = NSView(frame: NSMakeRect(0, 0, window.frame.size.width, window.frame.size.height)) | |
viewController.view.wantsLayer = true |
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
- (NSImage *)tintedImageWithColor:(NSColor *)tint | |
{ | |
NSSize size = [self size]; | |
NSRect imageBounds = NSMakeRect(0, 0, size.width, size.height); | |
NSImage *copiedImage = [self copy]; | |
[copiedImage lockFocus]; | |
[tint set]; |
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
static char *alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
@implementation Base64 | |
+ (NSString*) | |
encode:(NSData*)plainText | |
{ | |
int encodedLength = (((([plainText length] % 3) + [plainText length]) / 3) * 4) + 1; | |
unsigned char *outputBuffer = malloc(encodedLength); | |
unsigned char *inputBuffer = (unsigned char*)[plainText bytes]; |
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
# Uncrustify 0.58 | |
# | |
# General options | |
# | |
# The type of line endings | |
newlines = auto # auto/lf/crlf/cr | |
# The original size of tabs in the input |
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
NSArray *cursorNames = [NSArray arrayWithObjects: | |
@"arrowCursor", | |
@"IBeamCursor", | |
@"pointingHandCursor", | |
@"closedHandCursor", | |
@"openHandCursor", | |
@"resizeLeftCursor", | |
@"resizeRightCursor", | |
@"resizeLeftRightCursor", | |
@"resizeUpCursor", |