@@ -122,7 +122,7 @@ def __init__(
122
122
) -> None :
123
123
"""Initialize the console."""
124
124
self ._key_color : tuple [int , int , int ] | None = None
125
- self ._order = tcod ._internal .verify_order (order )
125
+ self ._order : Literal [ "C" , "F" ] = tcod ._internal .verify_order (order )
126
126
if buffer is not None :
127
127
if self ._order == "F" :
128
128
buffer = buffer .transpose ()
@@ -345,53 +345,90 @@ def rgb(self) -> NDArray[Any]:
345
345
"""
346
346
return self .rgba .view (self ._DTYPE_RGB )
347
347
348
+ _DEPRECATE_CONSOLE_DEFAULTS_MSG = """Console defaults have been deprecated.
349
+ Consider one of the following:
350
+
351
+ # Set parameters once then pass them as kwargs
352
+ DEFAULT_COLOR = {"bg": (0, 0, 127), "fg": (127, 127, 255)}
353
+ console.print(x, y, string, **DEFAULT_COLOR)
354
+
355
+ # Clear the console to a color and then skip setting colors on printing/drawing
356
+ console.clear(fg=(127, 127, 255), bg=(0, 0, 127))
357
+ console.print(x, y, string, fg=None)
358
+ """
359
+
348
360
@property
361
+ @deprecated (_DEPRECATE_CONSOLE_DEFAULTS_MSG , category = FutureWarning )
349
362
def default_bg (self ) -> tuple [int , int , int ]:
350
- """Tuple[int, int, int]: The default background color."""
363
+ """Tuple[int, int, int]: The default background color.
364
+
365
+ .. deprecated:: 8.5
366
+ These should not be used. Prefer passing defaults as kwargs.
367
+
368
+ .. code-block::
369
+
370
+ DEFAULT_COLOR = {"bg": (0, 0, 127), "fg": (127, 127, 255)}
371
+ console.print(x, y, string, **DEFAULT_COLOR)
372
+ """
351
373
color = self ._console_data .back
352
374
return color .r , color .g , color .b
353
375
354
376
@default_bg .setter
355
- @deprecated ("Console defaults have been deprecated." , category = FutureWarning )
377
+ @deprecated (_DEPRECATE_CONSOLE_DEFAULTS_MSG , category = FutureWarning )
356
378
def default_bg (self , color : tuple [int , int , int ]) -> None :
357
379
self ._console_data .back = color
358
380
359
381
@property
382
+ @deprecated (_DEPRECATE_CONSOLE_DEFAULTS_MSG , category = FutureWarning )
360
383
def default_fg (self ) -> tuple [int , int , int ]:
361
- """Tuple[int, int, int]: The default foreground color."""
384
+ """Tuple[int, int, int]: The default foreground color.
385
+
386
+ .. deprecated:: 8.5
387
+ These should not be used. Prefer passing defaults as kwargs.
388
+ """
362
389
color = self ._console_data .fore
363
390
return color .r , color .g , color .b
364
391
365
392
@default_fg .setter
366
- @deprecated ("Console defaults have been deprecated." , category = FutureWarning )
393
+ @deprecated (_DEPRECATE_CONSOLE_DEFAULTS_MSG , category = FutureWarning )
367
394
def default_fg (self , color : tuple [int , int , int ]) -> None :
368
395
self ._console_data .fore = color
369
396
370
397
@property
398
+ @deprecated (_DEPRECATE_CONSOLE_DEFAULTS_MSG , category = FutureWarning )
371
399
def default_bg_blend (self ) -> int :
372
- """int: The default blending mode."""
400
+ """int: The default blending mode.
401
+
402
+ .. deprecated:: 8.5
403
+ These should not be used. Prefer passing defaults as kwargs.
404
+ """
373
405
return self ._console_data .bkgnd_flag # type: ignore
374
406
375
407
@default_bg_blend .setter
376
- @deprecated ("Console defaults have been deprecated." , category = FutureWarning )
408
+ @deprecated (_DEPRECATE_CONSOLE_DEFAULTS_MSG , category = FutureWarning )
377
409
def default_bg_blend (self , value : int ) -> None :
378
410
self ._console_data .bkgnd_flag = value
379
411
380
412
@property
413
+ @deprecated (_DEPRECATE_CONSOLE_DEFAULTS_MSG , category = FutureWarning )
381
414
def default_alignment (self ) -> int :
382
- """int: The default text alignment."""
415
+ """int: The default text alignment.
416
+
417
+ .. deprecated:: 8.5
418
+ These should not be used. Prefer passing defaults as kwargs.
419
+ """
383
420
return self ._console_data .alignment # type: ignore
384
421
385
422
@default_alignment .setter
386
- @deprecated ("Console defaults have been deprecated." , category = FutureWarning )
423
+ @deprecated (_DEPRECATE_CONSOLE_DEFAULTS_MSG , category = FutureWarning )
387
424
def default_alignment (self , value : int ) -> None :
388
425
self ._console_data .alignment = value
389
426
390
427
def __clear_warning (self , name : str , value : tuple [int , int , int ]) -> None :
391
428
"""Raise a warning for bad default values during calls to clear."""
392
429
warnings .warn (
393
430
f"Clearing with the console default values is deprecated.\n Add { name } ={ value !r} to this call." ,
394
- DeprecationWarning ,
431
+ FutureWarning ,
395
432
stacklevel = 3 ,
396
433
)
397
434
@@ -737,8 +774,8 @@ def print_frame( # noqa: PLR0913
737
774
explicit.
738
775
"""
739
776
self .__deprecate_defaults ("draw_frame" , bg_blend )
740
- string = _fmt (string ) if string else ffi .NULL
741
- _check (lib .TCOD_console_printf_frame (self .console_c , x , y , width , height , clear , bg_blend , string ))
777
+ string_ : Any = _fmt (string ) if string else ffi .NULL
778
+ _check (lib .TCOD_console_printf_frame (self .console_c , x , y , width , height , clear , bg_blend , string_ ))
742
779
743
780
def blit ( # noqa: PLR0913
744
781
self ,
0 commit comments