Skip to content

Drag and Drop files or folders #440

Closed

Description

@GoogleCodeExporter
It would be awesome to support the drag&drop of files/folders as is it aleady 
supported for path paste. 

The idea is to send a command to the terminal in the case of a Drag&Drop event 
. It would be nice to detect which program is currently running on the terminal 
and send the appropriate command that can be registred in .minttyrc

For instance we could have this configuration

# <program>,<file/folder>,<wildcard>,<command>
DropAction=vim,file,*,'<esc>:e $0<cr>'
DropAction=bash,file,'*.m,octave -i --persist $0<cr>'
DropAction=bash,folder,,'cd $0<cr>'

Original issue reported on code.google.com by [email protected] on 30 Jan 2015 at 8:42

Activity

  1. mintty commented on Sep 4, 2015

    @mintty
    Owner

    The current feature just drops any dragged text into mintty as input, to whatever application is running.
    It is not possible in a reliable way to direct that input to a specific application (in which case application-specific additions could be inserted).

    The reason is that there is no way to determine which application is currently handling terminal input. From a process point of view, there is a tree of processes (often beginning with a shell) running inside the terminal. It can have multiple leaves and it is not even sure whether it's one of the leaves accepting input (imagine an editor having started some filter processes). It is even possible that multiple processes are trying to capture input from the terminal.

    Intending to close the issue.

  2. Artoria2e5 commented on Mar 1, 2016

    @Artoria2e5

    How about generalizing the 'program-name' part, and call it 'scheme-name'? Some control sequences can then be added to tell mintty which drag&drop-encoding scheme to use (much like the \e]0 thing), or potentially just to pass a line of 'anonymous' scheme. Users will then be able to use shell functionalities like PROMPT_COMMAND and trap foo_func DEBUG to manipulate it.

    Naturally after saything this people will think about applying appropriate escapes automatically by mintty, and I guess people will be asking for sed-like replacing functionalities soon (just kidding)

  3. mintty commented on Mar 1, 2016

    @mintty
    Owner

    Hmm, nice idea at first glance.
    I do see some security issues here, however: an escape sequence could simply switch mintty into a mode that issues actions (like commands) in a situation it shouldn't. How could that be dealt with?
    In general, any such sequences that trigger action from the terminal are considered security-relevant, that's why most other terminals (see xterm) meanwhile disable them by default.
    There are more issues: how to configure it? And where's the convincing use case that would justify the implementation effort...?

  4. mintty commented on Mar 24, 2016

    @mintty
    Owner

    I could imagine a variant of "bracketed paste mode":
    If "bracketed drop mode" is activated, the dropped text would be embedded in escape sequences.
    This would enable a cooperating program to detect the leading escape sequence and handle the drop text accordingly.
    It would still not facilitate the injection of arbitrary commands, and that's on purpose.
    Comments welcome.

  5. mintty commented on May 4, 2016

    @mintty
    Owner

    For the records, I have to revise the previous statement about identifying the terminal handling process; it is apparently possible to determine the terminal foreground process, so an application-specific mapping would in theory be possible.
    This does not mean I consider it useful now; security concerns still apply. I'll probably implement a bracketed drop mode. Not sure yet, whether it should automatically be enabled with bracketed paste mode or be an explicit mode, and whether the sequence sent should be the same as for bracketed paste or it's useful to distinguish the two. Comments welcome.

  6. changed the title [-]Drag on Drop files or folders[/-] [+]Drag and Drop files or folders[/+] on May 6, 2016
  7. mintty commented on May 6, 2016

    @mintty
    Owner

    In bracketed paste mode, drag-and-drop now embeds the file/folder like other pasted contents.
    Should anyone think it's useful to distinguish drag-and-drop from other pasting, or to distinguishing drag-and-drop file/folder from other text (e.g. URL), specific modes can be provided for that, likely using the same escape sequence with an additional parameter.

  8. mintty commented on May 22, 2016

    @mintty
    Owner

    Released bracketed-paste-mode embedding of drag-and-drop contents in 2.3.7.

  9. jordiFrei commented on Jun 7, 2016

    @jordiFrei

    I would really love the proposed feature.How does it work, how can we specify the specific brackets

    Thanks for your efforts

  10. mintty commented on Jun 7, 2016

    @mintty
    Owner

    Do you want to distinguish different kinds of contents or just drag-and-drop from other pasting? Any need to distinguish mouse pasting from keyboard shortcut pasting (hopefully not)?
    The current paste embedding sequence is ESC[200~. A drag-and-drop embedding sequence could be like ESC[200;2~.
    The sequence to set/reset bracketed paste mode is ESC[?2004h/l.
    A sequence to enable drag-and-drop specific bracketed paste mode could be ESC[?2004;2h.

  11. reopened this on Jun 7, 2016
  12. jordiFrei commented on Jun 7, 2016

    @jordiFrei

    Sorry, it is hard for me to understand these commands. I get it sends ESC but the rest of the command I don't understand. If you can direct me to some link where they are explained it would be great

    Do you want to distinguish different kinds of contents or just drag-and-drop from other pasting?

    just drag-and-drop from other pasting

    Here is what I am looking for:
    I use vim within mintty terminal. I would like to be able to drag and drop a file into vim (within mintty) and that the file opens in a new tab or just opens. At the moment, if I want to drag&drop a file into vim, I need to write ':e' or ':tabe' in vim and then drag and drop the file. It would be great that when I drag and drop a file in mintty/vim it adds ':e' or ':tabe' before the file path and 'CR' at the end so the file just opens pretty much like with any other text editor. other paste commands from mouse or keyboard should work as usual.

    Thank you very much

  13. mintty commented on Jun 9, 2016

    @mintty
    Owner

    For the current solution (that could be extended to distinguish drag-and-drop), the application would need to cooperate and detect the escape sequences.
    The idea of issuing application-specific commands, on the other hand, was discussed before and not pursued for security concerns, sorry.

  14. mintty commented on Mar 11, 2017

    @mintty
    Owner

    Foreground-application-specific drop patterns release with 2.7.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions