• 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
Removing all paragraph settings from a textview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Removing all paragraph settings from a textview


  • Subject: Removing all paragraph settings from a textview
  • From: Gerben Wierda <email@hidden>
  • Date: Sun, 6 Oct 2002 12:10:05 +0200

I have created the following category for NSTextView:

@implementation NSTextView (paragraphStyle)
static NSFont *__pStyleFixedFont = nil;
static NSDictionary *__pStyleFixedAttr = nil;

- (NSDictionary *)fixedAttr
{
if (!__pStyleFixedAttr) {
__pStyleFixedAttr = [[NSDictionary dictionaryWithObject:__pStyleFixedFont forKey:NSFontAttributeName] retain];
}
return __pStyleFixedAttr;
}

- (NSFont *)fixedFont
{
if (!__pStyleFixedFont) {
__pStyleFixedFont = [[NSFont userFixedPitchFontOfSize:0.0] retain];
}
return __pStyleFixedFont;
}

- (void)resetParagraphStyleAndClear
{
NSParagraphStyle *paraStyle = [NSParagraphStyle defaultParagraphStyle];

NSLog( @"reset and clear");
[self setString:@" "];
[[self textStorage] addAttribute:NSParagraphStyleAttributeName value:paraStyle range:NSMakeRange(0, [[self string] length])];
[self setString:@""];
[self setFont:[self fixedFont]];
}
@end

Now, when I have a NSTextView with in it RTF-data which ends with a indented paragraph, and when I call [aView resetParagraphStyleAndClear] and when I then add plain text strings to that view, as in:

A] [aView setString:[self stringFromFileContents:fileName]];

I would expect that the information is not indented. But it is.

When I add data with

B] [[aView textStorage] appendAttributedString: [[[NSAttributedString alloc]
initWithString: aString attributes:[aView fixedAttr]] autorelease]];

it is not indented.

How can I set the view to a (completely initial) state where A] also is displayed non-indented? I have tried

[self setRichText:NO];
[self setUsesRuler:NO];

but it does not help.

G
_______________________________________________
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.

  • Follow-Ups:
    • Re: Removing all paragraph settings from a textview
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: relaunch Finder...
  • Next by Date: NSProgressIndicator acting wonky
  • Previous by thread: Re: <no subject>
  • Next by thread: Re: Removing all paragraph settings from a textview
  • Index(es):
    • Date
    • Thread