-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Roll back change vendoring of colorama. (#5460)
* Roll back change vendoring of colorama. * Add back colorama version that worked. * Add news fragment.
- Loading branch information
Showing
14 changed files
with
800 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Rollback the change in version of ``colorama`` due to regressions in core functionality. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Copyright (c) 2010 Jonathan Hartley | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of the copyright holders, nor those of its contributors | ||
may be used to endorse or promote products derived from this software without | ||
specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. | ||
from .initialise import init, deinit, reinit, colorama_text | ||
from .ansi import Fore, Back, Style, Cursor | ||
from .ansitowin32 import AnsiToWin32 | ||
|
||
__version__ = '0.4.4' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. | ||
''' | ||
This module generates ANSI character codes to printing colors to terminals. | ||
See: http://en.wikipedia.org/wiki/ANSI_escape_code | ||
''' | ||
|
||
CSI = '\033[' | ||
OSC = '\033]' | ||
BEL = '\a' | ||
|
||
|
||
def code_to_chars(code): | ||
return CSI + str(code) + 'm' | ||
|
||
def set_title(title): | ||
return OSC + '2;' + title + BEL | ||
|
||
def clear_screen(mode=2): | ||
return CSI + str(mode) + 'J' | ||
|
||
def clear_line(mode=2): | ||
return CSI + str(mode) + 'K' | ||
|
||
|
||
class AnsiCodes(object): | ||
def __init__(self): | ||
# the subclasses declare class attributes which are numbers. | ||
# Upon instantiation we define instance attributes, which are the same | ||
# as the class attributes but wrapped with the ANSI escape sequence | ||
for name in dir(self): | ||
if not name.startswith('_'): | ||
value = getattr(self, name) | ||
setattr(self, name, code_to_chars(value)) | ||
|
||
|
||
class AnsiCursor(object): | ||
def UP(self, n=1): | ||
return CSI + str(n) + 'A' | ||
def DOWN(self, n=1): | ||
return CSI + str(n) + 'B' | ||
def FORWARD(self, n=1): | ||
return CSI + str(n) + 'C' | ||
def BACK(self, n=1): | ||
return CSI + str(n) + 'D' | ||
def POS(self, x=1, y=1): | ||
return CSI + str(y) + ';' + str(x) + 'H' | ||
|
||
|
||
class AnsiFore(AnsiCodes): | ||
BLACK = 30 | ||
RED = 31 | ||
GREEN = 32 | ||
YELLOW = 33 | ||
BLUE = 34 | ||
MAGENTA = 35 | ||
CYAN = 36 | ||
WHITE = 37 | ||
RESET = 39 | ||
|
||
# These are fairly well supported, but not part of the standard. | ||
LIGHTBLACK_EX = 90 | ||
LIGHTRED_EX = 91 | ||
LIGHTGREEN_EX = 92 | ||
LIGHTYELLOW_EX = 93 | ||
LIGHTBLUE_EX = 94 | ||
LIGHTMAGENTA_EX = 95 | ||
LIGHTCYAN_EX = 96 | ||
LIGHTWHITE_EX = 97 | ||
|
||
|
||
class AnsiBack(AnsiCodes): | ||
BLACK = 40 | ||
RED = 41 | ||
GREEN = 42 | ||
YELLOW = 43 | ||
BLUE = 44 | ||
MAGENTA = 45 | ||
CYAN = 46 | ||
WHITE = 47 | ||
RESET = 49 | ||
|
||
# These are fairly well supported, but not part of the standard. | ||
LIGHTBLACK_EX = 100 | ||
LIGHTRED_EX = 101 | ||
LIGHTGREEN_EX = 102 | ||
LIGHTYELLOW_EX = 103 | ||
LIGHTBLUE_EX = 104 | ||
LIGHTMAGENTA_EX = 105 | ||
LIGHTCYAN_EX = 106 | ||
LIGHTWHITE_EX = 107 | ||
|
||
|
||
class AnsiStyle(AnsiCodes): | ||
BRIGHT = 1 | ||
DIM = 2 | ||
NORMAL = 22 | ||
RESET_ALL = 0 | ||
|
||
Fore = AnsiFore() | ||
Back = AnsiBack() | ||
Style = AnsiStyle() | ||
Cursor = AnsiCursor() |
Oops, something went wrong.