Skip to content

Instantly share code, notes, and snippets.

@zorgiepoo
Created December 4, 2016 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zorgiepoo/b58ba63335bfa559ddbd4f4e028a1fc4 to your computer and use it in GitHub Desktop.
Save zorgiepoo/b58ba63335bfa559ddbd4f4e028a1fc4 to your computer and use it in GitHub Desktop.
// I'm not using the passed editRange and delta because I've found them to be quite misleading...
// This happens to be a new API (macOS 10.11) so maybe it's not really battle tested or I don't know what I'm doing
// Either way I'd like to support older systems so for portability sake it's easier to not use these parameters
- (void)textStorage:(NSTextStorage *)textStorage didProcessEditing:(NSTextStorageEditActions)editedMask range:(NSRange)editedRange changeInLength:(NSInteger)__unused delta
{
if ((editedMask & NSTextStorageEditedCharacters) != 0)
{
//[self updateTextProcessingForTextStorage:textStorage];
//NSLog(@"Edited range: %lu, %lu", editedRange.location, editedRange.length);
[textStorage removeAttribute:NSBackgroundColorAttributeName range:NSMakeRange(0, textStorage.length)];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment