How to make columns in a text view?

Is NSTextContainer a good candidate for that?
And how to achieve it?

NSTextContainer is probably what you need (along with other classes), unless you’re thinking of tables. But the “how” part looks to be pretty complicated — possibly too much for ASObjC.

I suspect you’re going to have to track down an Objective-C project, and do the translation yourself.

That’s what I was affraid of…

Thanks anyway :wink:

There’s an Apple sample project here.

Thanks Phil,

I already found a way to do it. This is just a rough draft:

		-- create the text storage
		set textStorage to current application's NSTextStorage's alloc()'s initWithAttributedString:styledString
		-- add layout manager to the text storage
		set textLayout to current application's NSLayoutManager's alloc()'s init()
		textStorage's addLayoutManager:textLayout
		-- create the text containers
		set textContainer1 to current application's NSTextContainer's alloc()'s initWithSize:{360, 700}
		set textContainer2 to current application's NSTextContainer's alloc()'s initWithSize:{360, 700}
		set textContainer3 to current application's NSTextContainer's alloc()'s initWithSize:{360, 700}
		-- add the text containers to text layout manager
		textLayout's insertTextContainer:textContainer1 atIndex:0
		textLayout's insertTextContainer:textContainer2 atIndex:1
		textLayout's insertTextContainer:textContainer3 atIndex:2
		-- create text views linked to the text containers
		set textView1 to current application's NSTextView's alloc()'s initWithFrame:{{40, 40}, {360, 700}} textContainer:textContainer1
		set textView2 to current application's NSTextView's alloc()'s initWithFrame:{{420, 40}, {360, 700}} textContainer:textContainer2
		set textView3 to current application's NSTextView's alloc()'s initWithFrame:{{800, 40}, {360, 700}} textContainer:textContainer3
		-- add text views to the main view
		theWindow's contentView()'s addSubview:textView1
		theWindow's contentView()'s addSubview:textView2
		theWindow's contentView()'s addSubview:textView3

I will give a look to the link you kindly provided. :wink:

1 Like

Cool — it doesn’t look nearly as bad as I thought.