Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

line wrapping / formatting answer #21

Closed
ghost opened this issue Jan 9, 2013 · 3 comments
Closed

line wrapping / formatting answer #21

ghost opened this issue Jan 9, 2013 · 3 comments

Comments

@ghost
Copy link

ghost commented Jan 9, 2013

Love this tools :)

It would gain a lot of readability if the output would wrap the line at a given width - or is there a way to force that? at this point the output cut whatever word in order to move to next line.

thanks!

@gleitz
Copy link
Owner

gleitz commented Jan 11, 2013

Good idea. I wonder if there is a way to determine the terminal size in Python...

$ howdoi determine console width in python
import console
(width, height) = console.getTerminalSize()

print "Your terminal's width is: %d" % width

Given that we know the console width what is the best place to break the text? Perhaps we would wrap at 80 chars unless the console was <80 characters wide? We would also have to know the terminal font size to determine how many characters fit on a line.

@ghost
Copy link
Author

ghost commented Jan 12, 2013

I think 80 columns would be a good start, I also like the formating for man pages, where there is also some paddings on both side of the text.

@gleitz
Copy link
Owner

gleitz commented Jan 19, 2013

Leaving this here as it appears to be a good code snippet for getting the terminal size in an OS agnostic way.

https://github.com/Steve-V/python_homework/blob/master/assignment1/getTerminalSize.py

@gleitz gleitz closed this as completed Sep 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant