Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Make screen clearing somewhat more portable #13
This may not merge perfectly with some of my other pull requests I've put in today - but it should be easy to resolve any conflicts. If you do like this change, and you like another of my change that conflicts, feel free to make me do a new pull request after you merge the other changes that you like.
Printing ANSI escape sequences to clear the screen breaks several things - Strawberry Perl on Win32, non-standard terminals, dumb terminals, and pipes/redirection of the output. I made the clear screen call a function - _cls() - and use Term::Cap (a core module) to get the clear code. If the program is not connected to a terminal (redirected output, for instance), if the terminal isn't known to Term::Cap, or if the terminal is particularly dumb (TERM=dumb), two newlines are printed instead.
I do cache the clear screen code, which probably isn't necessary, but it's a little nicer as far as performance.
This is the last pull request I'm submitting based on the things I saw in the module that I thought I could help with - feel free to give me feedback if you like these ideas but would like to do them a different way, I definitely want this work to fit into your desires for the module.