|
42 | 42 | |
43 | 43 | The fg and bg parameters expect a variety of types. |
44 | 44 | The parameters default to Ellipsis which will tell the function to |
45 | | - use the colors previously set by the L{set_colors} method. |
| 45 | + use the colors previously set by the L{Console.set_colors} method. |
46 | 46 | The colors set by L{Console.set_colors} are per each L{Console}/L{Window} |
47 | 47 | and default to white on black. |
48 | 48 | You can use a 3-item list/tuple of [red, green, blue] with integers in |
@@ -123,6 +123,8 @@ def _format_str(string): |
123 | 123 | _rootinitialized = False |
124 | 124 | _rootConsoleRef = None |
125 | 125 |
|
| 126 | +_set_char = _lib.set_char |
| 127 | + |
126 | 128 | # python 2 to 3 workaround |
127 | 129 | if _sys.version_info[0] == 2: |
128 | 130 | int_types = (int, long) |
@@ -182,14 +184,14 @@ class _BaseConsole(object): |
182 | 184 | @group Printing Methods: print_*, move, set_colors, set_mode, write, get_cursor |
183 | 185 | """ |
184 | 186 | __slots__ = ('width', 'height', 'console', '_cursor', '_fg', |
185 | | - '_bg', '_bgblend', '_colorLock', '__weakref__', '__dict__') |
| 187 | + '_bg', '_blend', '_colorLock', '__weakref__', '__dict__') |
186 | 188 |
|
187 | 189 | def __init__(self): |
188 | 190 | self._cursor = (0, 0) |
189 | 191 | self._scrollMode = 'error' |
190 | 192 | self._fg = _format_color((255, 255, 255)) |
191 | 193 | self._bg = _format_color((0, 0, 0)) |
192 | | - self._bgblend = 1 # SET |
| 194 | + self._blend = _lib.TCOD_BKGND_SET |
193 | 195 | self._colorLock = None # which object sets the ctype color options |
194 | 196 |
|
195 | 197 | def _normalizePoint(self, x, y): |
@@ -329,7 +331,7 @@ def write(self, string): |
329 | 331 | """This method mimics basic file-like behaviour. |
330 | 332 | |
331 | 333 | Because of this method you can replace sys.stdout or sys.stderr with |
332 | | - a L{Typewriter} instance. |
| 334 | + a L{Console} or L{Window} instance. |
333 | 335 | |
334 | 336 | This is a convoluted process and behaviour seen now can be excepted to |
335 | 337 | change on later versions. |
@@ -385,7 +387,7 @@ def draw_char(self, x, y, char, fg=Ellipsis, bg=Ellipsis): |
385 | 387 | @see: L{get_char} |
386 | 388 | """ |
387 | 389 | #x, y = self._normalizePoint(x, y) |
388 | | - _lib.set_char(self._as_parameter_, x, y, _format_char(char), |
| 390 | + _set_char(self._as_parameter_, x, y, _format_char(char), |
389 | 391 | _format_color(fg, self._fg), _format_color(bg, self._bg), 1) |
390 | 392 |
|
391 | 393 | def draw_str(self, x, y, string, fg=Ellipsis, bg=Ellipsis): |
@@ -611,8 +613,8 @@ def get_cursor(self): |
611 | 613 | """Return the virtual cursor position. |
612 | 614 | |
613 | 615 | @rtype: (x, y) |
614 | | - @return: Returns (x, y) a 2-integer tuple containing where the next |
615 | | - L{addChar} or L{addStr} will start at. |
| 616 | + @return: Returns (x, y), a 2-integer tuple containing where the next |
| 617 | + L{print_str} call will start at. |
616 | 618 | |
617 | 619 | This can be changed with the L{move} method. |
618 | 620 | @see: L{move} |
@@ -722,7 +724,32 @@ def getCover(x, length): |
722 | 724 | if uncoverX and uncoverY: # clear corner |
723 | 725 | self.draw_rect(uncoverX[0], uncoverY[0], uncoverX[1], uncoverY[1], |
724 | 726 | 0x20, self._fg, self._bg) |
| 727 | + |
| 728 | + def clear(self, fg=Ellipsis, bg=Ellipsis): |
| 729 | + """Clears the entire L{Console}/L{Window}. |
| 730 | + |
| 731 | + Unlike other drawing functions, fg and bg can not be None. |
725 | 732 |
|
| 733 | + @type fg: (r, g, b), int, or Ellipsis |
| 734 | + @type bg: (r, g, b), int, or Ellipsis |
| 735 | + @param fg: Can not be None. |
| 736 | + See Drawing and Colors at the L{module level docs<tdl>} |
| 737 | + @param bg: See fg |
| 738 | + |
| 739 | + |
| 740 | + @type fg: (r, g, b) |
| 741 | + @param fg: Foreground color. |
| 742 | + |
| 743 | + Must be a 3-item list with integers that range 0-255. |
| 744 | + |
| 745 | + Unlike most other operations you cannot use None here. |
| 746 | + To clear only the foreground or background use L{draw_rect}. |
| 747 | + @type bg: (r, g, b) |
| 748 | + @param bg: Background color. See fg. |
| 749 | + @see: L{draw_rect} |
| 750 | + """ |
| 751 | + raise NotImplementedError('this method is overwritten by subclasses') |
| 752 | + |
726 | 753 | def get_char(self, x, y): |
727 | 754 | """Return the character and colors of a tile as (ch, fg, bg) |
728 | 755 | |
@@ -848,19 +875,7 @@ def _translate(self, x, y): |
848 | 875 | return x, y |
849 | 876 |
|
850 | 877 | def clear(self, fg=Ellipsis, bg=Ellipsis): |
851 | | - """Clears the entire Console. |
852 | | -
|
853 | | - @type fg: (r, g, b) |
854 | | - @param fg: Foreground color. |
855 | | - |
856 | | - Must be a 3-item list with integers that range 0-255. |
857 | | - |
858 | | - Unlike most other operations you cannot use None here. |
859 | | - To clear only the foreground or background use L{draw_rect}. |
860 | | - @type bg: (r, g, b) |
861 | | - @param bg: Background color. See fg. |
862 | | - @see: L{draw_rect} |
863 | | - """ |
| 878 | + # inherit docstring |
864 | 879 | assert fg is not None and bg is not None, 'Can not use None with clear' |
865 | 880 | self._typewriter = None |
866 | 881 | fg = _format_color(fg, self._fg) |
@@ -1026,16 +1041,7 @@ def _translate(self, x, y): |
1026 | 1041 | return self.parent._translate((x + self.x), (y + self.y)) |
1027 | 1042 |
|
1028 | 1043 | def clear(self, fg=Ellipsis, bg=Ellipsis): |
1029 | | - """Clears the entire Window. |
1030 | | - |
1031 | | - fg and bg can not be None for this function, use L{draw_rect}. |
1032 | | -
|
1033 | | - @type fg: (r, g, b), int, Ellipsis, or None |
1034 | | - @type bg: (r, g, b), int, Ellipsis, or None |
1035 | | - @param fg: See Drawing and Colors at the L{module level docs<tdl>} |
1036 | | - @param bg: See fg |
1037 | | - @see: L{draw_rect} |
1038 | | - """ |
| 1044 | + # inherit docstring |
1039 | 1045 | assert fg is not None and bg is not None, 'Can not use None with clear' |
1040 | 1046 | if fg is Ellipsis: |
1041 | 1047 | fg = self._fg |
|
0 commit comments