Skip to content

TerminalConfig

Module: terminaltexteffects.engine.terminal

Bases: BaseConfig

Configuration for the terminal.

Attributes:

Name Type Description
tab_width int

Number of spaces to use for a tab character.

xterm_colors bool

Convert any colors specified in RBG hex to the closest XTerm-256 color.

no_color bool

Disable all colors in the effect.

wrap_text bool

Wrap text wider than the canvas width.

frame_rate float

Target frame rate for the animation in frames per second. Set to 0 to disable frame rate limiting.

canvas_width int

Canvas width, set to an integer > 0 to use a specific dimension, if set to 0 the canvas width is detected automatically based on the terminal device, if set to -1 the canvas width is based on the input data width.

canvas_height int

Canvas height, set to an integer > 0 to use a specific dimension, if set to 0 the canvas height is is detected automatically based on the terminal device, if set to -1 the canvas width is based on the input data height.

anchor_canvas Literal['sw', 's', 'se', 'e', 'ne', 'n', 'nw', 'w', 'c']

Anchor point for the Canvas. The Canvas will be anchored in the terminal to the location corresponding to the cardinal/diagonal direction. Defaults to 'sw'.

anchor_effect Literal['sw', 's', 'se', 'e', 'ne', 'n', 'nw', 'w', 'c']

Anchor point for the effect within the Canvas. Effect text will anchored in the Canvas to the location corresponding to the cardinal/diagonal direction. Defaults to 'sw'.

ignore_terminal_dimensions bool

Ignore the terminal dimensions and utilize the full Canvas beyond the extents of the terminal. Useful for sending frames to another output handler.

existing_color_handling Literal['always', 'dynamic', 'ignore']

Specify handling of existing ANSI color sequences in the input data. 'always' will always use the input colors, ignoring any effect specific colors. 'dynamic' will leave it to the effect implementation to apply input colors. 'ignore' will ignore the colors in the input data. Default is 'ignore'.

reuse_canvas bool

Do not create new rows at the start of the effect. The cursor will be restored to the position of the previous canvas.

no_eol bool

Suppress the trailing newline emitted when an effect animation completes.

Source code in terminaltexteffects/engine/terminal.py
@dataclass
class TerminalConfig(BaseConfig):
    """Configuration for the terminal.

    Attributes:
        tab_width (int): Number of spaces to use for a tab character.
        xterm_colors (bool): Convert any colors specified in RBG hex to the closest XTerm-256 color.
        no_color (bool): Disable all colors in the effect.
        wrap_text (bool): Wrap text wider than the canvas width.
        frame_rate (float): Target frame rate for the animation in frames per second. Set to 0 to disable frame
            rate limiting.
        canvas_width (int): Canvas width, set to an integer > 0 to use a specific dimension, if set to 0 the canvas
            width is detected automatically based on the terminal device, if set to -1 the canvas width is based on
            the input data width.
        canvas_height (int): Canvas height, set to an integer > 0 to use a specific dimension, if set to 0 the canvas
            height is is detected automatically based on the terminal device, if set to -1 the canvas width is
            based on the input data height.
        anchor_canvas (Literal['sw','s','se','e','ne','n','nw','w','c']): Anchor point for the Canvas. The Canvas will
            be anchored in the terminal to the location corresponding to the cardinal/diagonal direction.
            Defaults to 'sw'.
        anchor_effect (Literal['sw','s','se','e','ne','n','nw','w','c']): Anchor point for the effect within the Canvas.
            Effect text will anchored in the Canvas to the location corresponding to the cardinal/diagonal direction.
            Defaults to 'sw'.
        ignore_terminal_dimensions (bool): Ignore the terminal dimensions and utilize the full Canvas beyond the extents
            of the terminal. Useful for sending frames to another output handler.
        existing_color_handling (Literal['always','dynamic','ignore']): Specify handling of existing ANSI color
            sequences in the input data. 'always' will always use the input colors, ignoring any effect specific colors.
            'dynamic' will leave it to the effect implementation to apply input colors. 'ignore' will ignore the colors
            in the input data. Default is 'ignore'.
        reuse_canvas (bool): Do not create new rows at the start of the effect. The cursor will be restored to the
            position of the previous canvas.
        no_eol (bool): Suppress the trailing newline emitted when an effect animation completes.

    """

    tab_width: int = ArgSpec(
        name="--tab-width",
        type=argutils.PositiveInt.type_parser,
        metavar=argutils.PositiveInt.METAVAR,
        default=4,
        help="Number of spaces to use for a tab character.",
    )  # pyright: ignore[reportAssignmentType]

    "int : Number of spaces to use for a tab character."

    xterm_colors: bool = ArgSpec(
        name="--xterm-colors",
        default=False,
        action="store_true",
        help="Convert any colors specified in 24-bit RBG hex to the closest 8-bit XTerm-256 color.",
    )  # pyright: ignore[reportAssignmentType]

    "bool : Convert any colors specified in 24-bit RBG hex to the closest 8-bit XTerm-256 color."

    no_color: bool = ArgSpec(
        name="--no-color",
        default=False,
        action="store_true",
        help="Disable all colors in the effect.",
    )  # pyright: ignore[reportAssignmentType]

    "bool : Disable all colors in the effect."

    terminal_background_color: Color = ArgSpec(
        name="--terminal-background-color",
        type=argutils.ColorArg.type_parser,
        default=Color("#000000"),
        metavar=argutils.ColorArg.METAVAR,
        help=(
            "The background color of you terminal. "
            "Used to determine the appropriate color for fade-in/out within effects."
        ),
    )  # type: ignore[assignment]
    "Color: User-define background color of the terminal."

    existing_color_handling: Literal["always", "dynamic", "ignore"] = ArgSpec(
        name="--existing-color-handling",
        default="ignore",
        choices=["always", "dynamic", "ignore"],
        help=(
            "Specify handling of existing 8-bit and 24-bit ANSI color sequences in the input data. 3-bit and 4-bit "
            "sequences are not supported. 'always' will always use the input colors, ignoring any effect specific "
            "colors. 'dynamic' will leave it to the effect implementation to apply input colors. 'ignore' will "
            "ignore the colors in the input data. Default is 'ignore'."
        ),
    )  # pyright: ignore[reportAssignmentType]

    (
        "Literal['always','dynamic','ignore'] : Specify handling of existing ANSI color sequences in the input data. "
        "'always' will always use the input colors, ignoring any effect specific colors. 'dynamic' will leave it to "
        "the effect implementation to apply input colors. 'ignore' will ignore the colors in the input data. "
        "Default is 'ignore'."
    )

    wrap_text: int = ArgSpec(
        name="--wrap-text",
        default=False,
        action="store_true",
        help="Wrap text wider than the canvas width.",
    )  # pyright: ignore[reportAssignmentType]
    "bool : Wrap text wider than the canvas width."

    frame_rate: int = ArgSpec(
        name="--frame-rate",
        type=argutils.NonNegativeInt.type_parser,
        default=60,
        help=(
            "Target frame rate for the animation in frames per second. Set to 0 to disable frame rate limiting. "
            "Defaults to 60."
        ),
    )  # type: ignore[assignment]

    "int : Target frame rate for the animation in frames per second. Set to 0 to disable frame rate limiting."

    canvas_width: int = ArgSpec(
        name="--canvas-width",
        metavar=argutils.CanvasDimension.METAVAR,
        type=argutils.CanvasDimension.type_parser,
        default=-1,
        help=(
            "Canvas width, set to an integer > 0 to use a specific dimension, use 0 to match the terminal width, "
            "or use -1 to match the input text width. Defaults to -1."
        ),
    )  # pyright: ignore[reportAssignmentType]

    (
        "int : Canvas width, set to an integer > 0 to use a specific dimension, if set to 0 the canvas width is "
        "detected automatically based on the terminal device, if set to -1 the canvas width is based on "
        "the input data width. Defaults to -1."
    )

    canvas_height: int = ArgSpec(
        name="--canvas-height",
        metavar=argutils.CanvasDimension.METAVAR,
        type=argutils.CanvasDimension.type_parser,
        default=-1,
        help=(
            "Canvas height, set to an integer > 0 to use a specific dimension, use 0 to match the terminal "
            "height, or use -1 to match the input text height. Defaults to -1."
        ),
    )  # pyright: ignore[reportAssignmentType]

    (
        "int : Canvas height, set to an integer > 0 to use a specific dimension, if set to 0 the canvas height "
        "is is detected automatically based on the terminal device, if set to -1 the canvas width is "
        "based on the input data height. Defaults to -1."
    )

    anchor_canvas: Literal["sw", "s", "se", "e", "ne", "n", "nw", "w", "c"] = ArgSpec(
        name="--anchor-canvas",
        choices=["sw", "s", "se", "e", "ne", "n", "nw", "w", "c"],
        default="sw",
        help=(
            "Anchor point for the canvas. The canvas will be anchored in the terminal to the location "
            "corresponding to the cardinal/diagonal direction. Defaults to 'sw'."
        ),
    )  # pyright: ignore[reportAssignmentType]

    (
        "Literal['sw','s','se','e','ne','n','nw','w','c'] : Anchor point for the canvas. The canvas will be "
        "anchored in the terminal to the location corresponding to the cardinal/diagonal direction. Defaults to 'sw'."
    )

    anchor_text: Literal["n", "ne", "e", "se", "s", "sw", "w", "nw", "c"] = ArgSpec(
        name="--anchor-text",
        choices=["n", "ne", "e", "se", "s", "sw", "w", "nw", "c"],
        default="sw",
        help=(
            "Anchor point for the text within the Canvas. Input text will anchored in the Canvas to "
            "the location corresponding to the cardinal/diagonal direction. Defaults to 'sw'."
        ),
    )  # pyright: ignore[reportAssignmentType]

    (
        "Literal['n','ne','e','se','s','sw','w','nw','c'] : Anchor point for the text within the Canvas. "
        "Input text will anchored in the Canvas to the location corresponding to the cardinal/diagonal direction. "
        "Defaults to 'sw'."
    )

    ignore_terminal_dimensions: bool = ArgSpec(
        name="--ignore-terminal-dimensions",
        default=False,
        action="store_true",
        help=(
            "Ignore the terminal dimensions and utilize the full Canvas beyond the extents of the terminal. "
            "Useful for sending frames to another output handler."
        ),
    )  # pyright: ignore[reportAssignmentType]
    (
        "bool : Ignore the terminal dimensions and utilize the full Canvas beyond the extents of the terminal. "
        "Useful for sending frames to another output handler."
    )

    reuse_canvas: bool = ArgSpec(
        name="--reuse-canvas",
        default=False,
        action="store_true",
        help=(
            "Do not create new rows at the start of the effect. The cursor will be moved up the number of rows "
            "present in the input text in an attempt to re-use the canvas. This option works best when used in "
            "a shell script. If used interactively with prompts between runs, the result is unpredictable."
        ),
    )  # pyright: ignore[reportAssignmentType]
    (
        "bool: Do not create new rows at the start of the effect. The cursor will be moved up the number of rows "
        "present in the input text in an attempt to re-use the canvas. This option works best when used in "
        "a shell script. If used interactively with prompts between runs, the result is unpredictable."
    )

    no_eol: bool = ArgSpec(
        name="--no-eol",
        default=False,
        action="store_true",
        help=("Suppress the trailing newline emitted when an effect animation completes."),
    )  # pyright: ignore[reportAssignmentType]
    ("bool : Suppress the trailing newline emitted when an effect animation completes. ")

    no_restore_cursor: bool = ArgSpec(
        name="--no-restore-cursor",
        default=False,
        action="store_true",
        help=("Do not restore cursor visibility after the effect."),
    )  # pyright: ignore[reportAssignmentType]
    ("bool : Do not restore cursor visibility after the effect.")

anchor_canvas = ArgSpec(name='--anchor-canvas', choices=['sw', 's', 'se', 'e', 'ne', 'n', 'nw', 'w', 'c'], default='sw', help="Anchor point for the canvas. The canvas will be anchored in the terminal to the location corresponding to the cardinal/diagonal direction. Defaults to 'sw'.") class-attribute instance-attribute

Literal['sw','s','se','e','ne','n','nw','w','c'] : Anchor point for the canvas. The canvas will be anchored in the terminal to the location corresponding to the cardinal/diagonal direction. Defaults to 'sw'.

anchor_text = ArgSpec(name='--anchor-text', choices=['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw', 'c'], default='sw', help="Anchor point for the text within the Canvas. Input text will anchored in the Canvas to the location corresponding to the cardinal/diagonal direction. Defaults to 'sw'.") class-attribute instance-attribute

Literal['n','ne','e','se','s','sw','w','nw','c'] : Anchor point for the text within the Canvas. Input text will anchored in the Canvas to the location corresponding to the cardinal/diagonal direction. Defaults to 'sw'.

canvas_height = ArgSpec(name='--canvas-height', metavar=(argutils.CanvasDimension.METAVAR), type=(argutils.CanvasDimension.type_parser), default=(-1), help='Canvas height, set to an integer > 0 to use a specific dimension, use 0 to match the terminal height, or use -1 to match the input text height. Defaults to -1.') class-attribute instance-attribute

int : Canvas height, set to an integer > 0 to use a specific dimension, if set to 0 the canvas height is is detected automatically based on the terminal device, if set to -1 the canvas width is based on the input data height. Defaults to -1.

canvas_width = ArgSpec(name='--canvas-width', metavar=(argutils.CanvasDimension.METAVAR), type=(argutils.CanvasDimension.type_parser), default=(-1), help='Canvas width, set to an integer > 0 to use a specific dimension, use 0 to match the terminal width, or use -1 to match the input text width. Defaults to -1.') class-attribute instance-attribute

int : Canvas width, set to an integer > 0 to use a specific dimension, if set to 0 the canvas width is detected automatically based on the terminal device, if set to -1 the canvas width is based on the input data width. Defaults to -1.

existing_color_handling = ArgSpec(name='--existing-color-handling', default='ignore', choices=['always', 'dynamic', 'ignore'], help="Specify handling of existing 8-bit and 24-bit ANSI color sequences in the input data. 3-bit and 4-bit sequences are not supported. 'always' will always use the input colors, ignoring any effect specific colors. 'dynamic' will leave it to the effect implementation to apply input colors. 'ignore' will ignore the colors in the input data. Default is 'ignore'.") class-attribute instance-attribute

Literal['always','dynamic','ignore'] : Specify handling of existing ANSI color sequences in the input data. 'always' will always use the input colors, ignoring any effect specific colors. 'dynamic' will leave it to the effect implementation to apply input colors. 'ignore' will ignore the colors in the input data. Default is 'ignore'.

frame_rate = ArgSpec(name='--frame-rate', type=(argutils.NonNegativeInt.type_parser), default=60, help='Target frame rate for the animation in frames per second. Set to 0 to disable frame rate limiting. Defaults to 60.') class-attribute instance-attribute

int : Target frame rate for the animation in frames per second. Set to 0 to disable frame rate limiting.

ignore_terminal_dimensions = ArgSpec(name='--ignore-terminal-dimensions', default=False, action='store_true', help='Ignore the terminal dimensions and utilize the full Canvas beyond the extents of the terminal. Useful for sending frames to another output handler.') class-attribute instance-attribute

bool : Ignore the terminal dimensions and utilize the full Canvas beyond the extents of the terminal. Useful for sending frames to another output handler.

no_color = ArgSpec(name='--no-color', default=False, action='store_true', help='Disable all colors in the effect.') class-attribute instance-attribute

bool : Disable all colors in the effect.

no_eol = ArgSpec(name='--no-eol', default=False, action='store_true', help='Suppress the trailing newline emitted when an effect animation completes.') class-attribute instance-attribute

bool : Suppress the trailing newline emitted when an effect animation completes.

no_restore_cursor = ArgSpec(name='--no-restore-cursor', default=False, action='store_true', help='Do not restore cursor visibility after the effect.') class-attribute instance-attribute

bool : Do not restore cursor visibility after the effect.

reuse_canvas = ArgSpec(name='--reuse-canvas', default=False, action='store_true', help='Do not create new rows at the start of the effect. The cursor will be moved up the number of rows present in the input text in an attempt to re-use the canvas. This option works best when used in a shell script. If used interactively with prompts between runs, the result is unpredictable.') class-attribute instance-attribute

bool: Do not create new rows at the start of the effect. The cursor will be moved up the number of rows present in the input text in an attempt to re-use the canvas. This option works best when used in a shell script. If used interactively with prompts between runs, the result is unpredictable.

tab_width = ArgSpec(name='--tab-width', type=(argutils.PositiveInt.type_parser), metavar=(argutils.PositiveInt.METAVAR), default=4, help='Number of spaces to use for a tab character.') class-attribute instance-attribute

int : Number of spaces to use for a tab character.

terminal_background_color = ArgSpec(name='--terminal-background-color', type=(argutils.ColorArg.type_parser), default=(Color('#000000')), metavar=(argutils.ColorArg.METAVAR), help='The background color of you terminal. Used to determine the appropriate color for fade-in/out within effects.') class-attribute instance-attribute

Color: User-define background color of the terminal.

wrap_text = ArgSpec(name='--wrap-text', default=False, action='store_true', help='Wrap text wider than the canvas width.') class-attribute instance-attribute

bool : Wrap text wider than the canvas width.

xterm_colors = ArgSpec(name='--xterm-colors', default=False, action='store_true', help='Convert any colors specified in 24-bit RBG hex to the closest 8-bit XTerm-256 color.') class-attribute instance-attribute

bool : Convert any colors specified in 24-bit RBG hex to the closest 8-bit XTerm-256 color.