• 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
Re: Limiting number of characters per line in a NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Limiting number of characters per line in a NSTextView


  • Subject: Re: Limiting number of characters per line in a NSTextView
  • From: Martin Wierschin <email@hidden>
  • Date: Wed, 18 Mar 2009 13:32:51 -0700

I want my NSTextView to show only 32 characters per line and the 33rd
character should be shown at next line of textview.

My NSTextView will have fixed font.

If your font is truly fixed width, you can probably just set the NSTextView frame so it exactly fits 32 characters on a line. Then set the line breaking mode to wrap by character, eg:


NSTextView* tv = whatever;
NSTextStorage* ts = [tv textStorage];
NSMutableParagraphStyle* paraStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paraStyle setLineBreakMode:NSLineBreakByCharWrapping];
[ts addAttribute:NSParagraphStyleAttributeName value:paraStyle range:NSMakeRange(0, [ts length])];
[paraStyle release];


Warning: code typed into Mail without compiling/testing of any kind.

Hope that helps,

~Martin

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Limiting number of characters per line in a NSTextView
      • From: Andrew Farmer <email@hidden>
References: 
 >Limiting number of characters per line in a NSTextView (From: "Ankur Singhal" <email@hidden>)

  • Prev by Date: Custom modal panel, like NSSavePanel/NSOpenPanel
  • Next by Date: Construct type array from CGImageSourceCopyTypeIdentifiers
  • Previous by thread: Limiting number of characters per line in a NSTextView
  • Next by thread: Re: Limiting number of characters per line in a NSTextView
  • Index(es):
    • Date
    • Thread