akermu / emacs-libvterm

Emacs libvterm integration
GNU General Public License v3.0
1.72k stars 137 forks source link

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

Open Inc0n opened 2 years ago

Inc0n commented 2 years ago

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.

Sbozzolo commented 2 years ago

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.

Inc0n commented 2 years ago

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.