Skip to content

Commit

Permalink
Merge pull request #31 from tyeen/fix#27
Browse files Browse the repository at this point in the history
Fix #27
  • Loading branch information
aliaksandr-andrashuk committed Mar 4, 2015
2 parents fbfc0af + 419e9ff commit 47f91f5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Backlight/AAABacklight.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ - (id)initWithBundle:(NSBundle *)plugin
name:NSWindowDidResizeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backlightNotification:)
name:NSWindowDidBecomeKeyNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(endBacklightNotification:)
name:NSTextDidEndEditingNotification object:nil];

return self;
}
Expand Down Expand Up @@ -289,6 +291,24 @@ - (void)backlightNotification:(NSNotification *)notification
[self updateBacklightViewWithTextView:firstResponder];
}

/**
* Respond to NSTextDidEndEditingNotification to remove the highlighted background color.
*/
- (void)endBacklightNotification:(NSNotification *)notification {
id firstResponder = [[NSApp keyWindow] firstResponder];
if (![firstResponder isKindOfClass:NSClassFromString(@"DVTSourceTextView")]) return;

if (self.textView != nil &&
self.textView == firstResponder &&
self.currentMode == AAABacklightModeUnderneath &&
[self.textView.layoutManager temporaryAttribute:NSBackgroundColorAttributeName
atCharacterIndex:self.currentLineRange.location
effectiveRange:NULL]) {
[self.textView.layoutManager removeTemporaryAttribute:NSBackgroundColorAttributeName
forCharacterRange:self.currentLineRange];
}
}

- (void)colorPanelWillClose:(NSNotification *)notification
{
NSColorPanel *panel = [NSColorPanel sharedColorPanel];
Expand Down

0 comments on commit 47f91f5

Please sign in to comment.