You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If using ANSI colors in a table formatting function, the columns are not padded correctly due to the fact that the ANSI color commands are included in the length of the string:
In [1]: fromtermcolorimportcoloredIn [2]: deffmt(x):
...: ifx>0:
...: returncolored(str(x), 'green')
...: else:
...: returncolored(str(x), 'red')
...:
In [4]: fromastropy.tableimportTablet=In [5]: t=Table()
In [6]: t['a'] = [-1, 1, 0, 3, -3]
In [7]: t['b'] = [-1, 1, 0, 3, -3]
In [8]: tOut[8]:
<Tablelength=5>abint64int64-----------1-1110033-3-3In [9]: t['a'].format=fmtIn [10]: t['b'].format=fmtIn [11]: tOut[11]:
<Tablelength=5>abint64int64-----------------------1-1110033-3-3
The color works correctly though:
It would be nice if we could do the right thing™️ here though and auto-strip the ANSI color commands from strings when figuring out the width of the columns. Feel free to close this if it would be much too difficult though.
The text was updated successfully, but these errors were encountered:
Is there any kind of fast library that can strip out ANSI color commands or render ANSI text as plain ASCII in order to compute length? I think that without a pre-existing library to do the job (fast) this would be a bit of work and would impact performance.
If using ANSI colors in a table formatting function, the columns are not padded correctly due to the fact that the ANSI color commands are included in the length of the string:
The color works correctly though:
It would be nice if we could do the right thing™️ here though and auto-strip the ANSI color commands from strings when figuring out the width of the columns. Feel free to close this if it would be much too difficult though.
The text was updated successfully, but these errors were encountered: