Skip to content

Support clipboard via OSC 52 #4458

Description

@mc-butler

Important

This issue was migrated from Trac:

Origin https://midnight-commander.org/ticket/4458
Reporter yurikhan (yuri.v.khan@….com)
Mentions egmont (@egmontkob)

Many terminal emulators, starting with Xterm, conditionally allow access to the system clipboard via an escape sequence. In comparison with xclip-based solution (#30), this works transparently when you ssh around, without X11 forwarding and without having to install xclip on each server you manage.

To write to the clipboard, an application sends ESC ] 5 2 ; c ; <content> ESC \, where <content> is base64-encoded. (BEL can also be used as terminator.)

To read the clipboard, an application sends ESC ] 5 2 ; c ; ? ESC \. A conforming terminal will respond by sending ESC ] 5 2 ; c ; <content> ESC \, again, with <content> base64-encoded. (If the request uses BEL instead of ESC \, the terminal’s response will typically also be terminated with BEL.)

A non-supporting but ANSI-conforming terminal will ignore the unsupported OSC sequence until the ESC \ or BEL terminator.

I do not think there is a termcap/terminfo capability advertising support, so it would probably have to be a user option. Alternatively, mc could unconditionally put copied content into both ~/.local/share/mc/mcedit/mcedit.clip and send the OSC sequence; when pasting, first send the request, and if no response within a few milliseconds, fall back to reading ~/.local/share/mc/mcedit/mcedit.clip.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues not related to a specific subsystemprio: mediumHas the potential to affect progress

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions