libv8 7.3.492.27.3beta1 → 7.4.288.28.0beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/lib/libv8/version.rb +1 -1
- data/vendor/depot_tools/annotated_gclient.py +4 -2
- data/vendor/depot_tools/auth.py +2 -0
- data/vendor/depot_tools/autoninja +3 -1
- data/vendor/depot_tools/autoninja.bat +1 -1
- data/vendor/depot_tools/autoninja.py +3 -1
- data/vendor/depot_tools/bb +1 -1
- data/vendor/depot_tools/bootstrap/win/manifest.txt +1 -1
- data/vendor/depot_tools/buildbucket.py +8 -6
- data/vendor/depot_tools/checkout.py +7 -5
- data/vendor/depot_tools/cipd +1 -1
- data/vendor/depot_tools/cipd_manifest.txt +4 -4
- data/vendor/depot_tools/cipd_manifest.versions +80 -80
- data/vendor/depot_tools/cit.py +9 -7
- data/vendor/depot_tools/clang_format.py +4 -1
- data/vendor/depot_tools/clang_format_merge_driver.py +9 -7
- data/vendor/depot_tools/compile_single_file.py +3 -1
- data/vendor/depot_tools/dart_format.py +4 -2
- data/vendor/depot_tools/depot-tools-auth.py +10 -8
- data/vendor/depot_tools/fix_encoding.py +5 -2
- data/vendor/depot_tools/gclient-new-workdir.py +2 -0
- data/vendor/depot_tools/gclient.py +8 -9
- data/vendor/depot_tools/gclient_scm.py +54 -28
- data/vendor/depot_tools/gclient_utils.py +14 -4
- data/vendor/depot_tools/gerrit_util.py +8 -6
- data/vendor/depot_tools/git_cache.py +53 -37
- data/vendor/depot_tools/git_cl.py +115 -42
- data/vendor/depot_tools/git_drover.py +3 -1
- data/vendor/depot_tools/git_find_releases.py +8 -6
- data/vendor/depot_tools/git_footers.py +7 -5
- data/vendor/depot_tools/git_freezer.py +3 -1
- data/vendor/depot_tools/git_map_branches.py +7 -5
- data/vendor/depot_tools/git_mark_merge_base.py +8 -6
- data/vendor/depot_tools/git_nav_downstream.py +7 -5
- data/vendor/depot_tools/git_number.py +3 -1
- data/vendor/depot_tools/git_rebase_update.py +38 -43
- data/vendor/depot_tools/git_reparent_branch.py +8 -6
- data/vendor/depot_tools/git_upstream_diff.py +4 -2
- data/vendor/depot_tools/gn.py +6 -4
- data/vendor/depot_tools/infra/config/recipes.cfg +1 -1
- data/vendor/depot_tools/led +1 -1
- data/vendor/depot_tools/luci-auth +1 -1
- data/vendor/depot_tools/lucicfg +1 -1
- data/vendor/depot_tools/mac_toolchain +1 -1
- data/vendor/depot_tools/man/html/depot_tools.html +1 -1
- data/vendor/depot_tools/man/html/depot_tools_tutorial.html +28 -22
- data/vendor/depot_tools/man/html/git-cl.html +1 -1
- data/vendor/depot_tools/man/html/git-drover.html +18 -18
- data/vendor/depot_tools/man/html/git-footers.html +1 -1
- data/vendor/depot_tools/man/html/git-freeze.html +3 -3
- data/vendor/depot_tools/man/html/git-hyper-blame.html +1 -1
- data/vendor/depot_tools/man/html/git-map-branches.html +2 -2
- data/vendor/depot_tools/man/html/git-map.html +1 -1
- data/vendor/depot_tools/man/html/git-mark-merge-base.html +1 -1
- data/vendor/depot_tools/man/html/git-nav-downstream.html +3 -3
- data/vendor/depot_tools/man/html/git-nav-upstream.html +12 -6
- data/vendor/depot_tools/man/html/git-new-branch.html +1 -1
- data/vendor/depot_tools/man/html/git-rebase-update.html +20 -1
- data/vendor/depot_tools/man/html/git-rename-branch.html +1 -1
- data/vendor/depot_tools/man/html/git-reparent-branch.html +1 -1
- data/vendor/depot_tools/man/html/git-retry.html +1 -1
- data/vendor/depot_tools/man/html/git-squash-branch.html +1 -1
- data/vendor/depot_tools/man/html/git-thaw.html +1 -1
- data/vendor/depot_tools/man/html/git-upstream-diff.html +10 -6
- data/vendor/depot_tools/man/man1/git-cl.1 +4 -4
- data/vendor/depot_tools/man/man1/git-drover.1 +21 -21
- data/vendor/depot_tools/man/man1/git-footers.1 +4 -4
- data/vendor/depot_tools/man/man1/git-freeze.1 +6 -6
- data/vendor/depot_tools/man/man1/git-hyper-blame.1 +4 -4
- data/vendor/depot_tools/man/man1/git-map-branches.1 +4 -4
- data/vendor/depot_tools/man/man1/git-map.1 +4 -4
- data/vendor/depot_tools/man/man1/git-mark-merge-base.1 +4 -4
- data/vendor/depot_tools/man/man1/git-nav-downstream.1 +6 -6
- data/vendor/depot_tools/man/man1/git-nav-upstream.1 +15 -9
- data/vendor/depot_tools/man/man1/git-new-branch.1 +3 -3
- data/vendor/depot_tools/man/man1/git-rebase-update.1 +14 -4
- data/vendor/depot_tools/man/man1/git-rename-branch.1 +4 -4
- data/vendor/depot_tools/man/man1/git-reparent-branch.1 +4 -4
- data/vendor/depot_tools/man/man1/git-retry.1 +4 -4
- data/vendor/depot_tools/man/man1/git-squash-branch.1 +4 -4
- data/vendor/depot_tools/man/man1/git-thaw.1 +4 -4
- data/vendor/depot_tools/man/man1/git-upstream-diff.1 +7 -13
- data/vendor/depot_tools/man/man7/depot_tools.7 +4 -4
- data/vendor/depot_tools/man/man7/depot_tools_tutorial.7 +33 -27
- data/vendor/depot_tools/man/src/filter_demo_output.py +3 -1
- data/vendor/depot_tools/man/src/git-rebase-update.txt +7 -0
- data/vendor/depot_tools/my_activity.py +13 -11
- data/vendor/depot_tools/my_reviews.py +34 -29
- data/vendor/depot_tools/ninjalog_uploader_wrapper.py +4 -2
- data/vendor/depot_tools/owners_finder.py +3 -1
- data/vendor/depot_tools/patch.py +1 -1
- data/vendor/depot_tools/post_build_ninja_summary.py +17 -15
- data/vendor/depot_tools/presubmit_canned_checks.py +3 -1
- data/vendor/depot_tools/presubmit_support.py +10 -5
- data/vendor/depot_tools/prpc +1 -1
- data/vendor/depot_tools/recipes/README.recipes.md +17 -17
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail.json +1 -6
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json +2 -4
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch_download.json +1 -6
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/unrecognized_commit_repo.json +0 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-failed.json +2 -4
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_file.json +25 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_mode.json +23 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_verfile.json +23 -5
- data/vendor/depot_tools/recipes/recipe_modules/gclient/config.py +0 -6
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.py +0 -1
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.expected/basic.json +1 -5
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/can_fail_build.json +1 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output_fails_build.json +0 -5
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/rebase_failed.json +1 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/set_failure_hash_with_no_steps.json +1 -3
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch.json +4 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch_and_target_ref.json +4 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch.json +4 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch_luci.json +4 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch.json +4 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch_new.json +4 -6
- data/vendor/depot_tools/rietveld.py +3 -1
- data/vendor/depot_tools/roll_dep.py +2 -0
- data/vendor/depot_tools/roll_dep_svn.py +14 -11
- data/vendor/depot_tools/scm.py +10 -5
- data/vendor/depot_tools/split_cl.py +13 -11
- data/vendor/depot_tools/subprocess2.py +1 -1
- data/vendor/depot_tools/third_party/colorama/LICENSE.txt +0 -1
- data/vendor/depot_tools/third_party/colorama/README.chromium +4 -5
- data/vendor/depot_tools/third_party/colorama/README.rst +346 -0
- data/vendor/depot_tools/third_party/colorama/__init__.py +3 -4
- data/vendor/depot_tools/third_party/colorama/ansi.py +82 -30
- data/vendor/depot_tools/third_party/colorama/ansitowin32.py +105 -37
- data/vendor/depot_tools/third_party/colorama/initialise.py +39 -15
- data/vendor/depot_tools/third_party/colorama/win32.py +46 -28
- data/vendor/depot_tools/third_party/colorama/winterm.py +80 -31
- data/vendor/depot_tools/third_party/upload.py +1 -1
- data/vendor/depot_tools/upload_to_google_storage.py +8 -6
- data/vendor/depot_tools/vpython +1 -1
- data/vendor/depot_tools/watchlists.py +5 -3
- data/vendor/depot_tools/weekly +4 -2
- data/vendor/depot_tools/win_toolchain/get_toolchain_if_necessary.py +38 -36
- data/vendor/depot_tools/win_toolchain/package_from_installed.py +10 -8
- data/vendor/depot_tools/wtf +5 -3
- metadata +3 -3
- data/vendor/depot_tools/third_party/colorama/README.txt +0 -304
@@ -1,7 +1,6 @@
|
|
1
1
|
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
|
2
|
-
from .initialise import init, deinit, reinit
|
3
|
-
from .ansi import Fore, Back, Style
|
2
|
+
from .initialise import init, deinit, reinit, colorama_text
|
3
|
+
from .ansi import Fore, Back, Style, Cursor
|
4
4
|
from .ansitowin32 import AnsiToWin32
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
__version__ = '0.4.1'
|
@@ -5,46 +5,98 @@ See: http://en.wikipedia.org/wiki/ANSI_escape_code
|
|
5
5
|
'''
|
6
6
|
|
7
7
|
CSI = '\033['
|
8
|
+
OSC = '\033]'
|
9
|
+
BEL = '\007'
|
10
|
+
|
8
11
|
|
9
12
|
def code_to_chars(code):
|
10
13
|
return CSI + str(code) + 'm'
|
11
14
|
|
15
|
+
def set_title(title):
|
16
|
+
return OSC + '2;' + title + BEL
|
17
|
+
|
18
|
+
def clear_screen(mode=2):
|
19
|
+
return CSI + str(mode) + 'J'
|
20
|
+
|
21
|
+
def clear_line(mode=2):
|
22
|
+
return CSI + str(mode) + 'K'
|
23
|
+
|
24
|
+
|
12
25
|
class AnsiCodes(object):
|
13
|
-
def __init__(self
|
14
|
-
|
26
|
+
def __init__(self):
|
27
|
+
# the subclasses declare class attributes which are numbers.
|
28
|
+
# Upon instantiation we define instance attributes, which are the same
|
29
|
+
# as the class attributes but wrapped with the ANSI escape sequence
|
30
|
+
for name in dir(self):
|
15
31
|
if not name.startswith('_'):
|
16
|
-
value = getattr(
|
32
|
+
value = getattr(self, name)
|
17
33
|
setattr(self, name, code_to_chars(value))
|
18
34
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
35
|
+
|
36
|
+
class AnsiCursor(object):
|
37
|
+
def UP(self, n=1):
|
38
|
+
return CSI + str(n) + 'A'
|
39
|
+
def DOWN(self, n=1):
|
40
|
+
return CSI + str(n) + 'B'
|
41
|
+
def FORWARD(self, n=1):
|
42
|
+
return CSI + str(n) + 'C'
|
43
|
+
def BACK(self, n=1):
|
44
|
+
return CSI + str(n) + 'D'
|
45
|
+
def POS(self, x=1, y=1):
|
46
|
+
return CSI + str(y) + ';' + str(x) + 'H'
|
47
|
+
|
48
|
+
|
49
|
+
class AnsiFore(AnsiCodes):
|
50
|
+
BLACK = 30
|
51
|
+
RED = 31
|
52
|
+
GREEN = 32
|
53
|
+
YELLOW = 33
|
54
|
+
BLUE = 34
|
55
|
+
MAGENTA = 35
|
56
|
+
CYAN = 36
|
57
|
+
WHITE = 37
|
58
|
+
RESET = 39
|
59
|
+
|
60
|
+
# These are fairly well supported, but not part of the standard.
|
61
|
+
LIGHTBLACK_EX = 90
|
62
|
+
LIGHTRED_EX = 91
|
63
|
+
LIGHTGREEN_EX = 92
|
64
|
+
LIGHTYELLOW_EX = 93
|
65
|
+
LIGHTBLUE_EX = 94
|
66
|
+
LIGHTMAGENTA_EX = 95
|
67
|
+
LIGHTCYAN_EX = 96
|
68
|
+
LIGHTWHITE_EX = 97
|
69
|
+
|
70
|
+
|
71
|
+
class AnsiBack(AnsiCodes):
|
72
|
+
BLACK = 40
|
73
|
+
RED = 41
|
74
|
+
GREEN = 42
|
75
|
+
YELLOW = 43
|
76
|
+
BLUE = 44
|
77
|
+
MAGENTA = 45
|
78
|
+
CYAN = 46
|
79
|
+
WHITE = 47
|
80
|
+
RESET = 49
|
81
|
+
|
82
|
+
# These are fairly well supported, but not part of the standard.
|
83
|
+
LIGHTBLACK_EX = 100
|
84
|
+
LIGHTRED_EX = 101
|
85
|
+
LIGHTGREEN_EX = 102
|
86
|
+
LIGHTYELLOW_EX = 103
|
87
|
+
LIGHTBLUE_EX = 104
|
88
|
+
LIGHTMAGENTA_EX = 105
|
89
|
+
LIGHTCYAN_EX = 106
|
90
|
+
LIGHTWHITE_EX = 107
|
91
|
+
|
92
|
+
|
93
|
+
class AnsiStyle(AnsiCodes):
|
42
94
|
BRIGHT = 1
|
43
95
|
DIM = 2
|
44
96
|
NORMAL = 22
|
45
97
|
RESET_ALL = 0
|
46
98
|
|
47
|
-
Fore
|
48
|
-
Back
|
49
|
-
Style
|
50
|
-
|
99
|
+
Fore = AnsiFore()
|
100
|
+
Back = AnsiBack()
|
101
|
+
Style = AnsiStyle()
|
102
|
+
Cursor = AnsiCursor()
|
@@ -1,20 +1,18 @@
|
|
1
1
|
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
|
2
2
|
import re
|
3
3
|
import sys
|
4
|
+
import os
|
4
5
|
|
5
6
|
from .ansi import AnsiFore, AnsiBack, AnsiStyle, Style
|
6
7
|
from .winterm import WinTerm, WinColor, WinStyle
|
7
|
-
from .win32 import windll
|
8
|
+
from .win32 import windll, winapi_test
|
8
9
|
|
9
10
|
|
11
|
+
winterm = None
|
10
12
|
if windll is not None:
|
11
13
|
winterm = WinTerm()
|
12
14
|
|
13
15
|
|
14
|
-
def is_a_tty(stream):
|
15
|
-
return hasattr(stream, 'isatty') and stream.isatty()
|
16
|
-
|
17
|
-
|
18
16
|
class StreamWrapper(object):
|
19
17
|
'''
|
20
18
|
Wraps a stream (such as stdout), acting as a transparent proxy for all
|
@@ -30,9 +28,38 @@ class StreamWrapper(object):
|
|
30
28
|
def __getattr__(self, name):
|
31
29
|
return getattr(self.__wrapped, name)
|
32
30
|
|
31
|
+
def __enter__(self, *args, **kwargs):
|
32
|
+
# special method lookup bypasses __getattr__/__getattribute__, see
|
33
|
+
# https://stackoverflow.com/questions/12632894/why-doesnt-getattr-work-with-exit
|
34
|
+
# thus, contextlib magic methods are not proxied via __getattr__
|
35
|
+
return self.__wrapped.__enter__(*args, **kwargs)
|
36
|
+
|
37
|
+
def __exit__(self, *args, **kwargs):
|
38
|
+
return self.__wrapped.__exit__(*args, **kwargs)
|
39
|
+
|
33
40
|
def write(self, text):
|
34
41
|
self.__convertor.write(text)
|
35
42
|
|
43
|
+
def isatty(self):
|
44
|
+
stream = self.__wrapped
|
45
|
+
if 'PYCHARM_HOSTED' in os.environ:
|
46
|
+
if stream is not None and (stream is sys.__stdout__ or stream is sys.__stderr__):
|
47
|
+
return True
|
48
|
+
try:
|
49
|
+
stream_isatty = stream.isatty
|
50
|
+
except AttributeError:
|
51
|
+
return False
|
52
|
+
else:
|
53
|
+
return stream_isatty()
|
54
|
+
|
55
|
+
@property
|
56
|
+
def closed(self):
|
57
|
+
stream = self.__wrapped
|
58
|
+
try:
|
59
|
+
return stream.closed
|
60
|
+
except AttributeError:
|
61
|
+
return True
|
62
|
+
|
36
63
|
|
37
64
|
class AnsiToWin32(object):
|
38
65
|
'''
|
@@ -40,7 +67,8 @@ class AnsiToWin32(object):
|
|
40
67
|
sequences from the text, and if outputting to a tty, will convert them into
|
41
68
|
win32 function calls.
|
42
69
|
'''
|
43
|
-
|
70
|
+
ANSI_CSI_RE = re.compile('\001?\033\\[((?:\\d|;)*)([a-zA-Z])\002?') # Control Sequence Introducer
|
71
|
+
ANSI_OSC_RE = re.compile('\001?\033\\]((?:.|;)*?)(\x07)\002?') # Operating System Command
|
44
72
|
|
45
73
|
def __init__(self, wrapped, convert=None, strip=None, autoreset=False):
|
46
74
|
# The wrapped stream (normally sys.stdout or sys.stderr)
|
@@ -52,16 +80,21 @@ class AnsiToWin32(object):
|
|
52
80
|
# create the proxy wrapping our output stream
|
53
81
|
self.stream = StreamWrapper(wrapped, self)
|
54
82
|
|
55
|
-
on_windows =
|
83
|
+
on_windows = os.name == 'nt'
|
84
|
+
# We test if the WinAPI works, because even if we are on Windows
|
85
|
+
# we may be using a terminal that doesn't support the WinAPI
|
86
|
+
# (e.g. Cygwin Terminal). In this case it's up to the terminal
|
87
|
+
# to support the ANSI codes.
|
88
|
+
conversion_supported = on_windows and winapi_test()
|
56
89
|
|
57
90
|
# should we strip ANSI sequences from our output?
|
58
91
|
if strip is None:
|
59
|
-
strip =
|
92
|
+
strip = conversion_supported or (not self.stream.closed and not self.stream.isatty())
|
60
93
|
self.strip = strip
|
61
94
|
|
62
95
|
# should we should convert ANSI sequences into win32 calls?
|
63
96
|
if convert is None:
|
64
|
-
convert =
|
97
|
+
convert = conversion_supported and not self.stream.closed and self.stream.isatty()
|
65
98
|
self.convert = convert
|
66
99
|
|
67
100
|
# dict of ansi codes to win32 functions and parameters
|
@@ -70,7 +103,6 @@ class AnsiToWin32(object):
|
|
70
103
|
# are we wrapping stderr?
|
71
104
|
self.on_stderr = self.wrapped is sys.stderr
|
72
105
|
|
73
|
-
|
74
106
|
def should_wrap(self):
|
75
107
|
'''
|
76
108
|
True if this class is actually needed. If false, then the output
|
@@ -81,7 +113,6 @@ class AnsiToWin32(object):
|
|
81
113
|
'''
|
82
114
|
return self.convert or self.strip or self.autoreset
|
83
115
|
|
84
|
-
|
85
116
|
def get_win32_calls(self):
|
86
117
|
if self.convert and winterm:
|
87
118
|
return {
|
@@ -98,6 +129,14 @@ class AnsiToWin32(object):
|
|
98
129
|
AnsiFore.CYAN: (winterm.fore, WinColor.CYAN),
|
99
130
|
AnsiFore.WHITE: (winterm.fore, WinColor.GREY),
|
100
131
|
AnsiFore.RESET: (winterm.fore, ),
|
132
|
+
AnsiFore.LIGHTBLACK_EX: (winterm.fore, WinColor.BLACK, True),
|
133
|
+
AnsiFore.LIGHTRED_EX: (winterm.fore, WinColor.RED, True),
|
134
|
+
AnsiFore.LIGHTGREEN_EX: (winterm.fore, WinColor.GREEN, True),
|
135
|
+
AnsiFore.LIGHTYELLOW_EX: (winterm.fore, WinColor.YELLOW, True),
|
136
|
+
AnsiFore.LIGHTBLUE_EX: (winterm.fore, WinColor.BLUE, True),
|
137
|
+
AnsiFore.LIGHTMAGENTA_EX: (winterm.fore, WinColor.MAGENTA, True),
|
138
|
+
AnsiFore.LIGHTCYAN_EX: (winterm.fore, WinColor.CYAN, True),
|
139
|
+
AnsiFore.LIGHTWHITE_EX: (winterm.fore, WinColor.GREY, True),
|
101
140
|
AnsiBack.BLACK: (winterm.back, WinColor.BLACK),
|
102
141
|
AnsiBack.RED: (winterm.back, WinColor.RED),
|
103
142
|
AnsiBack.GREEN: (winterm.back, WinColor.GREEN),
|
@@ -107,8 +146,16 @@ class AnsiToWin32(object):
|
|
107
146
|
AnsiBack.CYAN: (winterm.back, WinColor.CYAN),
|
108
147
|
AnsiBack.WHITE: (winterm.back, WinColor.GREY),
|
109
148
|
AnsiBack.RESET: (winterm.back, ),
|
149
|
+
AnsiBack.LIGHTBLACK_EX: (winterm.back, WinColor.BLACK, True),
|
150
|
+
AnsiBack.LIGHTRED_EX: (winterm.back, WinColor.RED, True),
|
151
|
+
AnsiBack.LIGHTGREEN_EX: (winterm.back, WinColor.GREEN, True),
|
152
|
+
AnsiBack.LIGHTYELLOW_EX: (winterm.back, WinColor.YELLOW, True),
|
153
|
+
AnsiBack.LIGHTBLUE_EX: (winterm.back, WinColor.BLUE, True),
|
154
|
+
AnsiBack.LIGHTMAGENTA_EX: (winterm.back, WinColor.MAGENTA, True),
|
155
|
+
AnsiBack.LIGHTCYAN_EX: (winterm.back, WinColor.CYAN, True),
|
156
|
+
AnsiBack.LIGHTWHITE_EX: (winterm.back, WinColor.GREY, True),
|
110
157
|
}
|
111
|
-
|
158
|
+
return dict()
|
112
159
|
|
113
160
|
def write(self, text):
|
114
161
|
if self.strip or self.convert:
|
@@ -123,7 +170,7 @@ class AnsiToWin32(object):
|
|
123
170
|
def reset_all(self):
|
124
171
|
if self.convert:
|
125
172
|
self.call_win32('m', (0,))
|
126
|
-
elif
|
173
|
+
elif not self.strip and not self.stream.closed:
|
127
174
|
self.wrapped.write(Style.RESET_ALL)
|
128
175
|
|
129
176
|
|
@@ -134,7 +181,8 @@ class AnsiToWin32(object):
|
|
134
181
|
calls.
|
135
182
|
'''
|
136
183
|
cursor = 0
|
137
|
-
|
184
|
+
text = self.convert_osc(text)
|
185
|
+
for match in self.ANSI_CSI_RE.finditer(text):
|
138
186
|
start, end = match.span()
|
139
187
|
self.write_plain_text(text, cursor, start)
|
140
188
|
self.convert_ansi(*match.groups())
|
@@ -150,21 +198,29 @@ class AnsiToWin32(object):
|
|
150
198
|
|
151
199
|
def convert_ansi(self, paramstring, command):
|
152
200
|
if self.convert:
|
153
|
-
params = self.extract_params(paramstring)
|
201
|
+
params = self.extract_params(command, paramstring)
|
154
202
|
self.call_win32(command, params)
|
155
203
|
|
156
204
|
|
157
|
-
def extract_params(self, paramstring):
|
158
|
-
|
159
|
-
for p in paramstring.split(';')
|
160
|
-
|
161
|
-
|
162
|
-
|
205
|
+
def extract_params(self, command, paramstring):
|
206
|
+
if command in 'Hf':
|
207
|
+
params = tuple(int(p) if len(p) != 0 else 1 for p in paramstring.split(';'))
|
208
|
+
while len(params) < 2:
|
209
|
+
# defaults:
|
210
|
+
params = params + (1,)
|
211
|
+
else:
|
212
|
+
params = tuple(int(p) for p in paramstring.split(';') if len(p) != 0)
|
213
|
+
if len(params) == 0:
|
214
|
+
# defaults:
|
215
|
+
if command in 'JKm':
|
216
|
+
params = (0,)
|
217
|
+
elif command in 'ABCD':
|
218
|
+
params = (1,)
|
219
|
+
|
220
|
+
return params
|
163
221
|
|
164
222
|
|
165
223
|
def call_win32(self, command, params):
|
166
|
-
if params == []:
|
167
|
-
params = [0]
|
168
224
|
if command == 'm':
|
169
225
|
for param in params:
|
170
226
|
if param in self.win32_calls:
|
@@ -173,17 +229,29 @@ class AnsiToWin32(object):
|
|
173
229
|
args = func_args[1:]
|
174
230
|
kwargs = dict(on_stderr=self.on_stderr)
|
175
231
|
func(*args, **kwargs)
|
176
|
-
elif command in
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
elif command
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
232
|
+
elif command in 'J':
|
233
|
+
winterm.erase_screen(params[0], on_stderr=self.on_stderr)
|
234
|
+
elif command in 'K':
|
235
|
+
winterm.erase_line(params[0], on_stderr=self.on_stderr)
|
236
|
+
elif command in 'Hf': # cursor position - absolute
|
237
|
+
winterm.set_cursor_position(params, on_stderr=self.on_stderr)
|
238
|
+
elif command in 'ABCD': # cursor position - relative
|
239
|
+
n = params[0]
|
240
|
+
# A - up, B - down, C - forward, D - back
|
241
|
+
x, y = {'A': (0, -n), 'B': (0, n), 'C': (n, 0), 'D': (-n, 0)}[command]
|
242
|
+
winterm.cursor_adjust(x, y, on_stderr=self.on_stderr)
|
243
|
+
|
244
|
+
|
245
|
+
def convert_osc(self, text):
|
246
|
+
for match in self.ANSI_OSC_RE.finditer(text):
|
247
|
+
start, end = match.span()
|
248
|
+
text = text[:start] + text[end:]
|
249
|
+
paramstring, command = match.groups()
|
250
|
+
if command in '\x07': # \x07 = BEL
|
251
|
+
params = paramstring.split(";")
|
252
|
+
# 0 - change title and icon (we will only change title)
|
253
|
+
# 1 - change icon (we don't support this)
|
254
|
+
# 2 - change title
|
255
|
+
if params[0] in '02':
|
256
|
+
winterm.set_title(params[1])
|
257
|
+
return text
|
@@ -1,21 +1,23 @@
|
|
1
1
|
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
|
2
2
|
import atexit
|
3
|
+
import contextlib
|
3
4
|
import sys
|
4
5
|
|
5
6
|
from .ansitowin32 import AnsiToWin32
|
6
7
|
|
7
8
|
|
8
|
-
orig_stdout =
|
9
|
-
orig_stderr =
|
9
|
+
orig_stdout = None
|
10
|
+
orig_stderr = None
|
10
11
|
|
11
|
-
wrapped_stdout =
|
12
|
-
wrapped_stderr =
|
12
|
+
wrapped_stdout = None
|
13
|
+
wrapped_stderr = None
|
13
14
|
|
14
15
|
atexit_done = False
|
15
16
|
|
16
17
|
|
17
18
|
def reset_all():
|
18
|
-
AnsiToWin32
|
19
|
+
if AnsiToWin32 is not None: # Issue #74: objects might become None at exit
|
20
|
+
AnsiToWin32(orig_stdout).reset_all()
|
19
21
|
|
20
22
|
|
21
23
|
def init(autoreset=False, convert=None, strip=None, wrap=True):
|
@@ -24,10 +26,21 @@ def init(autoreset=False, convert=None, strip=None, wrap=True):
|
|
24
26
|
raise ValueError('wrap=False conflicts with any other arg=True')
|
25
27
|
|
26
28
|
global wrapped_stdout, wrapped_stderr
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
global orig_stdout, orig_stderr
|
30
|
+
|
31
|
+
orig_stdout = sys.stdout
|
32
|
+
orig_stderr = sys.stderr
|
33
|
+
|
34
|
+
if sys.stdout is None:
|
35
|
+
wrapped_stdout = None
|
36
|
+
else:
|
37
|
+
sys.stdout = wrapped_stdout = \
|
38
|
+
wrap_stream(orig_stdout, convert, strip, autoreset, wrap)
|
39
|
+
if sys.stderr is None:
|
40
|
+
wrapped_stderr = None
|
41
|
+
else:
|
42
|
+
sys.stderr = wrapped_stderr = \
|
43
|
+
wrap_stream(orig_stderr, convert, strip, autoreset, wrap)
|
31
44
|
|
32
45
|
global atexit_done
|
33
46
|
if not atexit_done:
|
@@ -36,13 +49,26 @@ def init(autoreset=False, convert=None, strip=None, wrap=True):
|
|
36
49
|
|
37
50
|
|
38
51
|
def deinit():
|
39
|
-
|
40
|
-
|
52
|
+
if orig_stdout is not None:
|
53
|
+
sys.stdout = orig_stdout
|
54
|
+
if orig_stderr is not None:
|
55
|
+
sys.stderr = orig_stderr
|
56
|
+
|
57
|
+
|
58
|
+
@contextlib.contextmanager
|
59
|
+
def colorama_text(*args, **kwargs):
|
60
|
+
init(*args, **kwargs)
|
61
|
+
try:
|
62
|
+
yield
|
63
|
+
finally:
|
64
|
+
deinit()
|
41
65
|
|
42
66
|
|
43
67
|
def reinit():
|
44
|
-
|
45
|
-
|
68
|
+
if wrapped_stdout is not None:
|
69
|
+
sys.stdout = wrapped_stdout
|
70
|
+
if wrapped_stderr is not None:
|
71
|
+
sys.stderr = wrapped_stderr
|
46
72
|
|
47
73
|
|
48
74
|
def wrap_stream(stream, convert, strip, autoreset, wrap):
|
@@ -52,5 +78,3 @@ def wrap_stream(stream, convert, strip, autoreset, wrap):
|
|
52
78
|
if wrapper.should_wrap():
|
53
79
|
stream = wrapper.stream
|
54
80
|
return stream
|
55
|
-
|
56
|
-
|