robpol86 / colorclass Goto Github PK
View Code? Open in Web Editor NEWColorful worry-free console applications for Linux, Mac OS X, and Windows.
License: MIT License
Colorful worry-free console applications for Linux, Mac OS X, and Windows.
License: MIT License
tests/test_width_and_alignment.py:16: in <module>
(Color('{autoblue}世界你好{/autoblue}'), 8),
.tox/py26/lib/python2.6/site-packages/colorclass.py:391: in __new__
obj = parent_class.__new__(cls, *args, **kwargs)
E UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 5: ordinal not in range(128)
>>> print(colorclass.Color('{red}XXX: {/red}{}').format('{green}moo{/green}'))
XXX: moo
Expected: XXX: {green}moo{/green}
(with XXX:
in red)
Actual: XXX: moo
(with XXX:
in red and moo
in green)
This is especially annoying since it means one cannot use the Color
class without the tag parsing.
http://www.nivot.org/blog/post/2016/02/04/Windows-10-TH2-%28v1511%29-Console-Host-Enhancements
https://msdn.microsoft.com/en-us/library/ms683167.aspx
https://msdn.microsoft.com/en-us/library/mt638032.aspx
Looks like (compared to archive.org) ENABLE_VIRTUAL_TERMINAL_PROCESSING (0x0004) was recently added to GetConsoleMode (and set). Perhaps I can use this to determine if stdout/stderr streams should not be replaced on Windows, instead of having users of colorclass figure it out themselves?
Looks like using atexit isn't actually resetting the console's background color.
Fixed it in "windows" branch, but need to fully test in my VMs first.
It's probably me being silly and it using it correctly, but from what i could gather from the docs, calling it anywhere should just disable all colors;
>>> from colorclass import disable_all_colors
>>> print string
←[31mbla←[39m
>>> disable_all_colors()
>>> print string
←[31mbla←[39m
>>>
What am I doing wrong? tried it both on Windows 7, 10 and Ubuntu...
For packaging, it is useful to run the tests from the source tarball to verify the packaging is correct.
Python 2.7.13 (default, Jul 24 2017, 20:13:18)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from colorclass import Color
>>> s = 'This is a test string ...'
>>> c = Color('{autogreen}This is a test string ...{/autogreen}')
>>> print s
This is a test string ...
>>> print c
This is a test string ...
>>> print s[:14]
This is a test
>>> print c[:14]
This is a
# work around
>>> print c.value_colors.replace(c.value_no_colors, c.value_no_colors[:14])
This is a test
It seems some ssh clients under windows don't respect the color settings.
I am not familiar about how to show color in terminal. Can you give me a hint?
I'm on Windows 10 (64bit), Python 3.5.1.
Calling Windows.enable()
as per documentation actually doesn't show the colors (although it does parse the string correctly). Commenting it out yields the correct behaviour.
len(Color("").join([Color("{red}ABC{/red}")])) != 3
it makes composing 'Color' strings really inconvenient
As the title says, the current version is incompatible with f strings in Python 3.6.
>>> print(Color("{autored}hi{/red}"))
hi
>>> print(Color(f"{autored}hi{/red}"))
File "<fstring>", line 1
(/red)
^
SyntaxError: invalid syntax
First, congratulate your work!
I wonder if there is any way to put the text bold or underlined.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.