Fixed some issues with getting the window size on linux

There were a couple of bugs in the linux implementation: (1) the ```env``` variable was not defined, and (2) there was not guarantee that the ```_getTerminalSize_linux``` function would have a window size so the tuple unpacking could have failed.

The changes will probably look larger than they really are. I put the query methods into a class so that I could easily check that I didn't break them. It seemed useful so I thought I would leave it that way. Mostly the changes are just to make the code a little easier to read (the ioctl interface does not make that easy), and changed the code to be more PEP8 compliant (http://www.python.org/dev/peps/pep-0008/)