emacs-libvterm icon indicating copy to clipboard operation
emacs-libvterm copied to clipboard

Would it be possible for vterm to display raw ansi color codes in output?

Open Inc0n opened this issue 3 years ago • 2 comments

Currently, I have made a custom ob-shell package that integration of shell and org babel, which allows for ansi-colored results output as a result of the ob-shell src block execute, using ansi-color-for-comint-mode.

Now I am trying the same for vterm, the buffer-substring shows that the substring are fontified with properties, however, org babel strips those properties once the results are inserted.

This lead me back to try to figure out a way to get raw ansi color codes in vterm output.

Inc0n avatar Jun 23 '22 11:06 Inc0n

I am not sure if I understand, but vterm should correctly respect ansi colors, e.g.: echo -e "\033[31m Hello World" is printed as red.

Sbozzolo avatar Jun 26 '22 04:06 Sbozzolo

Sorry, it seems that my request isn't entirely very clear. Here is my more lengthy explanation, please go on ahead to the second heading first, for a quick summary.

Reason/Background for this issue/request

What I would want for a better integration between org babel and vterm, would be that text-properties of the buffer string to be preserved after extracted from vterm buffer and inserted back into the org file (session).

The problem is org babel removes all text properties, filter these results.

Desired new feature for vterm

If vterm can, instead of (using your example) echo -e "\033[31m Hello World" is printed as red, print it as is, e.g. just \033[31m Hello World. So that so the raw ansi color code is "preserved".

How this new feature can help with my case

Now buffer-substring will return \033[31m Hello World instead of Hello World with red foreground text property, and org babel will not strip away the text property information and once the result is inserted back into the org file, ansi-color-apply-on-region can be used to translate the string back with text property.

Inc0n avatar Jun 26 '22 14:06 Inc0n