Re: [Tutor] ANSI / VT100 Escape Codes in Windows 7 Environment

2019-02-28 Thread Chip Wachob
Wow!  What a treasure of information.

>From the looks of it, I'm going to give colorama a try.  It seems like it
will do what I want to do, and, if I'm reading the documentation correctly,
it will work cross platform.  Ie: if I am in Linux, it will simply be
ignored.  And, it appears to interpret the ANSI codes (\033[xxxm) when it
comes to Windows...

As an aside, I enjoyed the trip down memory lane.  I still have my Hercules
graphics card and my AMBER monitor for my 286 machine.  You know, the
machine that has two full-height HDD with an MFM interface and provides a
combined 20Mbyte of storage space! And of course a math co-processor...  I
no longer recall how many Kbytes of onboard memory I had, maybe 1024...   :)

Thank you so much for sharing your insights.

Best,


On Wed, Feb 27, 2019 at 9:40 PM boB Stepp  wrote:

> On Wed, Feb 27, 2019 at 6:50 PM Chip Wachob  wrote:
> >
> > Hello again,
> >
> > As always, this list has been very helpful, and thank you.
> >
> > So, I thought I was good to go until I attempted to run my code on a
> > Windows 7 vintage machine this morning.  The application is intended to
> be
> > run in the command window in Windows, from the terminal in Linux...
> >
> > In the code I had included the ANSI escape characters so I could invert
> the
> > text and change the color.  Basically, I wanted to make the warning /
> error
> > messages stand out from the crowd.
>
> As I have been on a "curses" kick lately, I wonder if it would work
> for you?  Of course this means another module, but it is in the
> standard lib on all non-Windows Python versions.  For Windows I found
> this thread on stackoverflow:
>
>
> https://stackoverflow.com/questions/32417379/what-is-needed-for-curses-in-python-3-4-on-windows7
>
> The checked answer gives a link to binaries for Windows, which seems
> to support all Python versions through 3.7, including 2.7.
>
> Just a thought...
>
> --
> boB
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] ANSI / VT100 Escape Codes in Windows 7 Environment

2019-02-27 Thread boB Stepp
On Wed, Feb 27, 2019 at 6:50 PM Chip Wachob  wrote:
>
> Hello again,
>
> As always, this list has been very helpful, and thank you.
>
> So, I thought I was good to go until I attempted to run my code on a
> Windows 7 vintage machine this morning.  The application is intended to be
> run in the command window in Windows, from the terminal in Linux...
>
> In the code I had included the ANSI escape characters so I could invert the
> text and change the color.  Basically, I wanted to make the warning / error
> messages stand out from the crowd.

As I have been on a "curses" kick lately, I wonder if it would work
for you?  Of course this means another module, but it is in the
standard lib on all non-Windows Python versions.  For Windows I found
this thread on stackoverflow:

https://stackoverflow.com/questions/32417379/what-is-needed-for-curses-in-python-3-4-on-windows7

The checked answer gives a link to binaries for Windows, which seems
to support all Python versions through 3.7, including 2.7.

Just a thought...

-- 
boB
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] ANSI / VT100 Escape Codes in Windows 7 Environment

2019-02-27 Thread eryk sun
On 2/27/19, Alan Gauld via Tutor  wrote:
> On 27/02/2019 18:28, Chip Wachob wrote:
>> Windows 7 vintage machine this morning.
>
> Caveat: I have no direct experience on Windows 7 - I jumped
> from XP to Windows 8... Also I haven't used ANSIO codes in
> Windows since the heady days of Windows 98! But...
>
>> run in the command window in Windows, from the terminal in Linux...
>
> Be aware that ANSI codes in DOS don't correspond directly
> with the VT100 control codes commonly used in Linux etc.
> You might get some things that either don;t work or work
> slightly differently.
>
>> In the code I had included the ANSI escape characters so I could invert
>> the
>> text and change the color.
>
> Again remember that old ANSI terminals didn't have colors.
> (They were either green on black, white on black, or if you
> were really fancy, amber on black).
>
> Color came later so some terminal emulators won't do anything
> with those codes.
>
>> As I have now learned, Windows 7 does not support this functionality.
>> What do the experts out there suggest as the path of least pain and
>> suffering?
>
> No idea if this works on Windows 7 but what we used to have
> to do was load the ANSI.SYS driver in the CONFIG.SYS file
> located in the root directory of the boot drive.

Windows NT systems use the Windows console API, which talks to a
console that's hosted in a system process. In Windows 7+, each console
is hosted in an instance of conhost.exe. In older versions of NT,
consoles are hosted by threads in the session server process,
csrss.exe.

In 32-bit builds of NT, there's integration between the console and
the virtual DOS machine (ntvdm.exe). This allows running old 16-bit
DOS programs/drivers such as COMMAND.COM and ANSI.SYS in an emulated
DOS environment. 64-bit builds no longer support NTVDM. Anyway, it
wouldn't apply to Windows console applications such as python.exe,
which have nothing to do with DOS.

The only practical option is to implement VT sequences using the
console API, such as is done by the colorama package. Other options
require installing an alternate console (e.g. ConEmu) or a program
that hacks the console API in each process via DLL injection (e.g.
ANSICON).
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] ANSI / VT100 Escape Codes in Windows 7 Environment

2019-02-27 Thread eryk sun
On 2/27/19, Chip Wachob  wrote:
>
> I've been spending the morning looking at different solutions.  Many of
> them seem to involve either including yet aother module, or, worse (IMHO) a
> C library that will 'emulate' the ANSI escape sequences, API calls, etc.

To support virtual-terminal sequences prior to Windows 10, you'll need
a package such as colorama [1] that implements VT sequences in terms
of the Windows console API -- unless you're willing to require an
alternate console such as ConEmu or an API hack such as ANSICON.

[1]: https://pypi.org/project/colorama
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] ANSI / VT100 Escape Codes in Windows 7 Environment

2019-02-27 Thread Alan Gauld via Tutor
On 27/02/2019 18:28, Chip Wachob wrote:
> Windows 7 vintage machine this morning. 

Caveat: I have no direct experience on Windows 7 - I jumped
from XP to Windows 8... Also I haven't used ANSIO codes in
Windows since the heady days of Windows 98! But...

> run in the command window in Windows, from the terminal in Linux...

Be aware that ANSI codes in DOS don't correspond directly
with the VT100 control codes commonly used in Linux etc.
You might get some things that either don;t work or work
slightly differently.

> In the code I had included the ANSI escape characters so I could invert the
> text and change the color. 

Again remember that old ANSI terminals didn't have colors.
(They were either green on black, white on black, or if you
were really fancy, amber on black).

Color came later so some terminal emulators won't do anything
with those codes.

> As I have now learned, Windows 7 does not support this functionality.
> What do the experts out there suggest as the path of least pain and
> suffering?

No idea if this works on Windows 7 but what we used to have
to do was load the ANSI.SYS driver in the CONFIG.SYS file
located in the root directory of the boot drive.

A quick Google suggests that Windows supports config.nt
as a replacement for CONFIG.SYS.

Try creating such a file (or editing the existing one) with the line

DEVICE=ANSI.SYS

And see if that helps. (You might need a reboot or at
least a restart of the console)

Also it seems that the 32 bit version of ANSI.SYS does not support
cursor positioning. But if you only want bold/flashing/underlined
text in differing colors you should be OK...


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] ANSI / VT100 Escape Codes in Windows 7 Environment

2019-02-27 Thread Chip Wachob
Hello again,

As always, this list has been very helpful, and thank you.

So, I thought I was good to go until I attempted to run my code on a
Windows 7 vintage machine this morning.  The application is intended to be
run in the command window in Windows, from the terminal in Linux...

In the code I had included the ANSI escape characters so I could invert the
text and change the color.  Basically, I wanted to make the warning / error
messages stand out from the crowd.

Eg:
# there's an error in the loop, report it
# format reverse with yellow background
print "\033[7m\033[33m"
print " ERROR IN LOOP SIZE"
.
.
.
# clear formatting
print "\033[m"

As I have now learned, Windows 7 does not support this functionality.
Development had been done on a Windows 10 (and Ubuntu) machine where this
worked just fine.

I've been spending the morning looking at different solutions.  Many of
them seem to involve either including yet aother module, or, worse (IMHO) a
C library that will 'emulate' the ANSI escape sequences, API calls, etc.

Before I go tearing into my currently working code, I'm looking for
feedback from those much more experienced.

I need this code to run correctly on both Windows 7 and 10 (future Linux)
and I'm stuck with Python 2.7 due to other module limitations.

What do the experts out there suggest as the path of least pain and
suffering?

Again, thank you for your time and guidance.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor