On Sunday, 20 September 2015 at 00:22:17 UTC, Joel wrote:
What is simple way to wrap a string into strings?
Eg from:
I went for a walk and fell down a hole.
To (6 max width):
I went
for a
walk
and
fell
down a
hole.
a common method works as follows. first you split your string
into chunks where newlines might appear. e.g. after every space.
then you keep track of a "line buffer", you keep adding chunks to
the line buffer until it's too wide, then you remove one chunk
and output the buffer as a line. rinse and repeat.
I'll get to work on some example code.