Mercurial > dwindows
changeset 1959:9ac432c8620c
Mac: Switch to using NSAttributedString with foreground color set to
NSColor.textColor for importing to the DWMLE class. This allows the core
NSTextView to correctly display and change with light/dark modes.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 25 Jul 2019 07:51:10 +0000 |
parents | 45abd53a3fc6 |
children | 22e3e829be13 |
files | mac/dw.m |
diffstat | 1 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mac/dw.m Thu Jul 25 06:55:01 2019 +0000 +++ b/mac/dw.m Thu Jul 25 07:51:10 2019 +0000 @@ -5865,13 +5865,14 @@ unsigned int retval; NSTextStorage *ts = [mle textStorage]; NSString *nstr = [NSString stringWithUTF8String:buffer]; - NSMutableString *ms = [ts mutableString]; - NSUInteger length = [ms length]; + NSDictionary *attributes = [NSDictionary dictionaryWithObject:NSColor.textColor forKey:NSForegroundColorAttributeName]; + NSAttributedString *nastr = [[NSAttributedString alloc] initWithString:nstr attributes:attributes]; + NSUInteger length = [ts length]; if(startpoint < 0) startpoint = 0; if(startpoint > length) startpoint = (int)length; - [ms insertString:nstr atIndex:startpoint]; + [ts insertAttributedString:nastr atIndex:startpoint]; retval = (unsigned int)strlen(buffer) + startpoint; DW_FUNCTION_RETURN_THIS(retval); }