feluxe/sty

Not working in windows 10

outcastdreamer opened this issue ยท 13 comments

I tried the example codes in python3 running in my cmd in windows 10 but it doesn't print the string which I have mentioned as show n in the screenshot. Kindly find a solution for this!!
hmm

its not really a fix, but the portable CMD program called cmder works with the sty color codes:

sty with cmder

@sharkbound This is good news. cmder really looks promising, I'm glad it works with sty. Thanks for pointing this out!

@outcastdreamer I got myself a windows license. I'll investigate this in a VM.

I got it to work by importing init from colorama. Like this:
from colorama import init
init()

I got it to work by importing init from colorama. Like this:
from colorama import init
init()

With this it works perfect ! thanks @Nikedi

I'm planning to add windows support via the Environments & Feature Sets interface. This will offer a way to get windows compatible register-objects (fg, bg, etc.). It'll make use of sty's customization abilities and unlike colorama.init() it will not alter the terminal session globally (like reported here #15).

I'll add Environments & Feature Sets to sty as soon as I'm certain about the interface for it.

mcaay commented

Noticed interesting things using cmder.
If you use colorama to "make it work on windows" it acutally blocks some functionalities, like assigning 8 bit colors to your custom names.
sty windows cmder
And either way, 8 bit colors get approximated to one of the few SGR (?) colors (here it outputs red, while it should be orange).

@mcaay Thanks for posting this.

If you use colorama to "make it work on windows" it acutally blocks some functionalities, like assigning 8 bit colors to your custom names.

I guess this is related to #15. When #16 is done, we can omit colorama.init() and the issues that come with it.

And either way, 8 bit colors get approximated to one of the few SGR (?) colors (here it outputs red, while it should be orange).

Some terminals do that as a way to support 8bit color and RGB (true color) ANSI sequences.

Microsoft announced that Windows gets a new Terminal: https://devblogs.microsoft.com/commandline/introducing-windows-terminal

Let's hope it's compatible to the ANSI sequences that most other terminals use.

@feluxe i hope so, right now as it is, windows terminals is a mess of what is best for the job, sometimes you need GIT shell, sometimes CMDER, powershell, cmd, ect.

i hope this new one will be a one-in-all solution

@feluxe
@mcaay
@sharkbound

If you use colorama to "make it work on windows" it actually blocks some functionalities, like assigning 8 bit colors to your custom names.

You don't need to use the colorama module to make it work on windows.

If you add this near the top, then sty works on cmd (and cmder) and doesn't block any functionalities:

import os, sys
if sys.platform == "win32":
    os.system('color')

Better fix: #2 (comment)

@SimpleBinary This is great! Thanks for leaving this here. I just tried and it seems to work very well. With this fix cmd even supports 8bit and RGB colors. I linked your comment in the docs/README.

I close this issue, because @SimpleBinary solution seems nice. Plus, the new Windows Terminal will hopefully soon be shipped and I'm sure it will work with sty out of the box.

Thanks to everyone for your helpful comments!

The "new Windows Terminal" is only available on Windows 10, so other users of Windows are booted out.

@feluxe Actually, an even better fix is available:

import os

os.system("")

It doesn't actually require the color call, and with the blank call, no sys module is needed.