     }
     
 }
+
+
+
+private extension NSColor {
+    
+    static let tokenTextColor = NSColor(name: nil) { (appearance) in
+        NSColor.selectedControlColor.blended(withFraction: 0.7, of: appearance.isDark ? .white : .black)!
+    }
+    
+    static let tokenBraketColor = NSColor(name: nil) { (appearance) in
+        NSColor.selectedControlColor.blended(withFraction: 0.3, of: appearance.isDark ? .white : .black)!
+    }
+    
+    static let tokenBackgroundColor = NSColor(name: nil) { (appearance) in
+        NSColor.selectedControlColor.withAlphaComponent(appearance.isDark ? 0.5 : 0.3)
+    }
+    
+}

        
        tokenizer.tokenize(self.string) { (token, range, keywordRange) in
            layoutManager.addTemporaryAttribute(.token, value: token, forCharacterRange: range)
            layoutManager.addTemporaryAttribute(.roundedBackgroundColor, value: backgroundColor, forCharacterRange: range)
            layoutManager.addTemporaryAttribute(.foregroundColor, value: braketColor, forCharacterRange: range)
            layoutManager.addTemporaryAttribute(.foregroundColor, value: textColor, forCharacterRange: keywordRange)
        }
    }
    

    // MARK: Private Method
    
    /// find tokens in contents and mark-up them
    private func invalidateTokens() {
        
        guard
            let tokenizer = self.tokenizer,
            let layoutManager = self.layoutManager
            else { return }
        
        let wholeRange = self.string.nsRange
        layoutManager.removeTemporaryAttribute(.token, forCharacterRange: wholeRange)
