@@ -79,13 +79,13 @@ class Console:
7979 ... dtype=tcod.console.Console.DTYPE,
8080 ... order="F",
8181 ... )
82- >>> buffer["ch"] = ord(' ')
82+ >>> buffer["ch"] = ord('_ ')
8383 >>> buffer["ch"][:, 1] = ord('x')
8484 >>> c = tcod.console.Console(20, 3, order="F", buffer=buffer)
8585 >>> print(c)
86- < |
87- | xxxxxxxxxxxxxxxxxxxx|
88- | >
86+ <____________________
87+ xxxxxxxxxxxxxxxxxxxx
88+ ____________________ >
8989
9090 .. versionadded:: 8.5
9191
@@ -920,7 +920,7 @@ def __repr__(self) -> str:
920920
921921 def __str__(self) -> str:
922922 """Return a simplified representation of this consoles contents."""
923- return "<%s>" % "|\n| ".join("".join(chr(c) for c in line) for line in self._tiles["ch"])
923+ return "<%s>" % "\n ".join("".join(chr(c) for c in line) for line in self._tiles["ch"])
924924
925925 def _pythonic_index(self, x: int, y: int) -> Tuple[int, int]:
926926 if __debug__ and (x < 0 or y < 0):
@@ -1087,6 +1087,26 @@ def draw_frame(
10871087
10881088 .. versionchanged:: 12.6
10891089 Added `decoration` parameter.
1090+
1091+ Example::
1092+
1093+ >>> console = tcod.Console(12, 6)
1094+ >>> console.draw_frame(x=0, y=0, width=3, height=3)
1095+ >>> console.draw_frame(x=3, y=0, width=3, height=3, decoration="╔═╗║ ║╚═╝")
1096+ >>> console.draw_frame(x=6, y=0, width=3, height=3, decoration="123456789")
1097+ >>> console.draw_frame(x=9, y=0, width=3, height=3, decoration="/-\\| |\\-/")
1098+ >>> console.draw_frame(x=0, y=3, width=12, height=3)
1099+ >>> console.print_box(x=0, y=3, width=12, height=1, string=" Title ", alignment=tcod.CENTER)
1100+ 1
1101+ >>> console.print_box(x=0, y=5, width=12, height=1, string="┤Lower├", alignment=tcod.CENTER)
1102+ 1
1103+ >>> print(console)
1104+ <┌─┐╔═╗123/-\\
1105+ │ │║ ║456| |
1106+ └─┘╚═╝789\\-/
1107+ ┌─ Title ──┐
1108+ │ │
1109+ └─┤Lower├──┘>
10901110 """
10911111 x, y = self._pythonic_index(x, y)
10921112 if title and decoration != "┌─┐│ │└─┘":
@@ -1121,16 +1141,19 @@ def draw_frame(
11211141 decoration_ = decoration
11221142 if len(decoration_) != 9:
11231143 raise TypeError(f"Decoration must have a length of 9 (len(decoration) is {len(decoration_)}.)")
1124- lib.TCOD_console_draw_frame_rgb(
1125- x,
1126- y,
1127- width,
1128- height,
1129- decoration_,
1130- (fg,) if fg is not None else ffi.NULL,
1131- (bg,) if bg is not None else ffi.NULL,
1132- bg_blend,
1133- clear,
1144+ _check(
1145+ lib.TCOD_console_draw_frame_rgb(
1146+ self.console_c,
1147+ x,
1148+ y,
1149+ width,
1150+ height,
1151+ decoration_,
1152+ (fg,) if fg is not None else ffi.NULL,
1153+ (bg,) if bg is not None else ffi.NULL,
1154+ bg_blend,
1155+ clear,
1156+ )
11341157 )
11351158
11361159 def draw_rect(
0 commit comments