Hello community, here is the log from the commit of package python-colorama for openSUSE:Factory checked in at 2015-04-21 10:53:45 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-colorama (Old) and /work/SRC/openSUSE:Factory/.python-colorama.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-colorama" Changes: -------- --- /work/SRC/openSUSE:Factory/python-colorama/python-colorama.changes 2014-09-17 17:25:33.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python-colorama.new/python-colorama.changes 2015-04-21 10:53:49.000000000 +0200 @@ -1,0 +2,23 @@ +Sun Apr 19 14:50:28 UTC 2015 - [email protected] + +- update to 0.3.3: + * Fix Google Code issue #13 - support changing the console title + with OSC escape sequence + * Fix Google Code issue #16 - Add support for Windows xterm + emulators + * Fix Google Code issue #30 - implement \033[nK (clear line) + * Fix Google Code issue #49 - no need to adjust for scroll when + new position is already relative (CSI n A\B\C\D) + * Fix Google Code issue #55 - erase_data fails on Python 3.x + * Fix Google Code issue #46 - win32.COORD definition missing + * Implement \033[0J and \033[1J (clear screen options) + * Fix default ANSI parameters + * Fix position after \033[2J (clear screen) + * Add command shortcuts: colorama.Cursor, + colorama.ansi.set_title, colorama.ansi.clear_line, + colorama.ansi.clear_screen + * Fix issue #22 - Importing fails for python3 on Windows + * Thanks to John Szakmeister for adding support for light colors + * Thanks to Charles Merriam for adding documentation to demos + +------------------------------------------------------------------- Old: ---- colorama-0.3.2.tar.gz New: ---- colorama-0.3.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-colorama.spec ++++++ --- /var/tmp/diff_new_pack.g8eHzC/_old 2015-04-21 10:53:50.000000000 +0200 +++ /var/tmp/diff_new_pack.g8eHzC/_new 2015-04-21 10:53:50.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-colorama # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: python-colorama -Version: 0.3.2 +Version: 0.3.3 Release: 0 Summary: Cross-platform colored terminal text License: BSD-3-Clause ++++++ colorama-0.3.2.tar.gz -> colorama-0.3.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/colorama-0.3.2/CHANGELOG.rst new/colorama-0.3.3/CHANGELOG.rst --- old/colorama-0.3.2/CHANGELOG.rst 2014-09-04 00:10:46.000000000 +0200 +++ new/colorama-0.3.3/CHANGELOG.rst 2014-10-11 16:01:33.000000000 +0200 @@ -1,4 +1,4 @@ -0.3.2 (not released yet) +0.3.2 * Thanks to Marc Schlaich (schlamar) for a setup.py fix for Python2.5 * Thanks to Jurko for fix on 64-bit Windows CPython2.5 w/o ctypes (issue #56) * Thanks to Remi Rampin for: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/colorama-0.3.2/PKG-INFO new/colorama-0.3.3/PKG-INFO --- old/colorama-0.3.2/PKG-INFO 2014-09-04 00:12:09.000000000 +0200 +++ new/colorama-0.3.3/PKG-INFO 2015-01-06 11:44:35.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: colorama -Version: 0.3.2 +Version: 0.3.3 Summary: Cross-platform colored terminal text. Home-page: https://pypi.python.org/pypi/colorama Author: Jonathan Hartley @@ -11,8 +11,10 @@ Download and docs: http://pypi.python.org/pypi/colorama - Development: + Source code & Development: https://github.com/tartley/colorama + Issues: + https://code.google.com/p/colorama/issues/list Discussion group: https://groups.google.com/forum/#!forum/python-colorama @@ -71,7 +73,7 @@ Dependencies ============ - None, other than Python. Tested on Python 2.5.5, 2.6.5, 2.7, 3.1.2, and 3.2 + None, other than Python. Tested on Python 2.5.5, 2.6.5, 2.7, 3.1.2, 3.2, 3.3, 3.4. Usage ===== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/colorama-0.3.2/README.rst new/colorama-0.3.3/README.rst --- old/colorama-0.3.2/README.rst 2014-09-03 21:56:00.000000000 +0200 +++ new/colorama-0.3.3/README.rst 2014-10-11 16:01:33.000000000 +0200 @@ -3,8 +3,10 @@ Download and docs: http://pypi.python.org/pypi/colorama -Development: +Source code & Development: https://github.com/tartley/colorama +Issues: + https://code.google.com/p/colorama/issues/list Discussion group: https://groups.google.com/forum/#!forum/python-colorama @@ -63,7 +65,7 @@ Dependencies ============ -None, other than Python. Tested on Python 2.5.5, 2.6.5, 2.7, 3.1.2, and 3.2 +None, other than Python. Tested on Python 2.5.5, 2.6.5, 2.7, 3.1.2, 3.2, 3.3, 3.4. Usage ===== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/colorama-0.3.2/colorama/__init__.py new/colorama-0.3.3/colorama/__init__.py --- old/colorama-0.3.2/colorama/__init__.py 2014-09-04 00:05:59.000000000 +0200 +++ new/colorama-0.3.3/colorama/__init__.py 2015-01-06 11:41:27.000000000 +0100 @@ -1,7 +1,7 @@ # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. from .initialise import init, deinit, reinit -from .ansi import Fore, Back, Style +from .ansi import Fore, Back, Style, Cursor from .ansitowin32 import AnsiToWin32 -__version__ = '0.3.2' +__version__ = '0.3.3' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/colorama-0.3.2/colorama/ansi.py new/colorama-0.3.3/colorama/ansi.py --- old/colorama-0.3.2/colorama/ansi.py 2014-09-04 00:10:46.000000000 +0200 +++ new/colorama-0.3.3/colorama/ansi.py 2014-11-03 11:35:17.000000000 +0100 @@ -5,10 +5,14 @@ ''' CSI = '\033[' +OSC = '\033]' +BEL = '\007' + def code_to_chars(code): return CSI + str(code) + 'm' + class AnsiCodes(object): def __init__(self, codes): for name in dir(codes): @@ -16,27 +20,72 @@ value = getattr(codes, 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" + +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 AnsiFore: - BLACK = 30 - RED = 31 - GREEN = 32 - YELLOW = 33 - BLUE = 34 - MAGENTA = 35 - CYAN = 36 - WHITE = 37 - RESET = 39 + 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: - BLACK = 40 - RED = 41 - GREEN = 42 - YELLOW = 43 - BLUE = 44 - MAGENTA = 45 - CYAN = 46 - WHITE = 47 - RESET = 49 + 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: BRIGHT = 1 @@ -47,4 +96,4 @@ Fore = AnsiCodes( AnsiFore ) Back = AnsiCodes( AnsiBack ) Style = AnsiCodes( AnsiStyle ) - +Cursor = AnsiCursor() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/colorama-0.3.2/colorama/ansitowin32.py new/colorama-0.3.3/colorama/ansitowin32.py --- old/colorama-0.3.2/colorama/ansitowin32.py 2014-09-04 00:05:59.000000000 +0200 +++ new/colorama-0.3.3/colorama/ansitowin32.py 2014-11-03 11:35:31.000000000 +0100 @@ -1,6 +1,7 @@ # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. import re import sys +import os from .ansi import AnsiFore, AnsiBack, AnsiStyle, Style from .winterm import WinTerm, WinColor, WinStyle @@ -41,7 +42,8 @@ sequences from the text, and if outputting to a tty, will convert them into win32 function calls. ''' - ANSI_RE = re.compile('\033\[((?:\d|;)*)([a-zA-Z])') + ANSI_CSI_RE = re.compile('\033\[((?:\d|;)*)([a-zA-Z])') # Control Sequence Introducer + ANSI_OSC_RE = re.compile('\033\]((?:.|;)*?)(\x07)') # Operating System Command def __init__(self, wrapped, convert=None, strip=None, autoreset=False): # The wrapped stream (normally sys.stdout or sys.stderr) @@ -53,16 +55,17 @@ # create the proxy wrapping our output stream self.stream = StreamWrapper(wrapped, self) - on_windows = sys.platform.startswith('win') + on_windows = os.name == 'nt' + on_emulated_windows = on_windows and 'TERM' in os.environ # should we strip ANSI sequences from our output? if strip is None: - strip = on_windows + strip = on_windows and not on_emulated_windows self.strip = strip # should we should convert ANSI sequences into win32 calls? if convert is None: - convert = on_windows and not wrapped.closed and is_a_tty(wrapped) + convert = on_windows and not wrapped.closed and not on_emulated_windows and is_a_tty(wrapped) self.convert = convert # dict of ansi codes to win32 functions and parameters @@ -71,7 +74,6 @@ # are we wrapping stderr? self.on_stderr = self.wrapped is sys.stderr - def should_wrap(self): ''' True if this class is actually needed. If false, then the output @@ -82,7 +84,6 @@ ''' return self.convert or self.strip or self.autoreset - def get_win32_calls(self): if self.convert and winterm: return { @@ -99,6 +100,14 @@ AnsiFore.CYAN: (winterm.fore, WinColor.CYAN), AnsiFore.WHITE: (winterm.fore, WinColor.GREY), AnsiFore.RESET: (winterm.fore, ), + AnsiFore.LIGHTBLACK_EX: (winterm.fore, WinColor.BLACK, True), + AnsiFore.LIGHTRED_EX: (winterm.fore, WinColor.RED, True), + AnsiFore.LIGHTGREEN_EX: (winterm.fore, WinColor.GREEN, True), + AnsiFore.LIGHTYELLOW_EX: (winterm.fore, WinColor.YELLOW, True), + AnsiFore.LIGHTBLUE_EX: (winterm.fore, WinColor.BLUE, True), + AnsiFore.LIGHTMAGENTA_EX: (winterm.fore, WinColor.MAGENTA, True), + AnsiFore.LIGHTCYAN_EX: (winterm.fore, WinColor.CYAN, True), + AnsiFore.LIGHTWHITE_EX: (winterm.fore, WinColor.GREY, True), AnsiBack.BLACK: (winterm.back, WinColor.BLACK), AnsiBack.RED: (winterm.back, WinColor.RED), AnsiBack.GREEN: (winterm.back, WinColor.GREEN), @@ -108,10 +117,17 @@ AnsiBack.CYAN: (winterm.back, WinColor.CYAN), AnsiBack.WHITE: (winterm.back, WinColor.GREY), AnsiBack.RESET: (winterm.back, ), + AnsiBack.LIGHTBLACK_EX: (winterm.back, WinColor.BLACK, True), + AnsiBack.LIGHTRED_EX: (winterm.back, WinColor.RED, True), + AnsiBack.LIGHTGREEN_EX: (winterm.back, WinColor.GREEN, True), + AnsiBack.LIGHTYELLOW_EX: (winterm.back, WinColor.YELLOW, True), + AnsiBack.LIGHTBLUE_EX: (winterm.back, WinColor.BLUE, True), + AnsiBack.LIGHTMAGENTA_EX: (winterm.back, WinColor.MAGENTA, True), + AnsiBack.LIGHTCYAN_EX: (winterm.back, WinColor.CYAN, True), + AnsiBack.LIGHTWHITE_EX: (winterm.back, WinColor.GREY, True), } return dict() - def write(self, text): if self.strip or self.convert: self.write_and_convert(text) @@ -136,7 +152,8 @@ calls. ''' cursor = 0 - for match in self.ANSI_RE.finditer(text): + text = self.convert_osc(text) + for match in self.ANSI_CSI_RE.finditer(text): start, end = match.span() self.write_plain_text(text, cursor, start) self.convert_ansi(*match.groups()) @@ -152,21 +169,29 @@ def convert_ansi(self, paramstring, command): if self.convert: - params = self.extract_params(paramstring) + params = self.extract_params(command, paramstring) self.call_win32(command, params) - def extract_params(self, paramstring): - def split(paramstring): - for p in paramstring.split(';'): - if p != '': - yield int(p) - return tuple(split(paramstring)) + def extract_params(self, command, paramstring): + if command in 'Hf': + params = tuple(int(p) if len(p) != 0 else 1 for p in paramstring.split(';')) + while len(params) < 2: + # defaults: + params = params + (1,) + else: + params = tuple(int(p) for p in paramstring.split(';') if len(p) != 0) + if len(params) == 0: + # defaults: + if command in 'JKm': + params = (0,) + elif command in 'ABCD': + params = (1,) + + return params def call_win32(self, command, params): - if params == []: - params = [0] if command == 'm': for param in params: if param in self.win32_calls: @@ -175,17 +200,29 @@ args = func_args[1:] kwargs = dict(on_stderr=self.on_stderr) func(*args, **kwargs) - elif command in ('H', 'f'): # set cursor position - func = winterm.set_cursor_position - func(params, on_stderr=self.on_stderr) - elif command in ('J'): - func = winterm.erase_data - func(params, on_stderr=self.on_stderr) - elif command == 'A': - if params == () or params == None: - num_rows = 1 - else: - num_rows = params[0] - func = winterm.cursor_up - func(num_rows, on_stderr=self.on_stderr) + elif command in 'J': + winterm.erase_screen(params[0], on_stderr=self.on_stderr) + elif command in 'K': + winterm.erase_line(params[0], on_stderr=self.on_stderr) + elif command in 'Hf': # cursor position - absolute + winterm.set_cursor_position(params, on_stderr=self.on_stderr) + elif command in 'ABCD': # cursor position - relative + n = params[0] + # A - up, B - down, C - forward, D - back + x, y = {'A': (0, -n), 'B': (0, n), 'C': (n, 0), 'D': (-n, 0)}[command] + winterm.cursor_adjust(x, y, on_stderr=self.on_stderr) + + def convert_osc(self, text): + for match in self.ANSI_OSC_RE.finditer(text): + start, end = match.span() + text = text[:start] + text[end:] + paramstring, command = match.groups() + if command in '\x07': # \x07 = BEL + params = paramstring.split(";") + # 0 - change title and icon (we will only change title) + # 1 - change icon (we don't support this) + # 2 - change title + if params[0] in '02': + winterm.set_title(params[1]) + return text diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/colorama-0.3.2/colorama/win32.py new/colorama-0.3.3/colorama/win32.py --- old/colorama-0.3.2/colorama/win32.py 2014-09-03 21:34:03.000000000 +0200 +++ new/colorama-0.3.3/colorama/win32.py 2014-11-03 11:35:00.000000000 +0100 @@ -13,18 +13,18 @@ windll = None SetConsoleTextAttribute = lambda *_: None else: - from ctypes import ( - byref, Structure, c_char, c_short, c_uint32, c_ushort, POINTER - ) + from ctypes import byref, Structure, c_char, POINTER + + COORD = wintypes._COORD class CONSOLE_SCREEN_BUFFER_INFO(Structure): """struct in wincon.h.""" _fields_ = [ - ("dwSize", wintypes._COORD), - ("dwCursorPosition", wintypes._COORD), + ("dwSize", COORD), + ("dwCursorPosition", COORD), ("wAttributes", wintypes.WORD), ("srWindow", wintypes.SMALL_RECT), - ("dwMaximumWindowSize", wintypes._COORD), + ("dwMaximumWindowSize", COORD), ] def __str__(self): return '(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)' % ( @@ -58,7 +58,7 @@ _SetConsoleCursorPosition = windll.kernel32.SetConsoleCursorPosition _SetConsoleCursorPosition.argtypes = [ wintypes.HANDLE, - wintypes._COORD, + COORD, ] _SetConsoleCursorPosition.restype = wintypes.BOOL @@ -67,7 +67,7 @@ wintypes.HANDLE, c_char, wintypes.DWORD, - wintypes._COORD, + COORD, POINTER(wintypes.DWORD), ] _FillConsoleOutputCharacterA.restype = wintypes.BOOL @@ -77,11 +77,17 @@ wintypes.HANDLE, wintypes.WORD, wintypes.DWORD, - wintypes._COORD, + COORD, POINTER(wintypes.DWORD), ] _FillConsoleOutputAttribute.restype = wintypes.BOOL + _SetConsoleTitleW = windll.kernel32.SetConsoleTitleA + _SetConsoleTitleW.argtypes = [ + wintypes.LPCSTR + ] + _SetConsoleTitleW.restype = wintypes.BOOL + handles = { STDOUT: _GetStdHandle(STDOUT), STDERR: _GetStdHandle(STDERR), @@ -98,26 +104,27 @@ handle = handles[stream_id] return _SetConsoleTextAttribute(handle, attrs) - def SetConsoleCursorPosition(stream_id, position): - position = wintypes._COORD(*position) + def SetConsoleCursorPosition(stream_id, position, adjust=True): + position = COORD(*position) # If the position is out of range, do nothing. if position.Y <= 0 or position.X <= 0: return # Adjust for Windows' SetConsoleCursorPosition: # 1. being 0-based, while ANSI is 1-based. # 2. expecting (x,y), while ANSI uses (y,x). - adjusted_position = wintypes._COORD(position.Y - 1, position.X - 1) - # Adjust for viewport's scroll position - sr = GetConsoleScreenBufferInfo(STDOUT).srWindow - adjusted_position.Y += sr.Top - adjusted_position.X += sr.Left + adjusted_position = COORD(position.Y - 1, position.X - 1) + if adjust: + # Adjust for viewport's scroll position + sr = GetConsoleScreenBufferInfo(STDOUT).srWindow + adjusted_position.Y += sr.Top + adjusted_position.X += sr.Left # Resume normal processing handle = handles[stream_id] return _SetConsoleCursorPosition(handle, adjusted_position) def FillConsoleOutputCharacter(stream_id, char, length, start): handle = handles[stream_id] - char = c_char(char) + char = c_char(char.encode()) length = wintypes.DWORD(length) num_written = wintypes.DWORD(0) # Note that this is hard-coded for ANSI (vs wide) bytes. @@ -134,3 +141,6 @@ # Note that this is hard-coded for ANSI (vs wide) bytes. return _FillConsoleOutputAttribute( handle, attribute, length, start, byref(num_written)) + + def SetConsoleTitle(title): + return _SetConsoleTitleW(title) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/colorama-0.3.2/colorama/winterm.py new/colorama-0.3.3/colorama/winterm.py --- old/colorama-0.3.2/colorama/winterm.py 2014-04-19 13:16:24.000000000 +0200 +++ new/colorama-0.3.3/colorama/winterm.py 2014-11-03 11:35:00.000000000 +0100 @@ -15,9 +15,9 @@ # from wincon.h class WinStyle(object): - NORMAL = 0x00 # dim text, dim background - BRIGHT = 0x08 # bright text, dim background - + NORMAL = 0x00 # dim text, dim background + BRIGHT = 0x08 # bright text, dim background + BRIGHT_BACKGROUND = 0x80 # dim text, bright background class WinTerm(object): @@ -34,22 +34,26 @@ def set_attrs(self, value): self._fore = value & 7 self._back = (value >> 4) & 7 - self._style = value & WinStyle.BRIGHT + self._style = value & (WinStyle.BRIGHT | WinStyle.BRIGHT_BACKGROUND) def reset_all(self, on_stderr=None): self.set_attrs(self._default) self.set_console(attrs=self._default) - def fore(self, fore=None, on_stderr=False): + def fore(self, fore=None, light=False, on_stderr=False): if fore is None: fore = self._default_fore self._fore = fore + if light: + self._style |= WinStyle.BRIGHT self.set_console(on_stderr=on_stderr) - def back(self, back=None, on_stderr=False): + def back(self, back=None, light=False, on_stderr=False): if back is None: back = self._default_back self._back = back + if light: + self._style |= WinStyle.BRIGHT_BACKGROUND self.set_console(on_stderr=on_stderr) def style(self, style=None, on_stderr=False): @@ -73,7 +77,7 @@ position.X += 1 position.Y += 1 return position - + def set_cursor_position(self, position=None, on_stderr=False): if position is None: #I'm not currently tracking the position, so there is no default. @@ -84,37 +88,64 @@ handle = win32.STDERR win32.SetConsoleCursorPosition(handle, position) - def cursor_up(self, num_rows=0, on_stderr=False): - if num_rows == 0: - return + def cursor_adjust(self, x, y, on_stderr=False): handle = win32.STDOUT if on_stderr: handle = win32.STDERR position = self.get_position(handle) - adjusted_position = (position.Y - num_rows, position.X) - self.set_cursor_position(adjusted_position, on_stderr) + adjusted_position = (position.Y + y, position.X + x) + win32.SetConsoleCursorPosition(handle, adjusted_position, adjust=False) - def erase_data(self, mode=0, on_stderr=False): - # 0 (or None) should clear from the cursor to the end of the screen. + def erase_screen(self, mode=0, on_stderr=False): + # 0 should clear from the cursor to the end of the screen. # 1 should clear from the cursor to the beginning of the screen. - # 2 should clear the entire screen. (And maybe move cursor to (1,1)?) - # - # At the moment, I only support mode 2. From looking at the API, it - # should be possible to calculate a different number of bytes to clear, - # and to do so relative to the cursor position. - if mode[0] not in (2,): - return + # 2 should clear the entire screen, and move cursor to (1,1) handle = win32.STDOUT if on_stderr: handle = win32.STDERR - # here's where we'll home the cursor - coord_screen = win32.COORD(0,0) csbi = win32.GetConsoleScreenBufferInfo(handle) # get the number of character cells in the current buffer - dw_con_size = csbi.dwSize.X * csbi.dwSize.Y + cells_in_screen = csbi.dwSize.X * csbi.dwSize.Y + # get number of character cells before current cursor position + cells_before_cursor = csbi.dwSize.X * csbi.dwCursorPosition.Y + csbi.dwCursorPosition.X + if mode == 0: + from_coord = csbi.dwCursorPosition + cells_to_erase = cells_in_screen - cells_before_cursor + if mode == 1: + from_coord = win32.COORD(0, 0) + cells_to_erase = cells_before_cursor + elif mode == 2: + from_coord = win32.COORD(0, 0) + cells_to_erase = cells_in_screen # fill the entire screen with blanks - win32.FillConsoleOutputCharacter(handle, ' ', dw_con_size, coord_screen) + win32.FillConsoleOutputCharacter(handle, ' ', cells_to_erase, from_coord) # now set the buffer's attributes accordingly - win32.FillConsoleOutputAttribute(handle, self.get_attrs(), dw_con_size, coord_screen ); - # put the cursor at (0, 0) - win32.SetConsoleCursorPosition(handle, (coord_screen.X, coord_screen.Y)) + win32.FillConsoleOutputAttribute(handle, self.get_attrs(), cells_to_erase, from_coord) + if mode == 2: + # put the cursor where needed + win32.SetConsoleCursorPosition(handle, (1, 1)) + + def erase_line(self, mode=0, on_stderr=False): + # 0 should clear from the cursor to the end of the line. + # 1 should clear from the cursor to the beginning of the line. + # 2 should clear the entire line. + handle = win32.STDOUT + if on_stderr: + handle = win32.STDERR + csbi = win32.GetConsoleScreenBufferInfo(handle) + if mode == 0: + from_coord = csbi.dwCursorPosition + cells_to_erase = csbi.dwSize.X - csbi.dwCursorPosition.X + if mode == 1: + from_coord = win32.COORD(0, csbi.dwCursorPosition.Y) + cells_to_erase = csbi.dwCursorPosition.X + elif mode == 2: + from_coord = win32.COORD(0, csbi.dwCursorPosition.Y) + cells_to_erase = csbi.dwSize.X + # fill the entire screen with blanks + win32.FillConsoleOutputCharacter(handle, ' ', cells_to_erase, from_coord) + # now set the buffer's attributes accordingly + win32.FillConsoleOutputAttribute(handle, self.get_attrs(), cells_to_erase, from_coord) + + def set_title(self, title): + win32.SetConsoleTitle(title) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/colorama-0.3.2/colorama.egg-info/PKG-INFO new/colorama-0.3.3/colorama.egg-info/PKG-INFO --- old/colorama-0.3.2/colorama.egg-info/PKG-INFO 2014-09-04 00:12:09.000000000 +0200 +++ new/colorama-0.3.3/colorama.egg-info/PKG-INFO 2015-01-06 11:44:31.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: colorama -Version: 0.3.2 +Version: 0.3.3 Summary: Cross-platform colored terminal text. Home-page: https://pypi.python.org/pypi/colorama Author: Jonathan Hartley @@ -11,8 +11,10 @@ Download and docs: http://pypi.python.org/pypi/colorama - Development: + Source code & Development: https://github.com/tartley/colorama + Issues: + https://code.google.com/p/colorama/issues/list Discussion group: https://groups.google.com/forum/#!forum/python-colorama @@ -71,7 +73,7 @@ Dependencies ============ - None, other than Python. Tested on Python 2.5.5, 2.6.5, 2.7, 3.1.2, and 3.2 + None, other than Python. Tested on Python 2.5.5, 2.6.5, 2.7, 3.1.2, 3.2, 3.3, 3.4. Usage ===== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/colorama-0.3.2/colorama.egg-info/SOURCES.txt new/colorama-0.3.3/colorama.egg-info/SOURCES.txt --- old/colorama-0.3.2/colorama.egg-info/SOURCES.txt 2014-09-04 00:12:09.000000000 +0200 +++ new/colorama-0.3.3/colorama.egg-info/SOURCES.txt 2015-01-06 11:44:31.000000000 +0100 @@ -21,4 +21,5 @@ demos/demo04.py demos/demo05.py demos/demo06.py +demos/demo07.py demos/fixpath.py \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/colorama-0.3.2/demos/demo.bat new/colorama-0.3.3/demos/demo.bat --- old/colorama-0.3.2/demos/demo.bat 2014-04-19 13:16:24.000000000 +0200 +++ new/colorama-0.3.3/demos/demo.bat 2015-01-06 11:41:05.000000000 +0100 @@ -8,16 +8,25 @@ :: Implemented as a bash script which invokes python so that we can test the :: behaviour on exit, which resets default colors again. +:: print grid of all colors and brightnesses python demo01.py +:: Simple demo of changing foreground, background and brightness. python demo02.py +:: Demonstrate the different behavior when autoreset is True and False. python demo03.py +:: check that stripped ANSI in redirected stderr does not affect stdout if exist demo04.out del demo04.out python demo04.py 2> demo04.out type demo04.out +:: Demonstrate the difference between colorama intialized with wrapping on and off. python demo05.py +:: # Demonstrate printing colored, random characters at random positions on the screen python demo06.py + +:: demo07.py not shown +:: Demonstrate cursor relative movement: UP, DOWN, FORWARD, and BACK in colorama.CURSOR diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/colorama-0.3.2/demos/demo.sh new/colorama-0.3.3/demos/demo.sh --- old/colorama-0.3.2/demos/demo.sh 2014-04-17 21:53:28.000000000 +0200 +++ new/colorama-0.3.3/demos/demo.sh 2015-01-06 11:41:05.000000000 +0100 @@ -9,17 +9,25 @@ # Implemented as a bash script which invokes python so that we can test the # behaviour on exit, which resets default colors again. +# print grid of all colors and brightnesses python demo01.py +# Simple demo of changing foreground, background and brightness. python demo02.py +# Demonstrate the different behavior when autoreset is True and False. python demo03.py +# check that stripped ANSI in redirected stderr does not affect stdout rm -f demo04.out python demo04.py 2> demo04.out cat demo04.out +# Demonstrate the difference between colorama intialized with wrapping on and off. python demo05.py +# Demonstrate printing colored, random characters at random positions on the screen python demo06.py +# demo07.py not shown +# Demonstrate cursor relative movement: UP, DOWN, FORWARD, and BACK in colorama.CURSOR diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/colorama-0.3.2/demos/demo06.py new/colorama-0.3.3/demos/demo06.py --- old/colorama-0.3.2/demos/demo06.py 2014-04-19 13:16:24.000000000 +0200 +++ new/colorama-0.3.3/demos/demo06.py 2015-01-06 11:41:05.000000000 +0100 @@ -6,6 +6,8 @@ from random import randint, choice from string import printable +# Demonstrate printing colored, random characters at random positions on the screen + # Fore, Back and Style are convenience classes for the constant ANSI strings that set # the foreground, background and style. The don't have any magic of their own. FORES = [ Fore.BLACK, Fore.RED, Fore.GREEN, Fore.YELLOW, Fore.BLUE, Fore.MAGENTA, Fore.CYAN, Fore.WHITE ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/colorama-0.3.2/demos/demo07.py new/colorama-0.3.3/demos/demo07.py --- old/colorama-0.3.2/demos/demo07.py 1970-01-01 01:00:00.000000000 +0100 +++ new/colorama-0.3.3/demos/demo07.py 2015-01-06 11:41:05.000000000 +0100 @@ -0,0 +1,26 @@ +import fixpath +import colorama + +# Demonstrate cursor relative movement: UP, DOWN, FORWARD, and BACK in colorama.CURSOR + +up = colorama.Cursor.UP +down = colorama.Cursor.DOWN +forward = colorama.Cursor.FORWARD +back = colorama.Cursor.BACK + +def main(): + """ + expected output: + 1a2 + aba + 3a4 + """ + colorama.init() + print "aaa" + print "aaa" + print "aaa" + print forward() + up(2) + "b" + up() + back(2) + "1" + forward() + "2" + back(3) + down(2) + "3" + forward() + "4" + + +if __name__ == '__main__': + main()
