reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit cc6c1780ddd78f50c20a4ea392d3d4a5ef934aba
parent 3606a08b13e5d424d41c314ed3eb78f6169800fa
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Sun, 12 Jan 2020 17:05:11 -0500

about: fix unreadable text when macOS dark mode is enabled

Diffstat:
Msrc/richedit.mm | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/richedit.mm b/src/richedit.mm @@ -48,9 +48,14 @@ void RichEdit::setPlainText(const std::string &text) encoding: NSUTF8StringEncoding ]; - NSTextView *textView = (NSTextView *)handle(); + NSDictionary *darkMode = [NSDictionary + dictionaryWithObject: NSColor.textColor + forKey: NSForegroundColorAttributeName]; - NSAttributedString *attrStr = [[NSAttributedString alloc] initWithString: str]; + NSAttributedString *attrStr = [[NSAttributedString alloc] + initWithString: str attributes: darkMode]; + + auto textView = static_cast<NSTextView *>(handle()); [[textView textStorage] setAttributedString: attrStr]; [attrStr release]; } @@ -62,8 +67,6 @@ bool RichEdit::setRichText(const std::string &rtf) encoding: NSUTF8StringEncoding ]; - NSTextView *textView = (NSTextView *)handle(); - NSAttributedString *attrStr = [[NSAttributedString alloc] initWithRTF: [str dataUsingEncoding: NSUTF8StringEncoding] documentAttributes: nullptr]; @@ -71,7 +74,9 @@ bool RichEdit::setRichText(const std::string &rtf) if(!attrStr) return false; + auto textView = static_cast<NSTextView *>(handle()); [[textView textStorage] setAttributedString: attrStr]; + [textView setTextColor: NSColor.textColor]; // dark mode support [attrStr release]; // auto-detect links, equivalent to Windows' EM_AUTOURLDETECT message