Changing the default color in an NSTextView?
Changing the default color in an NSTextView?
- Subject: Changing the default color in an NSTextView?
- From: Chris Gehlker <email@hidden>
- Date: Sat, 23 Feb 2002 09:35:04 -0700
Hi everybody,
I'm still working on my Ruby IDE and now another issue has come up.
Sometimes the user hits Run to test a program that wants to interact as if
it were launched from the command line. I though it would be cool if the
computers prompts were in a different color, so I wrote this:
while ((dataToRead = [stdOutHndl availableData]) && [dataToRead
length]) {
outString = [[NSString alloc] initWith
Data:dataToRead
encoding:NSASCIIStringEncoding];
if (![outString isEqualToString:@"\n"]) {
outText = [[NSAttributedString alloc] initWithString:
outString attributes:
[NSDictionary dictionaryWithObject:[NSColor blueColor]
forKey:NSForegroundColorAttributeName]];
[resultsView insertText:outText];
[outText release];
This is good except for one problem. Adding the colored string leaves the
textView in a state where the next thing the user types will also be blue.
Apparently NSTextView looks back a character to infer the attributes of the
next character typed. I can see how you might want that in most
applications. I don9t want it, however, and I can't figure out how to turn
it off. I'm currently adding a space with default attributes but that's an
ugly hack.
Thanks for any help.
-Chris
--
Those who write clearly have readers, those who write obscurely have
commentators. -Albert Camus, writer and philosopher (1913-1960)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.