comparison mac/dw.m @ 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 80f6be39b7fe
comparison
equal deleted inserted replaced
1958:45abd53a3fc6 1959:9ac432c8620c
5863 DW_FUNCTION_INIT; 5863 DW_FUNCTION_INIT;
5864 DWMLE *mle = handle; 5864 DWMLE *mle = handle;
5865 unsigned int retval; 5865 unsigned int retval;
5866 NSTextStorage *ts = [mle textStorage]; 5866 NSTextStorage *ts = [mle textStorage];
5867 NSString *nstr = [NSString stringWithUTF8String:buffer]; 5867 NSString *nstr = [NSString stringWithUTF8String:buffer];
5868 NSMutableString *ms = [ts mutableString]; 5868 NSDictionary *attributes = [NSDictionary dictionaryWithObject:NSColor.textColor forKey:NSForegroundColorAttributeName];
5869 NSUInteger length = [ms length]; 5869 NSAttributedString *nastr = [[NSAttributedString alloc] initWithString:nstr attributes:attributes];
5870 NSUInteger length = [ts length];
5870 if(startpoint < 0) 5871 if(startpoint < 0)
5871 startpoint = 0; 5872 startpoint = 0;
5872 if(startpoint > length) 5873 if(startpoint > length)
5873 startpoint = (int)length; 5874 startpoint = (int)length;
5874 [ms insertString:nstr atIndex:startpoint]; 5875 [ts insertAttributedString:nastr atIndex:startpoint];
5875 retval = (unsigned int)strlen(buffer) + startpoint; 5876 retval = (unsigned int)strlen(buffer) + startpoint;
5876 DW_FUNCTION_RETURN_THIS(retval); 5877 DW_FUNCTION_RETURN_THIS(retval);
5877 } 5878 }
5878 5879
5879 /* 5880 /*