molikto
molikto

Reputation: 536

Is this achievable in OS X TextView? (wrap with indent)

See screenshot from Sublime Text 2

enter image description here

The second line is wrapped with indent. Can I do this with standard TextView in OS X?

Upvotes: 2

Views: 201

Answers (2)

Vlad
Vlad

Reputation: 6732

If you need visually indent wrapped lines (aka IDE editor) without modifying text storage attributes, then subclassing of NSATSTypesetter is needed. See my SO answer.

Upvotes: 1

Ken Thomases
Ken Thomases

Reputation: 90601

According to Text System User Interface Layer Programming Guide: Setting Text Margins, you would set a mutable paragraph style object's firstLineHeadIndent and headIndent to do that. So:

NSMutableParagraphStyle* style = [NSMutableParagraphStyle defaultParagraphStyle];
style.headIndent = style.firstLineHeadIndent = 40;
[textView.textStorage addAttribute:style value:NSParagraphStyleAttributeName range:NSMakeRange(0, textView.textStorage.length)];

Upvotes: 1

Related Questions