js/src/tests/lib/terminal_unix.py

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 import sys
michael@0 2
michael@0 3 class Terminal(object):
michael@0 4 COLOR = {
michael@0 5 'red': '31',
michael@0 6 'green': '32',
michael@0 7 'blue': '34',
michael@0 8 'gray': '37'
michael@0 9 }
michael@0 10 NORMAL_INTENSITY = '1'
michael@0 11 BRIGHT_INTENSITY = '2'
michael@0 12 ESCAPE = '\x1b['
michael@0 13 RESET = '0'
michael@0 14 SEPARATOR = ';'
michael@0 15 COLOR_CODE = 'm'
michael@0 16 CLEAR_RIGHT_CODE = 'K'
michael@0 17
michael@0 18 @classmethod
michael@0 19 def set_color(cls, color):
michael@0 20 """
michael@0 21 color: str - color definition string
michael@0 22 """
michael@0 23 mod = Terminal.NORMAL_INTENSITY
michael@0 24 if color.startswith('bright'):
michael@0 25 mod = Terminal.BRIGHT_INTENSITY
michael@0 26 color = color[len('bright'):]
michael@0 27 color_code = Terminal.COLOR[color]
michael@0 28
michael@0 29 sys.stdout.write(cls.ESCAPE + color_code + cls.SEPARATOR + mod + cls.COLOR_CODE)
michael@0 30
michael@0 31 @classmethod
michael@0 32 def reset_color(cls):
michael@0 33 sys.stdout.write(cls.ESCAPE + cls.RESET + cls.COLOR_CODE)
michael@0 34
michael@0 35 @classmethod
michael@0 36 def clear_right(cls):
michael@0 37 sys.stdout.write(cls.ESCAPE + cls.CLEAR_RIGHT_CODE)

mercurial