spangey / miniboa

Automatically exported from code.google.com/p/miniboa
Apache License 2.0
0 stars 0 forks source link

Text wrapping method #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I have noticed that you do not use native Python wrapping function in
xterm.py. Is there any specific reason?

It's just a suggestion but You could do something similar to:

        content = file.read() #suppose that text is read from file
        paragraph_list = content.split("\n") #split it to paragraphs
        content_list = []
        for paragraph in paragraph_list:
            if not paragraph: #to handle empty new lines
                content_list1.append(" ")
            else:
                content_list.extend(textwrap.wrap(paragraph)) #split
paragraphs and put them again to the list
        wrapped_content = "\n\r".join(content_list1) #make string back but
with new line endings

Original issue reported on code.google.com by mich.mierzwa@gmail.com on 5 Feb 2010 at 3:05