From: John Nagle on
On 7/27/2010 7:44 AM, Bruno Desthuilliers wrote:
> Grant Edwards a �crit :
>> On 2010-07-27, Bruno Desthuilliers
>> <bruno.42.desthuilliers(a)websiteburo.invalid> wrote:
>>> Daniel Fetchinson a ?crit :
> (snip)
>>>> Why was clearing a terminal left out?
>>>>
>>> What you're talking about is a shell, not a terminal (a terminal is a
>>> physical device).
>>
>> No, what he's talking about is clearing a terminal (or a terminal
>> emulator). They both work the same, the only difference is whether
>> the terminal software is running on dedicated hardware or on
>> general-purpose hardware.
>
> (snip)
>
> I stand corrected.

I immediately thought of using the "curses" module, but that's
UNIX-only, or at least it's not in the ActiveState Python distro.

John Nagle
From: Grant Edwards on
On 2010-07-27, Daniel Fetchinson <fetchinson(a)googlemail.com> wrote:

> After getting the technicalities out of the way, maybe I should have asked:
>
> Is it only me or others would find a platform independent python API
> to clear the terminal useful?

I write a lot of command-line programs, and I can't remember the last
time time I wanted to clear a terminal. But then again, pretty much
all of my programs are designed so that they can be used as filters.

About 10 years ago I did need to do a text-mode UI (menus, popups,
text-entry, etc.), and I used newt.

--
Grant Edwards grant.b.edwards Yow! Is a tattoo real, like
at a curb or a battleship?
gmail.com Or are we suffering in
Safeway?
From: Terry Reedy on
On 7/27/2010 12:58 PM, Daniel Fetchinson wrote:

> After getting the technicalities out of the way, maybe I should have asked:
>
> Is it only me or others would find a platform independent python API
> to clear the terminal useful?

One problem is, Where would you put it? The OS module is for system
calls, mostly based on posix. The system call involved in clearing a
terminal is a write string call. *nix puts terminal control in a
separate library.

Another is, what next? clear_line? Pretty soon, we are back to curses.

Still another problem is that most of us do not have terminals; we have
screens and use them as such. OS-independent full-screen graphics/game
libraries have clear screen commands. Similary, GUI systems have means
of clearing text and canvas widgets, but should not be able to clear the
whole screen. The turtle module has a clear command for its canvas,
which would be the same regardless of underlying gui. So we already have
several OS independent clear commands.

On Windows, the DOS clr command only works withing a text-mode command
window (once called a dos window). The same thing (os.system('clr')
within an IDLE shell uselessly flashes a blank command window, which
then disappears. Yeah, it is too bad windows did not use the obvious
'clear' like everyone? else. If command windows still imitate or can be
set to imitate ansi terminals, then I would think curses is your best bet.

--
Terry Jan Reedy

From: Tim Harig on
On 2010-07-27, John Nagle <nagle(a)animats.com> wrote:
> On 7/27/2010 7:44 AM, Bruno Desthuilliers wrote:
>> Grant Edwards a �crit :
>>> On 2010-07-27, Bruno Desthuilliers
>>> <bruno.42.desthuilliers(a)websiteburo.invalid> wrote:
>>>> Daniel Fetchinson a ?crit :
>> (snip)
>>>>> Why was clearing a terminal left out?
>>>>>
>>>> What you're talking about is a shell, not a terminal (a terminal is a
>>>> physical device).
>>>
>>> No, what he's talking about is clearing a terminal (or a terminal
>>> emulator). They both work the same, the only difference is whether
>>> the terminal software is running on dedicated hardware or on
>>> general-purpose hardware.
>>
>> (snip)
>>
>> I stand corrected.
>
> I immediately thought of using the "curses" module, but that's
> UNIX-only, or at least it's not in the ActiveState Python distro.

pdcurses:

http://pdcurses.sourceforge.net/

is a cross platform curses implementation that is available for Windows.
I wonder how difficult it would be to embed into the Python curses module
as a backup for systems where curses is not natively available. This would
allow Python to provide cross platform charactor mode manipulation.
From: Ulrich Eckhardt on
Daniel Fetchinson wrote:
> After getting the technicalities out of the way, maybe I should have
> asked:
>
> Is it only me or others would find a platform independent python API
> to clear the terminal useful?

There are two kinds of programs:
1. Those that process input to output. If one of those suddenly started by
clearing my screen, I'd just dump it. Also, if output is redirected to a
file or piped into another program, that is basically useless or even
hurting, since you then end up with control sequences in the file.

2. Those that provide a text-based interactive UI. Those typically not only
clear the screen, but also control its whole layout and content, so there
you don't only need ways to clear the screen but also to position the
cursor or draw boxes etc. In that case you need a full "curses" library.

Summary: No, I don't see the need for such an API.

Cheers!

Uli

--
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932