Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 30 lines (23 sloc) 0.841 kb
41285e5 Harry Pierson moved console color code to consolecolor.py file
authored
1 from System import Console as _Console
2
3 class ConsoleColorMgr(object):
4 def __init__(self, foreground = None, background = None):
5 self.foreground = foreground
6 self.background = background
7
8 def __enter__(self):
9 self._tempFG = _Console.ForegroundColor
10 self._tempBG = _Console.BackgroundColor
11
12 if self.foreground: _Console.ForegroundColor = self.foreground
13 if self.background: _Console.BackgroundColor = self.background
14
15 def __exit__(self, t, v, tr):
16 _Console.ForegroundColor = self._tempFG
17 _Console.BackgroundColor = self._tempBG
18
19 import sys
20 _curmodule = sys.modules[__name__]
21
22 from System import ConsoleColor, Enum
23 for n in Enum.GetNames(ConsoleColor):
24 setattr(_curmodule, n, ConsoleColorMgr(Enum.Parse(ConsoleColor, n)))
25
26 del ConsoleColor
27 del Enum
28 del sys
29 del _curmodule
30 del n
Something went wrong with that request. Please try again.