@@ -352,6 +352,61 @@ If ``t=e`` or ``t=E`` escape codes are sent to the terminal before the drag is
352352started and the terminal has responded with ``t=E ; OK ``, the terminal must respond
353353with ``t=E ; EINVAL `` and abort the drag.
354354
355+ Dragging to remote machines
356+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
357+
358+ To support dragging files to remote machines, when requesting the data for the
359+ ``text/uri-list `` MIME type, terminal emulators can add the ``Y=1 `` key. On
360+ receipt of this key, the client should first send the ``text/uri-list `` as
361+ normal and then a series of responses for every ``file:// `` URL type in the
362+ list of the form::
363+
364+ OSC _dnd_code ; t=k:x=idx:m=0 or 1 ; base64 encoded file data ST
365+ OSC _dnd_code ; t=k:x=idx:X=1:m=0 or 1 ; base64 encoded symlink target ST
366+ OSC _dnd_code ; t=k:x=idx:X=handle:m=0 or 1 ; base64 encoded null separated list of directory entries ST
367+
368+ These represent possibly chunked data for files, symlinks and directories, as
369+ denoted by the ``X `` key. As always, end of data is indicated by an escape code
370+ with ``m=0 `` and no payload. ``idx `` is the one based index into the list of
371+ entries in the ``text/uri-list `` MIME type. ``file:// `` URLs that point to
372+ symlinks must be resolved to files or directories and sent. So actual symlinks
373+ will appear only when recursing through directories as described below. Only
374+ regular files should be sent.
375+
376+ Terminals should write the transmitted data into a temporary directory
377+ and replace the entries in the ``text/uri-list `` data with the transmitted
378+ files/directories.
379+
380+ Every directory must be transmitted with ``X=handle ``. The payload
381+ is a null separated list of regular files, directories and symlinks in the
382+ directory. ``handle `` is an integer other than ``0 `` or ``1 ``
383+ that serves as an identifier for the directory. Directories must be traversed
384+ in breadth first order. The children of a directory are reported by
385+ adding ``Y=parent-handle:y=num `` to the escape codes above. Here
386+ ``parent-handle `` is the handle of the directory being traversed and ``num ``
387+ is the one based index into the list of entries in the directory.
388+
389+ Once all data is transmitted, the client informs the terminal emulator of
390+ completion with::
391+
392+ OSC _dnd_code ; t=k ; ST
393+
394+ If any error occurs in the client while reading the data, it can inform
395+ the terminal using::
396+
397+ OSC _dnd_code ; t=E ; POSIX error name ST
398+
399+ The terminal must then abort the drag.
400+
401+ Terminals are free to impose resource limits on how much data they accept,
402+ if a limit is breached or some errors occurs, they can abort the drag and
403+ inform the client of it with::
404+
405+ OSC _dnd_code ; t=E ; POSIX error name ST
406+
407+ The error code for too many resources is ``EMFILE `` for IO errors is ``EIO ``
408+ and so on.
409+
355410Multiplexers
356411-----------------
357412
@@ -383,6 +438,7 @@ Key Value Default Description
383438 ``P `` - Change drag image or start drag
384439 ``e `` - a drag offer event occurred
385440 ``E `` - a drag offer data error occurred
441+ ``k `` - data for uri-list items in drag offer
386442
387443``m`` Chunking indicator ``0`` ``0`` or ``1``
388444
0 commit comments