Skip to content

Instantly share code, notes, and snippets.

@BekaValentine
Created September 23, 2013 04:20
Show Gist options
  • Save BekaValentine/6666438 to your computer and use it in GitHub Desktop.
Save BekaValentine/6666438 to your computer and use it in GitHub Desktop.
- (void)newDocument:(id)sender {
NSLog(@"creating document");
NSWindow* newWindow = [[NSWindow alloc]
initWithContentRect: NSMakeRect(100,100,500,500)
styleMask: NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask
backing: NSBackingStoreBuffered
defer: NO];
[[newWindow contentView] setAutoresizesSubviews: YES];
NSTextView* codeView = [[NSTextView alloc] initWithFrame: NSMakeRect(0,0,400,400)];
[[codeView textContainer] setContainerSize: NSMakeSize(FLT_MAX, FLT_MAX)];
[[codeView textContainer] setWidthTracksTextView: NO];
[[codeView textContainer] setHeightTracksTextView: NO];
[codeView setHorizontallyResizable: YES];
[codeView setVerticallyResizable: YES];
[codeView setString: @"MMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM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MMM\nMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMM\nMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n"];
[codeView sizeToFit];
[[newWindow contentView] addSubview: codeView];
NSString* title = @"test window";
[newWindow setTitle: title];
[newWindow makeKeyAndOrderFront: self];
[[NSApplication sharedApplication] addWindowsItem: newWindow
title: title
filename: NO];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment