Skip to content

Support colors in table cells #6

@jlusiardi

Description

@jlusiardi

Hi,

I would like to use https://github.com/onevcat/Rainbow to colorize cells in a TextTable.

let table = TextTable<Attributes> {
    [   
        Column(title: "Country", value: $0.country!.blue), 
        Column(title: "County", value: $0.county!.red),
    ]   
}   
table.print(result, style: Style.psql)

This result in a table where the length of the cell data in https://github.com/cfilipov/TextTable/blob/master/Sources/TextTable/TextTable.swift#L237 should only count the visible characters. The escape sequences used for colors should not be counted here:

+----------------------------+--------------------------------+
| Country                    | County                         |
+----------------------------+--------------------------------+
| Baden-Württemberg | SK Karlsruhe          |
| Baden-Württemberg | SK Ulm                |

(The colors are missing...)

Is there any way this can already be achieved or implemented?

Greetings
Joachim

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions