Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved console color code to consolecolor.py file
- Loading branch information
Harry Pierson
committed
Mar 20, 2009
1 parent
ec6520e
commit 41285e5
Showing
2 changed files
with
39 additions
and
24 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,30 @@ | ||
from System import Console as _Console | ||
|
||
class ConsoleColorMgr(object): | ||
def __init__(self, foreground = None, background = None): | ||
self.foreground = foreground | ||
self.background = background | ||
|
||
def __enter__(self): | ||
self._tempFG = _Console.ForegroundColor | ||
self._tempBG = _Console.BackgroundColor | ||
|
||
if self.foreground: _Console.ForegroundColor = self.foreground | ||
if self.background: _Console.BackgroundColor = self.background | ||
|
||
def __exit__(self, t, v, tr): | ||
_Console.ForegroundColor = self._tempFG | ||
_Console.BackgroundColor = self._tempBG | ||
|
||
import sys | ||
_curmodule = sys.modules[__name__] | ||
|
||
from System import ConsoleColor, Enum | ||
for n in Enum.GetNames(ConsoleColor): | ||
setattr(_curmodule, n, ConsoleColorMgr(Enum.Parse(ConsoleColor, n))) | ||
|
||
del ConsoleColor | ||
del Enum | ||
del sys | ||
del _curmodule | ||
del n |
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