diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-12-08 13:17:46 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-12-08 13:17:46 +0000 |
commit | a6180b9b0c513d11e27c7f8f5801225fcbed315c (patch) | |
tree | 7bba8f3328024622dd4f3c7faeee004e3b6ada3a | |
parent | c491ba8abfa470dac9b552cbad885bba81b02785 (diff) | |
download | sequelpro-a6180b9b0c513d11e27c7f8f5801225fcbed315c.tar.gz sequelpro-a6180b9b0c513d11e27c7f8f5801225fcbed315c.tar.bz2 sequelpro-a6180b9b0c513d11e27c7f8f5801225fcbed315c.zip |
• Bundel Editor
- improved undo behaviour
- fix issue for non-US keyboard layouts
-rw-r--r-- | Source/SPBundleCommandTextView.m | 48 | ||||
-rw-r--r-- | Source/SPBundleEditorController.m | 2 |
2 files changed, 27 insertions, 23 deletions
diff --git a/Source/SPBundleCommandTextView.m b/Source/SPBundleCommandTextView.m index 76020392..8a5bf620 100644 --- a/Source/SPBundleCommandTextView.m +++ b/Source/SPBundleCommandTextView.m @@ -408,44 +408,54 @@ if (currentRange.length == 0 || ![self isEditable]) return NO; - unichar matchingCharacter; + NSString *matchingCharacter; + NSString *prefixStr = nil; // Set matchingCharacter due to prefix. switch (prefix) { case '(': - matchingCharacter = ')'; + matchingCharacter = @")"; break; case '"': - matchingCharacter = '"'; + matchingCharacter = @"\""; break; case '`': - matchingCharacter = '`'; + matchingCharacter = @"`"; break; case '\'': - matchingCharacter = '\''; + matchingCharacter = @"'"; break; case '{': - matchingCharacter = '}'; + matchingCharacter = @"}"; break; case '[': - matchingCharacter = ']'; + matchingCharacter = @"]"; break; - case '“': - matchingCharacter = '”'; + case 0x201c: + prefixStr = @"“"; + matchingCharacter = @"”"; break; - case '‘': - matchingCharacter = '’'; + case 0x2018: + prefixStr = @"‘"; + matchingCharacter = @"’"; break; default: return NO; } NSString *selString = [[self string] substringWithRange:currentRange]; + NSString *replaceString; + if(prefixStr != nil) + replaceString = [NSString stringWithFormat:@"%@%@%@", prefixStr, selString, matchingCharacter]; + else + replaceString = [NSString stringWithFormat:@"%c%@%@", prefix, selString, matchingCharacter]; + + [self breakUndoCoalescing]; // Replace the current selection with the selected string wrapped in prefix and suffix - [self insertText:[NSString stringWithFormat:@"%c%@%c", prefix, selString, matchingCharacter]]; - + [self insertText:replaceString]; + // Re-select original selection NSRange innerSelectionRange = NSMakeRange(currentRange.location+1, [selString length]); [self setSelectedRange:innerSelectionRange]; @@ -458,18 +468,12 @@ long allFlags = (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask); - // Check if user pressed ⌥ to allow composing of accented characters. - // e.g. for US keyboard "⌥u a" to insert ä - // or for non-US keyboards to allow to enter dead keys - // e.g. for German keyboard ` is a dead key, press space to enter ` - if (([theEvent modifierFlags] & allFlags) == NSAlternateKeyMask || [[theEvent characters] length] == 0) - { + NSString *characters = [theEvent characters]; + NSString *charactersIgnMod = [theEvent charactersIgnoringModifiers]; + if(![characters length]) { [super keyDown: theEvent]; return; } - - NSString *characters = [theEvent characters]; - NSString *charactersIgnMod = [theEvent charactersIgnoringModifiers]; unichar insertedCharacter = [characters characterAtIndex:0]; long curFlags = ([theEvent modifierFlags] & allFlags); diff --git a/Source/SPBundleEditorController.m b/Source/SPBundleEditorController.m index 7c213a6f..4091e606 100644 --- a/Source/SPBundleEditorController.m +++ b/Source/SPBundleEditorController.m @@ -1504,7 +1504,7 @@ cycleCounter = 0; } - [self performSelector:@selector(setAllowedUndo) withObject:nil afterDelay:0.09]; + [self performSelector:@selector(setAllowedUndo) withObject:nil afterDelay:0.0005]; } } |