setcolor.exe

6 views
Skip to first unread message

Ronnie

unread,
Jan 27, 2009, 4:51:17 PM1/27/09
to Testoob
Can anyone tell me in which situations setcolor.exe is used?
(Which practical situation led to the development of this c program?)

Ronnie

Ori Peleg

unread,
Jan 27, 2009, 5:08:36 PM1/27/09
to tes...@googlegroups.com
Amir Szekely wrote it (http://kichik.net).
It's for color support on Windows terminals when the other options (ctypes or win32console) aren't available.

In windows you set the terminal colors with API calls to manipulate the terminal, not by printing control codes. The win32console module (part of pywin32) wraps this API, and like any other C API it's also available through ctypes.

For Python versions older than 2.5 that don't have pywin32 or ctypes, setcolor.exe is a workaround - a simple C program that manipulates the terminal, and Testoob uses to control colors.
--
Check out my blog: http://orip.org

Ronnie van 't Westeinde

unread,
Jan 28, 2009, 3:02:04 PM1/28/09
to tes...@googlegroups.com
In that case, may I suggest to rewrite the C program to take an integer or hex-number as argument and
offer a get function to retrieve the background color?

I'm working on a feature to use a blue warning color if testoob can autodetect a light background. 
(If autodetection is not possible, blue can be activated by setting the environment variable
TESTOOB_WARNING_COLOR to blue)

By making the above changes, I can put the logic of switching between blue and yellow as warning color
purely in Python.

Ronnie

Misha Seltzer

unread,
Jan 28, 2009, 3:08:44 PM1/28/09
to tes...@googlegroups.com
Instead of environment variable, I would suggest adding a command-line parameter --background=[light/dark].

In any case, we already support the ~/.testoobrc file, so you could just put this argument there, and it'll be default for you.
--
ɐɥsıɯ

Ronnie van 't Westeinde

unread,
Jan 28, 2009, 3:19:08 PM1/28/09
to tes...@googlegroups.com
That works for me too. I was never aware of the possibility of the ~/.testoobrc file, so that's why I was thinking
about the environment variable. It's definitely not an option I would like to specify every time I run testoob.

Ori Peleg

unread,
Jan 29, 2009, 9:09:06 AM1/29/09
to tes...@googlegroups.com
Good call about setcolor.exe, better to have it receive a code than to have it hard-coded to a specific set of colors.

Ronnie

unread,
Jan 30, 2009, 1:22:22 AM1/30/09
to Testoob
I've actually named the option --bgcolor, to avoid confusion with
background processes. The possible values are light, dark and auto.

Ronnie

On 28 jan, 21:08, Misha Seltzer <misha.selt...@gmail.com> wrote:
> Instead of environment variable, I would suggest adding a command-line
> parameter --background=[light/dark].
> In any case, we already support the ~/.testoobrc file, so you could just put
> this argument there, and it'll be default for you.
>
> On Wed, Jan 28, 2009 at 22:02, Ronnie van 't Westeinde <
>
>
>
> ronnie.van.t.westei...@gmail.com> wrote:
> > In that case, may I suggest to rewrite the C program to take an integer or
> > hex-number as argument andoffer a get function to retrieve the background
> > color?
>
> > I'm working on a feature to use a blue warning color if testoob can
> > autodetect a light background.
> > (If autodetection is not possible, blue can be activated by setting the
> > environment variable
> > TESTOOB_WARNING_COLOR to blue)
>
> > By making the above changes, I can put the logic of switching between blue
> > and yellow as warning color
> > purely in Python.
> > Ronnie
>
> > On Tue, Jan 27, 2009 at 11:08 PM, Ori Peleg <ori...@gmail.com> wrote:
>
> >> Amir Szekely wrote it (http://kichik.net).It'sfor color support on
> >> Windows terminals when the other options (ctypes or win32console) aren't
> >> available.
>
> >> In windows you set the terminal colors with API calls to manipulate the
> >> terminal, not by printing control codes. The win32console module (part of
> >> pywin32 <http://sourceforge.net/projects/pywin32/>) wraps this API, and
Reply all
Reply to author
Forward
0 new messages