Hi,
This is more a challenge then a question really.
I'm wanting to print some long lines out to a terminal, but I don't want the terminal to cut words in half as they wrap to the next line. Essentially I want to be able to split on the last word boundary before, say, 80 characters. I cannot pre-format the text as the terminal width is not guaranteed to be the same.
I want to, for example, to do this: -
instead of this: -
I've already got some code that does it, but it is clunky and horrible. I'm looking for something simpler and more elegant.
Thanks,
Warren
This is more a challenge then a question really.
I'm wanting to print some long lines out to a terminal, but I don't want the terminal to cut words in half as they wrap to the next line. Essentially I want to be able to split on the last word boundary before, say, 80 characters. I cannot pre-format the text as the terminal width is not guaranteed to be the same.
I want to, for example, to do this: -
Code:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum
Code:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis [red][b]nostr
ud[/b][/red] exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis [red][b]au
te[/b][/red] irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa [red][b]qu
i[/b][/red] officia deserunt mollit anim id est laborum
Thanks,
Warren