jtablesaw/tablesaw

Feature Request: Support ANSI color escape codes when printing tables

jacob-pro opened this issue · 0 comments

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)