I’m always surprised when I google a code recipe* and don’t find any corresponding blog posts or StackOverflow questions. It’s like the internet is incomplete or something. Here’s my homebaked implementation of word wrap in curses:
It’s not going to be as clever about wrapping as Python’s textwrap library, but that lib is only suitable if we’re writing big tracts of text all at once. With curses, you often want to add strings incrementally, bolding or underlining certain words along the way.
If anyone has an answer to the #TODO above, please ping me.
*How awesome would "The Joy of Coding" be as a title for a blog or a book of code recipes? And if you could emulate the iconic "Joy of Cooking" typography? Man. Someone's probably done this.