• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Changing the default color in an NSTextView?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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] initWithData: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.

  • Prev by Date: Re: +poseAsClass and instance variables
  • Next by Date: Getting selected items in a matrix
  • Previous by thread: Re: NSPopupButton and fonts
  • Next by thread: Re: Changing the default color in an NSTextView?
  • Index(es):
    • Date
    • Thread