How is coloured text stored in the clipboard?

1

I've been using xclip to copy text to and from terminal. I was curious how it would handle coloured text from non-terminal applications such as google docs, and libreoffice

When copying from one of these document editors to another the text colour remains, however when I use xclip -o --clipboard there doesn't seem to be any attributes or escape codes to the copied text; only the copied text is displayed.

This makes sense for most uses, you wouldn't want random escape sequences or attributes appearing within your copied text. Except when you do.

I've also tried copying some red text and then directing xclip output to a .doc file which is otherwise able to support coloured text -xclip likely does not support it.

My subsequent question is, how (if at all) can I access/view the escape sequences/colour attributes/other-representation associated with coloured text -in the clipboard?

I'm aware that terminal colour to terminal colour typically uses ANSI set graphics mode escape sequences e.g. \033[1m for bold, while doc/text editors probably use a different standard.

Think this is more an X thing than terminal thing, but in case it matters I tested & found similar behaviour on xfce4-terminal & gnome-terminal.

Anroca

Posted 2019-01-29T01:27:25.947

Reputation: 11

Checked the source code? Everything should be right there, in xclip &/or your desktop – Xen2050 – 2019-01-29T09:35:16.650

@Xen2050 looking at the source didn't reveal anything to suggest attributes were being stripped. I'd be willing to hack at xlib to get something working, but without knowing the standards associated with the behaviour I doubt I'd achieve much.

– Anroca – 2019-01-30T00:33:22.220

No answers