Skip to content

Feature Request: Support ANSI color escape codes when printing tables  #1243

Open
@jacob-pro

Description

@jacob-pro

First, thank you for this useful library.

Feature Request:

ANSI escape codes can be used for controlling text colour.

Whilst these can currently be included in a string column, and will show with colour when printed in a compatible terminal, the table does not print correctly due to the cell width being calculated incorrectly.

/**
* Returns the column widths required to print the header and data
*
* @param headers the headers to print
* @param data the data items to print
* @return the required column widths
*/
private static int[] getWidths(String[] headers, String[][] data) {

It would be awesome if this library allowed for either:

a. Easily overriding the cell width used in the DataFramePrinter instead of calling .length directly. (low effort)
b. Detecting ANSI escape codes in string columns and correctly counting the actual display width (higher effort)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions