I have a program that prints tab-formatted output. (SO renders tabs below as spaces, in question edit mode it is tabs.)

Some Key:       Value
Another:        Different value

When I run this program as subprocess, I intentionally prepend >: in front of every line, to distinguish what is my output and what is coming from the subprocess. Problem is, prepending these two chars sometimes breaks the column alignment.

>: Some Key:        Value
>: Another:     Different value

Is there a way to preserve the alignment while adding few characters in front of the lines? Ideally, I would want not to introduce tabs to outputs that originally did not contain tabs. Also, I am printing the output line by line as the subprocess is running, so in the beginning I might not yet know if it will produce tabs or not.

I looked at Unicode, if there is some magic hiding there, and found nothing likely.

I also investigated the TBC control sequence https://terminalguide.namepad.de/seq/csi_sg/. My outputs go into Jenkins build console, so I can plausibly use ANSI control sequences.

0

There are 0 best solutions below