tablewriter icon indicating copy to clipboard operation
tablewriter copied to clipboard

support ANSI OSC escapes as well as CSI colors

Open 007 opened this issue 1 year ago • 4 comments

Slightly more complete fix than #206, not sure how you feel about detail-vs-complexity.

CC @tucksaun for potential review

007 avatar Jul 06 '23 20:07 007

does it really make sense to support other OSCs when displaying a table? I mean... most of them would probably be used outside of a table context don't you think?

tucksaun avatar Jul 10 '23 16:07 tucksaun

They'll be interpreted / not-displayed regardless of how the table is printed, does it make sense to make wonky tables whether or not you know or care what the codes are doing? None of these are filtering codes to remove them for printing, just for determining column width.

I haven't been able to find a definitive list of other OSCs that might apply. MinTTY CtrlSeqs wiki seems close, in that it enumerates quite a few. I agree that the majority are likely global / system state, but could see even some of those as useful embedded inline:

  • Wide characters seem like potentially useful escapes embedded within text
  • Emoji style might change the display of those types within a cell? From the description it's unclear how that's intended to be interpreted.
  • Locale might be significant, but more likely would be ignored or embedded in Unicode for e.g. Arabic RTL text
  • Window title set could be used for fun or for nefarious purposes, setting the window title to the "highest" row title for some corresponding value
  • Scroll markers could certainly be used along with colors for something like an error display
  • Audio data shouldn't make a 3k-column-wide table just because someone embedded a beep to draw attention to something

007 avatar Jul 13 '23 21:07 007

if the goal is to support all those use cases when adding values to the tab then the regex LGTM 👍 Though we probably want to avoid rebuilding it on each call to DisplayWidth

tucksaun avatar Aug 11 '23 12:08 tucksaun

cc @olekukonko I'm quite a bit behind schedule on updating this, can you 👀 and see if this makes sense?

If so, please merge and tag a new release as requested from https://github.com/olekukonko/tablewriter/pull/205#issuecomment-1739105385, I'd be very happy to get these into our environment.

007 avatar Feb 05 '24 18:02 007