running-text

How to start implementing a running text algorithm?

I have a dialog implementation that receives a length of text from the user and I'd like to format it over multiple lines in a visually pleasing way. The user can include their own line breaks in the string which I would also like to account for. Is anyone aware of pseudocode or something else publicly available I could use as a referen...