columnize icon indicating copy to clipboard operation
columnize copied to clipboard

solve issues when display with terminal color

Open funkygao opened this issue 8 years ago • 1 comments

before this fix, the output was not aligned correctly

funkygao avatar Dec 24 '16 06:12 funkygao

Hey @funkygao, thanks for the PR. I have a few concerns about this:

  1. Performance is a factor, as I mentioned in a (recently) closed PR here. This logic has to pass over each character. I have not had the time to run the benchmark against this branch myself, but I am guessing there will be a good difference here, and I'm trying to avoid negating all of the performance optimization we did in #10. One thought would be to completely prune out the color codes prior to checking the length with a pre-compiled regular expression or similar. As I mentioned in the above linked comment, we might need to provide an option to enable/disable the color code detection so that systems which produce huge amounts of output don't become slow as a result.

  2. I am not convinced that m invariably indicates the end of a color sequence code. I'll admit I am not an expert in this area, but IIRC there is an escaping / terminal width calculation problem which can manifest if the color code is not enclosed in \[\]. We should be certain that this is the right way to detect the end of the color code for that case.

ryanuber avatar Jan 11 '17 01:01 ryanuber