Why is there no platform independent way of clearing a terminal?

T

Thomas Jollans

Ah, I should have spotted that. Of course. Thanks for the
enlightenment.

And Neil Cerutti, I think I'll just email the whole source tree to
myself, and have a script that scans my inbox, unzips source trees and
runs their tests. Much nicer. :)

use version control! Use mercurial, commit often, and add a commit-hook
that runs tests. Then you can even set up a separate repository that
your script automatically pushes your changes to if they pass the tests
cleanly.
 
N

Neil Cerutti

And Neil Cerutti, I think I'll just email the whole source tree
to myself, and have a script that scans my inbox, unzips source
trees and runs their tests. Much nicer. :)

Don't forget to clear the screen, though. That ties the whole
program together.
 
T

Tim Harig

It might be possible to write a curses-compatible library that works
with cmd.exe. Maybe. But, even if it's possible, I don't think it's
easy, and I especially don't think it would be particularly rewarding.

http://pdcurses.sourceforge.net/

It would be rewarding as it would make writing cross-platform charactor
mode applications possible. Using curses for the interface makes a lot of
sense because it is already supported by almost every Unix/POSIX platorm,
so re-implementation is only required for those odd platforms (Windows)
where it does not exist natively,; because well documented on the internet
and in print; and because a huge number of people are already familiar with
its API.

If licensing permits, I don't think it would be too difficult difficult to
embed something like pdcurses into the existing curses module to use as a
backup for platforms where curses does not already exist. If not, there
cannot be much difference to writing a terminal emulator that runs inside
the windows console and there are a *huge* number of terminal emulators
available for ansi/vt100 terminals. Add a termcap database mechanism and
an embedded emulator can easily convert the excape codes into actions for
the console.
 
M

Martin Gregorie

Also, is it crazy to imagine that if colorama was pushed through to
completion (ie. to support a majority of the relevant ANSI codes) then
Python's stdlib curses module, unmodified, would suddenly just work on
Windows? (after a call to 'colorama.init()')
Curses was originally built on top of termcap, a much simpler and more
primitive library. Its abilities are:
- read the termcap database to find and load the capability list
of the terminal identified as the TERM environment variable.
- write a named capability to the screen. If the capability isn't
defined for the current terminal its silently ignored.
- fill in x, y and write the cursor movement string
- thats about it.

Its easy enough to find termcap databases. They're just text files
containing a block of attribute values for each terminal, normally
including ANSI terminals, Linux consoles, X-terms etc. They are also
fairly easy to parse, even in vanilla C, so parsing one on Python should
be a breeze. Termcap format specs and lists of standard attribute names
are easy enough to find too.

IOW, if you extend colorama to read its codes from a termcap database
you'll have a basic but easily portable character console handler that
can at least clear the screen, move the cursor and, if the screen has the
capability, change the colour of characters or make them bold/dim/blink
etc.

To give you an idea of how complex this is, I've re-implemented termcap
in Java for my own purposes. It amounts to 1100 lines of fairly well
spaced and commented Java or about 340 statements, which were estimated
by counting lines containing semicolons.
 
U

Ulrich Eckhardt

Neil said:
Perhaps emailing the tests to yourself would be a good solution.
Every tme the tests ran, you'd get a new email containing the
results.

Nice idea, only that it's even less portable and requires manual setup...

;^)

Uli
 
L

Lawrence D'Oliveiro

Daniel said:
Sure, there are many different terminals and many different operating
systems but in many areas python managed to hide all these complexities
behind a well defined API.

Once upon a time, there were indeed many different kinds of actual physical
terminals.

However, they are all extinct now. All that’s left is software emulations.
And the one emulation they all have in common is the DEC VT100.

So just assume you’re displaying on one of those:

sys.stdout.write("\x1b[2J")
 
L

Lawrence D'Oliveiro

It would be rewarding as it would make writing cross-platform charactor
mode applications possible.

I thought Windows users were allergic to command lines.
 
L

Lawrence D'Oliveiro

Emile van said:
If all else fails, repeating 24 (or 40,60?) lines feeds clears the
screen cross platform.

Depending on the height of the terminal window...
 
T

Tim Harig

I thought Windows users were allergic to command lines.

To the best of my knowledge, there have never been any documentated
cases of computer software related alleries. There are however several
chemicals used in the process of constructing computer hardware componets
which have been linked to allergy illnesses. Maybe Windows users are
simply allergic to their computers.
 
M

Mark Lawrence

To the best of my knowledge, there have never been any documentated
cases of computer software related alleries. There are however several
chemicals used in the process of constructing computer hardware componets
which have been linked to allergy illnesses. Maybe Windows users are
simply allergic to their computers.

Windows users biggest allergy is to this strange world that involves
"make" on other boxes, whatever that is, it strikes me as rather
archaic. Personally I find double clicking on an msi file rather easier.

Regards.

Mark Lawrence.
 
L

Lawrence D'Oliveiro

Mark said:
I'm sorry but I only do English, could you please translate. :)

I run Debian Unstable, which has new goodies coming out on a weekly basis.
The last time I checked for updates, there were over 500 packages I had
installed for which updates were available. It only took a command like the
above to upgrade them all.

How many .msi files would you have to click on to achieve the Windows
equivalent?
 
M

Mark Lawrence

I run Debian Unstable, which has new goodies coming out on a weekly basis.
The last time I checked for updates, there were over 500 packages I had
installed for which updates were available. It only took a command like the
above to upgrade them all.

How many .msi files would you have to click on to achieve the Windows
equivalent?

No idea, but your mental capacity is clearly infinitely higher than
mine, as I simply couldn't cope with over 500 installed packages. What
do they all do, make your lunch and fetch the beer from the fridge
amongst other things?

Cheers.

Mark Lawrence.
 
G

Gregory Ewing

Lawrence said:
How many .msi files would you have to click on to achieve the Windows
equivalent?

Don't you just leave the machine on overnight and wait
for Microsoft to download all the stuff they think
you should be using?
 
L

Lawrence D'Oliveiro

Don't you just leave the machine on overnight and wait
for Microsoft to download all the stuff they think
you should be using?

That’s fine, but it doesn’t handle the non-Microsoft stuff.
 
T

Tim Harig

Windows users biggest allergy is to this strange world that involves
"make" on other boxes, whatever that is, it strikes me as rather
archaic. Personally I find double clicking on an msi file rather easier.

I work with several thousand computers located on three different
continents. Few of them have mice attached to them. If you think double
clicking is a better method, be my guest; but, you need to get a package
installed and configured on all of them before lunch.

Its also kind of funny that I couldn't get the msi to work with a large
percentage of the systems that I work with. Make works on all but one out
of the box, and potentially on the last with the addition of SFU or
Cygwin.

With all that said, I am still not sure what the make/msi question has
anything to do with packing a backup, cross platform, implementation of
curses that allows the curses module to give Python a cross platform method
of character mode manipulation.
 
R

Roy Smith

Lawrence D'Oliveiro said:
That’s fine, but it doesn’t handle the non-Microsoft stuff.

You've apparently never worked in a big company. Your IT department
downloads whatever *they* think you should be using. Eventually, your
machine is so slow, you can't get any work done.
 
M

Mark Lawrence

Precisely my point. Go back to playing with your .msi toys.

Oh, and<http://dilbert.com/strips/comic/1995-06-24/>.

Repeating what was obviously deliberately snipped.

"No idea, but your mental capacity is clearly infinitely higher than
mine, as I simply couldn't cope with over 500 installed packages. What
do they all do, make your lunch and fetch the beer from the fridge
amongst other things?"

How does any user or an admin cope with 500 packages? Can Python help
here, assume an eight hour working day?

c:\Python31\Lib>python
Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.57.6

So every working day you have 57.6 seconds to use each package.
Strangely I don't think anyone will get too much done. Am I in cloud
cuckoo land or are you?

As it happens, I'm also not a windows fan, did most of my work on VMS.
Which to repeat myself stands for Very Much Safer. Thinking of which
did *nix ever get around to providing proper clustering, or does VMS
still rule?

Mark Lawrence.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top