A while back, I came up with a great way to print fancy boxed and wrapped text to the screen (see the old post) in a way that was easy to use in other scripts, and which allowed the justification of the text. I've reworked the code since then, revisiting my random libraries as I do, and came up with a much better implementation. It more-or-less works the same as the old one, but now returns the string for printing, and some of the arguments are slightly different.
For example, the following code:
print formatText('Wow, this sure is a lot of text.\nQuite a bit of text, actually.\nWhy would anyone have this much text to output?', mode="box", width = 20, justify='center')
...produces this output:
==================== = Wow, this sure = = is a lot of = = text. Quite a = = bit of text, = = actually. Why = = would anyone = = have this much = = text to output? = ====================
Here's the code from GitHub:

0 comments:
Post a Comment