Browse files

TextMate Style Command-Return

moves caret to end of current paragraph and inserts a newline.
  • Loading branch information...
1 parent 2fd4c37 commit 23e216190a4361eda0fbc679741360877e7b9958 @elasticthreads elasticthreads committed Aug 16, 2011
Showing with 61 additions and 21 deletions.
  1. +26 −5 English.lproj/MainMenu.xib
  2. +1 −1 LinkingEditor.h
  3. +25 −7 LinkingEditor.m
  4. +2 −2 NVPasswordGenerator.m
  5. +7 −6 Notation.xcodeproj/project.pbxproj
View
31 English.lproj/MainMenu.xib
@@ -60,12 +60,9 @@
</object>
<string key="NSWindowContentMinSize">{213, 107}</string>
<object class="NSView" key="NSWindowView" id="92063295">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<string key="NSFrame">{{7, 11}, {397, 464}}</string>
- <reference key="NSSuperview"/>
- <reference key="NSWindow"/>
- <reference key="NSNextKeyView"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
<string key="NSMinSize">{213, 129}</string>
@@ -1879,8 +1876,28 @@
<object class="NSTextView" id="633888970">
<reference key="NSNextResponder" ref="572834572"/>
<int key="NSvFlags">2322</int>
+ <set class="NSMutableSet" key="NSDragTypes">
+ <string>Apple HTML pasteboard type</string>
+ <string>Apple PDF pasteboard type</string>
+ <string>Apple PICT pasteboard type</string>
+ <string>Apple PNG pasteboard type</string>
+ <string>Apple URL pasteboard type</string>
+ <string>CorePasteboardFlavorType 0x6D6F6F76</string>
+ <string>NSColor pasteboard type</string>
+ <string>NSFilenamesPboardType</string>
+ <string>NSStringPboardType</string>
+ <string>NeXT Encapsulated PostScript v1.2 pasteboard type</string>
+ <string>NeXT RTFD pasteboard type</string>
+ <string>NeXT Rich Text Format v1.0 pasteboard type</string>
+ <string>NeXT TIFF v4.0 pasteboard type</string>
+ <string>NeXT font pasteboard type</string>
+ <string>NeXT ruler pasteboard type</string>
+ <string>WebURLsWithTitlesPboardType</string>
+ <string>public.url</string>
+ </set>
<string key="NSFrameSize">{399, 14}</string>
<reference key="NSSuperview" ref="572834572"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="540470833"/>
<object class="NSTextContainer" key="NSTextContainer" id="721568932">
<object class="NSLayoutManager" key="NSLayoutManager">
@@ -1901,7 +1918,7 @@
<int key="NSTCFlags">1</int>
</object>
<object class="NSTextViewSharedData" key="NSSharedData">
- <int key="NSFlags">67120871</int>
+ <int key="NSFlags">11367</int>
<int key="NSTextCheckingTypes">0</int>
<nil key="NSMarkedAttributes"/>
<reference key="NSBackgroundColor" ref="883979725"/>
@@ -1937,6 +1954,7 @@
</array>
<string key="NSFrameSize">{399, 304}</string>
<reference key="NSSuperview" ref="26511639"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="633888970"/>
<reference key="NSDocView" ref="633888970"/>
<object class="NSColor" key="NSBGColor">
@@ -1973,6 +1991,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<int key="NSvFlags">-2147479296</int>
<string key="NSFrame">{{384, 0}, {15, 304}}</string>
<reference key="NSSuperview" ref="26511639"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<int key="NSArrowsLoc">2</int>
<reference key="NSTarget" ref="26511639"/>
@@ -1984,6 +2003,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<int key="NSvFlags">-2147479296</int>
<string key="NSFrame">{{-100, -100}, {384, 15}}</string>
<reference key="NSSuperview" ref="26511639"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="572834572"/>
<int key="NSsFlags">1</int>
<int key="NSArrowsLoc">2</int>
@@ -1995,6 +2015,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
</array>
<string key="NSFrameSize">{399, 304}</string>
<reference key="NSSuperview"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="965568530"/>
<int key="NSsFlags">528</int>
<reference key="NSVScroller" ref="540470833"/>
View
2 LinkingEditor.h
@@ -82,6 +82,7 @@
- (void)switchFindPanelDelegate;
- (IBAction)findInFullscreen;
- (IBAction)insertLink:(id)sender;
+- (void)cmdReturn;
//
@end
@@ -90,7 +91,6 @@
- (void)toggleAutomaticTextReplacement:(id)sender;
- (BOOL)isAutomaticTextReplacementEnabled;
- (void)setAutomaticTextReplacementEnabled:(BOOL)flag;
-
- (void)moveToLeftEndOfLine:(id)sender;
#endif
View
32 LinkingEditor.m
@@ -631,13 +631,13 @@ - (NSRange)selectionRangeForProposedRange:(NSRange)proposedSelRange granularity:
return [super selectionRangeForProposedRange:proposedSelRange granularity:granularity];
}
- unsigned int location = [super selectionRangeForProposedRange:proposedSelRange granularity:NSSelectByCharacter].location;
+ unsigned int location = (unsigned int)[super selectionRangeForProposedRange:proposedSelRange granularity:NSSelectByCharacter].location;
int originalLocation = location;
NSString *completeString = [self string];
unichar characterToCheck = [completeString characterAtIndex:location];
unsigned short skipMatchingBrace = 0;
- unsigned int lengthOfString = [completeString length];
+ unsigned int lengthOfString = (unsigned int)[completeString length];
if (lengthOfString == proposedSelRange.location) { // To avoid crash if a double-click occurs after any text
return [super selectionRangeForProposedRange:proposedSelRange granularity:granularity];
}
@@ -650,7 +650,7 @@ - (NSRange)selectionRangeForProposedRange:(NSRange)proposedSelRange granularity:
char *rightChar = strchr(rightGroupings, (char)characterToCheck);
if (rightChar) {
- groupingIndex = rightChar - rightGroupings;
+ groupingIndex = (int)(rightChar - rightGroupings);
triedToMatchBrace = YES;
while (location--) {
@@ -670,7 +670,7 @@ - (NSRange)selectionRangeForProposedRange:(NSRange)proposedSelRange granularity:
char *leftChar = strchr(leftGroupings, (char)characterToCheck);
if (leftChar) {
- groupingIndex = leftChar - leftGroupings;
+ groupingIndex = (int)(leftChar - leftGroupings);
triedToMatchBrace = YES;
while (++location < lengthOfString) {
@@ -816,18 +816,20 @@ - (void)flagsChanged:(NSEvent *)theEvent{
[[NSApp delegate] flagsChanged:theEvent];
}
-
- (void)keyDown:(NSEvent*)anEvent {
+ [[NSApp delegate] resetModTimers];
unichar keyChar = [anEvent firstCharacterIgnoringModifiers];
if (keyChar == NSBackTabCharacter) {
//apparently interpretKeyEvents: on 10.3 does not call insertBacktab
//maybe it works on someone else's 10.3 Mac
[self doCommandBySelector:@selector(insertBacktab:)];
return;
- }
+ }else if (([anEvent keyCode]==36)&&([anEvent modifierFlags]&NSCommandKeyMask)&&(!(([anEvent modifierFlags]&NSControlKeyMask)||([anEvent modifierFlags]&NSAlternateKeyMask)||([anEvent modifierFlags]&NSShiftKeyMask)))) {
+ [self cmdReturn];
+ return;
+ }
- [[NSApp delegate] resetModTimers];
//[super interpretKeyEvents:[NSArray arrayWithObject:anEvent]];
[super keyDown:anEvent];
@@ -1631,6 +1633,22 @@ - (void)dealloc {
//elasticwork
+- (void)cmdReturn{
+ NSRange selRange = [self selectedRange];
+ NSString *postStr=[[self string] substringFromIndex:selRange.location];
+ const unichar newL = NSNewlineCharacter;
+ NSString *nwLn=[NSString stringWithCharacters:&newL length:1];
+ NSRange pRange = [postStr rangeOfString:nwLn];
+ pRange.length=0;
+ if (pRange.location==NSNotFound) {
+ pRange.location=[self string].length;
+ }else{
+ pRange.location+=selRange.location;
+ }
+ [self setSelectedRange:pRange];
+ [super insertNewlineIgnoringFieldEditor:self];
+}
+
- (IBAction)insertLink:(id)sender{
if ([[self window] firstResponder]!=self) {
[[self window] makeFirstResponder:self];
View
4 NVPasswordGenerator.m
@@ -93,10 +93,10 @@ + (NSArray*)suggestions
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
dispatch_apply(numSuggestions, dispatch_get_global_queue(0, 0), ^(size_t i) {
#else
- size_t i;
+ __block size_t i;
for (i = 0; i < numSuggestions; ++i) {
#endif
- suggest[i] = [self performSelector:methods[i]];
+ // suggest[i] = [self performSelector:methods[i]]; //BUILD ISSUE
}
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
);
View
13 Notation.xcodeproj/project.pbxproj
@@ -2317,7 +2317,7 @@
GCC_THREADSAFE_STATICS = NO;
GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = NO;
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
- GCC_VERSION = "";
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
@@ -2367,7 +2367,7 @@
GCC_THREADSAFE_STATICS = NO;
GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
- GCC_VERSION = "";
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES;
GCC_WARN_ABOUT_GLOBAL_CONSTRUCTORS = NO;
@@ -2419,6 +2419,7 @@
GCC_THREADSAFE_STATICS = NO;
GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
@@ -2445,7 +2446,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.5;
"MACOSX_DEPLOYMENT_TARGET[sdk=macosx10.6][arch=x86_64]" = 10.5;
- SDKROOT = macosx10.7;
+ SDKROOT = macosx;
"SDKROOT[arch=x86_64]" = macosx;
};
name = Default;
@@ -2462,7 +2463,7 @@
GCC_THREADSAFE_STATICS = NO;
GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
- GCC_VERSION = "";
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
@@ -2538,12 +2539,12 @@
INSTALL_PATH = "$(HOME)/Applications";
LIBRARY_SEARCH_PATHS = "$(LIBRARY_SEARCH_PATHS)";
MACOSX_DEPLOYMENT_TARGET = 10.5;
- "MACOSX_DEPLOYMENT_TARGET[sdk=macosx10.6][arch=x86_64]" = 10.5;
+ "MACOSX_DEPLOYMENT_TARGET[sdk=macosx10.6][arch=x86_64]" = 10.6;
ONLY_ACTIVE_ARCH = NO;
OTHER_LDFLAGS = "";
PRODUCT_NAME = nvALT;
SDKROOT = macosx;
- "SDKROOT[arch=x86_64]" = macosx10.7;
+ "SDKROOT[arch=x86_64]" = macosx;
SECTORDER_FLAGS = (
"-sectorder",
__TEXT,

0 comments on commit 23e2161

Please sign in to comment.