diff --git a/kittens/dnd/__init__.py b/kittens/dnd/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/kittens/dnd/main.go b/kittens/dnd/main.go new file mode 100644 index 000000000..bcc6196d0 --- /dev/null +++ b/kittens/dnd/main.go @@ -0,0 +1,22 @@ +// License: GPLv3 Copyright: 2022, Kovid Goyal, + +package dnd + +import ( + "fmt" + + "github.com/kovidgoyal/kitty/tools/cli" + "github.com/kovidgoyal/kitty/tools/tty" +) + +var _ = fmt.Append +var debugprintln = tty.DebugPrintln +var _ = debugprintln + +func dnd_main(cmd *cli.Command, opts *Options, args []string) (rc int, err error) { + return 0, nil +} + +func EntryPoint(parent *cli.Command) { + create_cmd(parent, dnd_main) +} diff --git a/kittens/dnd/main.py b/kittens/dnd/main.py new file mode 100644 index 000000000..ba5d337d2 --- /dev/null +++ b/kittens/dnd/main.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python +# License: GPL v3 Copyright: 2018, Kovid Goyal + +import sys + +OPTIONS = r''' +--drag +type=list +When starting a drag, use the specified file as the data source for the specified +MIME type. Syntax is: mime-type:path/to/file. For example image/jpeg:mypic.jpg +Can be specified multiple times to drag multiple MIME types. + + +--drop +type=list +When receiving a drop, use the specified file as the data destination for the specified +MIME type. Syntax is: mime-type:path/to/file. For example image/jpeg:mypic.jpg +Can be specified multiple times to enable receiving multiple MIME types. + + +--confirm-drop-overwrite +type=bool-set +Ask for confirmation when dropping text/uri-list data if the drop will cause any existing +files to be overwritten. Note that confirmation is asked only for actual file conflicts, non +conflicting files are automatically created, always. +'''.format + +help_text = '''\ +Perform drag and drop operations, even over SSH. + +Any arguments on the command line are assumed to be files and directories to drag. +They will be dragged as the text/uri-list MIME type which can then be dropped into any +file manager or similar program to copy the files. + +If the text/uri-list MIME type is dropped onto this window, the files and directories in it are +copied into the current working directory. + +If data is present on STDIN it is set as text/plain when dragging. Any text/plain data that is +dropped onto this window is output to STDOUT, if STDOUT is connected to a file, otherwise it +is discarded. +''' + +usage = '[files to drag]' +if __name__ == '__main__': + raise SystemExit('This should be run as kitten dnd') +elif __name__ == '__doc__': + from kitty.simple_cli_definitions import CompletionSpec + cd = sys.cli_docs # type: ignore + cd['usage'] = usage + cd['options'] = OPTIONS + cd['help_text'] = help_text + cd['short_desc'] = 'Perform drag and drop operations, even over SSH' + cd['args_completion'] = CompletionSpec.from_string('type:file mime:* group:Files') diff --git a/tools/cmd/tool/main.go b/tools/cmd/tool/main.go index 0efae28f5..597fb5bea 100644 --- a/tools/cmd/tool/main.go +++ b/tools/cmd/tool/main.go @@ -12,6 +12,7 @@ import ( "github.com/kovidgoyal/kitty/kittens/command_palette" "github.com/kovidgoyal/kitty/kittens/desktop_ui" "github.com/kovidgoyal/kitty/kittens/diff" + "github.com/kovidgoyal/kitty/kittens/dnd" "github.com/kovidgoyal/kitty/kittens/hints" "github.com/kovidgoyal/kitty/kittens/hyperlinked_grep" "github.com/kovidgoyal/kitty/kittens/icat" @@ -52,6 +53,8 @@ func KittyToolEntryPoints(root *cli.Command) { edit_in_kitty.EntryPoint(root) // clipboard clipboard.EntryPoint(root) + // dnd + dnd.EntryPoint(root) // icat icat.EntryPoint(root) // ssh