diff options
author | rowanbeentje <rowan@beent.je> | 2009-04-02 22:47:54 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2009-04-02 22:47:54 +0000 |
commit | 6e4d0662303ecd6b3f953ff3313965835a9b8074 (patch) | |
tree | 63764a750a644dc655faafe6ce56cbcc35b7de6b /Source | |
parent | c9669a3236c88c24ee310b7812cd3fb6cc5e22d6 (diff) | |
download | sequelpro-6e4d0662303ecd6b3f953ff3313965835a9b8074.tar.gz sequelpro-6e4d0662303ecd6b3f953ff3313965835a9b8074.tar.bz2 sequelpro-6e4d0662303ecd6b3f953ff3313965835a9b8074.zip |
- Improves autopairing to no longer autopair different quote characters within a quoted string, and also to no longer autoquote escaped characters within a quoted string. Also adds syntax highlighting to `-enclosed strings. Further thanks to Hans-Jörg Bibiko for these further improvements to his original patch (see http://code.google.com/p/sequel-pro/issues/detail?id=208 )
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMTextView.m | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m index cfd42884..67d2b39b 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -138,6 +138,35 @@ YY_BUFFER_STATE yy_scan_string (const char *); return; } + // When a quote character is being inserted into a string quoted with other + // quote characters, or if it's the same character but is escaped, don't + // automatically match it. + if( + // Only for " ` or ' quote characters + (insertedCharacter == '\'' || insertedCharacter == '"' || insertedCharacter == '`') + + // And if the next char marked as linked auto-pair + && [self isNextCharMarkedBy:kAPlinked] + + // And we are inside a quoted string + && [self isNextCharMarkedBy:kWQquoted] + + // And there is no selection, just the text caret + && ![self selectedRange].length + + && ( + // And the user is inserting an escaped string + [[self string] characterAtIndex:[self selectedRange].location-1] == '\\' + + // Or the user is inserting a character not matching the characters used to quote this string + || [[self string] characterAtIndex:[self selectedRange].location] != insertedCharacter + ) + ) + { + [super keyDown: theEvent]; + return; + } + // If the caret is inside a text string, without any selection, skip autopairing. // There is one exception to this - if the caret is before a linked pair character, // processing continues in order to check whether the next character should be jumped @@ -819,7 +848,8 @@ sets self as delegate for the textView's textStorage to enable syntax highlighti NSColor *commentColor = [NSColor colorWithDeviceRed:0.000 green:0.455 blue:0.000 alpha:1.000]; NSColor *quoteColor = [NSColor colorWithDeviceRed:0.769 green:0.102 blue:0.086 alpha:1.000]; NSColor *keywordColor = [NSColor colorWithDeviceRed:0.200 green:0.250 blue:1.000 alpha:1.000]; - + NSColor *backtickColor = [NSColor colorWithDeviceRed:0.0 green:0.0 blue:0.658 alpha:1.000]; + NSColor *tokenColor; int token; @@ -845,6 +875,9 @@ sets self as delegate for the textView's textStorage to enable syntax highlighti case SPT_DOUBLE_QUOTED_TEXT: tokenColor = quoteColor; break; + case SPT_BACKTICK_QUOTED_TEXT: + tokenColor = backtickColor; + break; case SPT_RESERVED_WORD: tokenColor = keywordColor; break; |