From 98d651758a14f1675a605000cd1813d7fc64695a Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 27 Jan 2010 17:48:11 +0000 Subject: =?UTF-8?q?=E2=80=A2=20improved=20the=20graphical=20representation?= =?UTF-8?q?=20of=20text=20macro=20snippets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/DBView.xib | 72 +++---------------------------------- Source/CMTextView.h | 2 ++ Source/CMTextView.m | 25 +++++++++---- Source/CustomQuery.m | 2 +- 4 files changed, 27 insertions(+), 74 deletions(-) diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index ade5b304..cec05aa8 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -23,6 +23,7 @@ YES + YES @@ -100,7 +101,6 @@ 266 {{5, 2}, {202, 19}} - YES 343014976 @@ -193,7 +193,6 @@ 256 {212, 26} - YES @@ -282,7 +281,6 @@ {212, 26} - @@ -298,7 +296,6 @@ -2147483392 {{-100, -100}, {15, 102}} - _doScroller: 37 @@ -309,7 +306,6 @@ -2147483392 {{-100, -100}, {223, 15}} - 1 _doScroller: @@ -318,7 +314,6 @@ {212, 26} - 0 @@ -329,7 +324,6 @@ {212, 26} - NSView @@ -352,7 +346,6 @@ 4352 {212, 354} - YES @@ -419,7 +412,6 @@ {212, 354} - @@ -430,7 +422,6 @@ -2147483392 {{197, 0}, {15, 292}} - _doScroller: 0.99658697843551636 @@ -440,7 +431,6 @@ -2147483392 {{-100, -100}, {141, 11}} - 257 _doScroller: @@ -449,7 +439,6 @@ {212, 354} - 528 @@ -460,13 +449,11 @@ {{0, 27}, {212, 354}} - NSView {212, 381} - 2 6 @@ -500,7 +487,6 @@ {212, 381} - NSView @@ -523,7 +509,6 @@ 4352 {212, 145} - YES @@ -590,7 +575,6 @@ {212, 145} - @@ -601,7 +585,6 @@ -2147483392 {{-100, -100}, {15, 20}} - _doScroller: 0.94736838340759277 @@ -611,7 +594,6 @@ -2147483392 {{-100, -100}, {141, 11}} - 257 _doScroller: @@ -620,7 +602,6 @@ {212, 145} - 512 @@ -631,13 +612,11 @@ {{0, 382}, {212, 145}} - NSView {{0, 23}, {212, 527}} - 2 NO @@ -688,7 +667,6 @@ 268 {{-1, -1}, {32, 24}} - YES 67239424 @@ -713,7 +691,6 @@ 268 {{30, -1}, {32, 24}} - YES 71433792 @@ -819,7 +796,6 @@ 268 {{61, -1}, {32, 24}} - YES 67239424 @@ -844,7 +820,6 @@ 268 {{92, -1}, {32, 24}} - YES -2080244224 @@ -871,7 +846,6 @@ {212, 23} - YES YES NO @@ -880,7 +854,6 @@ {212, 550} - NSView @@ -893,7 +866,6 @@ 274 {{-7, -10}, {735, 564}} - YES @@ -2968,7 +2940,6 @@ {688, 14} - @@ -2989,7 +2960,7 @@ 1 - 28003 + 27747 0 @@ -3028,7 +2999,6 @@ {{1, 1}, {688, 155}} - @@ -3043,7 +3013,6 @@ -2147483392 {{598, 1}, {15, 68}} - _doScroller: 1 @@ -3053,7 +3022,6 @@ -2147483392 {{-100, -100}, {601, 11}} - 257 _doScroller: @@ -3063,7 +3031,6 @@ {690, 157} - 530 @@ -3073,7 +3040,6 @@ {690, 156} - NSView @@ -3096,14 +3062,12 @@ 4352 {688, 228} - YES 256 {688, 17} - @@ -3111,7 +3075,6 @@ -2147483392 {{-26, 0}, {16, 17}} - YES @@ -3158,7 +3121,6 @@ {{1, 17}, {688, 228}} - @@ -3169,7 +3131,6 @@ -2147483392 {{611, 17}, {15, 30}} - _doScroller: 0.9375 @@ -3179,7 +3140,6 @@ -2147483392 {{1, 47}, {610, 15}} - 1 _doScroller: @@ -3194,7 +3154,6 @@ {{1, 0}, {688, 17}} - @@ -3204,7 +3163,6 @@ {690, 246} - 562 @@ -3219,7 +3177,6 @@ 268 {{156, 246}, {98, 22}} - YES -2076049856 @@ -3321,7 +3278,6 @@ - 5 YES 3 YES @@ -3334,7 +3290,6 @@ 264 {{38, 246}, {108, 22}} - YES -2076049856 @@ -3449,7 +3404,6 @@ 268 {{-10, 245}, {46, 25}} - YES -2076049856 @@ -3731,7 +3685,6 @@ 265 {{591, 248}, {90, 17}} - YES -2080244224 @@ -3753,7 +3706,6 @@ 265 {{473, 248}, {110, 17}} - YES 604110336 @@ -3786,7 +3738,6 @@ {{32, 246}, {658, 23}} - YES 130560 @@ -3802,7 +3753,6 @@ {{0, 165}, {690, 269}} - NSView @@ -3815,7 +3765,6 @@ 266 {{242, 64}, {431, 17}} - YES 67239424 @@ -3832,7 +3781,6 @@ 264 {{17, 67}, {143, 14}} - YES 67239424 @@ -3849,7 +3797,6 @@ 274 {{17, 20}, {656, 43}} - YES 69336577 @@ -3864,18 +3811,15 @@ {{0, 443}, {690, 87}} - NSView {{6, 10}, {690, 530}} - {{10, 7}, {700, 544}} - Custom Query @@ -4933,20 +4877,17 @@ {{221, 0}, {723, 550}} - NSView {944, 550} - YES DBViewSplitter {944, 550} - {{0, 0}, {1920, 1178}} {780, 502} @@ -10833,7 +10774,7 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 NSView - + 4364 YES @@ -10842,7 +10783,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 268 {{20, 1}, {176, 19}} - YES 343014976 @@ -10904,8 +10844,6 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 {217, 20} - - NSView @@ -23160,10 +23098,10 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8 com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{225, 421}, {944, 550}} + {{225, 206}, {944, 550}} com.apple.InterfaceBuilder.CocoaPlugin - {{225, 421}, {944, 550}} + {{225, 206}, {944, 550}} {{62, 352}, {845, 504}} diff --git a/Source/CMTextView.h b/Source/CMTextView.h index ab7ed1af..96028a5e 100644 --- a/Source/CMTextView.h +++ b/Source/CMTextView.h @@ -103,4 +103,6 @@ static inline void NSMutableAttributedStringAddAttributeValueRange (NSMutableAtt - (NSUInteger)characterIndexOfPoint:(NSPoint)aPoint; - (void)insertFileContentOfFile:(NSString *)aPath; +- (BOOL)isSnippetMode; + @end diff --git a/Source/CMTextView.m b/Source/CMTextView.m index eb2abff4..cadd71c4 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -1125,6 +1125,15 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) } +/* + * Return YES if user interacts with snippets (is needed mainly for suppressing + * the highlighting of the current query) + */ +- (BOOL)isSnippetMode +{ + return (snippetControlCounter > -1) ? YES : NO; +} + #pragma mark - #pragma mark event management @@ -2865,24 +2874,28 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) - (void)drawRect:(NSRect)rect { - [super drawRect:rect]; - // Highlight snippets coming from the Query Favorite text macro if(snippetControlCounter > -1) { NSInteger i; - [[NSColor colorWithCalibratedRed:0.0 green:0.5 blue:0.0 alpha:0.1] setFill]; for(i=0; i -1) { NSRange glRange = [[self layoutManager] glyphRangeForCharacterRange:NSMakeRange(snippetControlArray[i][0],snippetControlArray[i][1]) actualCharacterRange:NULL]; if(glRange.length) { NSRect boundingRect = [[self layoutManager] boundingRectForGlyphRange:glRange inTextContainer:[self textContainer]]; - boundingRect = NSInsetRect(boundingRect, 0, 2); - NSBezierPath *aBezierPath = [NSBezierPath bezierPathWithRoundedRect:boundingRect xRadius:4 yRadius:15]; + boundingRect = NSInsetRect(boundingRect, -4, -1); + NSBezierPath *aBezierPath = [NSBezierPath bezierPathWithRoundedRect:boundingRect xRadius:5 yRadius:10]; + [[NSColor colorWithCalibratedRed:1.0 green:1. blue:0.0 alpha:0.4] setFill]; + [aBezierPath fill]; + boundingRect = NSInsetRect(boundingRect, 2, 2); + aBezierPath = [NSBezierPath bezierPathWithRoundedRect:boundingRect xRadius:5 yRadius:10]; + [[NSColor colorWithCalibratedRed:1.0 green:1. blue:1.0 alpha:0.8] setFill]; [aBezierPath fill]; } } } } + [super drawRect:rect]; + } @@ -3051,7 +3064,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) NSInteger changeInLength = [textStore changeInLength]; NSInteger i; - // Remove any fully nested snippets relative to the current snippet which is was edited + // Remove any fully nested snippets relative to the current snippet which was edited if(snippetControlArray[i][0] > -1 && i != snippetControlMax) { NSInteger currentSnippetLocation = snippetControlArray[currentSnippetIndex][0]; NSInteger currentSnippetMaxRange = snippetControlArray[currentSnippetIndex][0] + snippetControlArray[currentSnippetIndex][1]; diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index a02da041..6f8afecf 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -2046,7 +2046,7 @@ // Highlight by setting a background color the current query // if nothing is selected - if(qRange.length && !currentSelection.length) { + if(qRange.length && !currentSelection.length && ![textView isSnippetMode]) { if([prefs boolForKey:SPCustomQueryHighlightCurrentQuery]) { [[textView textStorage] addAttribute: NSBackgroundColorAttributeName value: [NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorHighlightQueryColor]] -- cgit v1.2.3