wijjit.terminal.ansi.clip_to_width

wijjit.terminal.ansi.clip_to_width(text, width, ellipsis='...')[source]

Clip text to specified width, preserving ANSI codes.

This clips the visible text to the specified width while preserving any ANSI escape sequences in the output.

Parameters:
  • text (str) – Text to clip

  • width (int) – Maximum visible width

  • ellipsis (str) – Ellipsis to append if text is clipped

Returns:

Clipped text with ANSI codes preserved

Return type:

str