mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-28 03:01:57 +02:00
Skeleton for dnd kitten
This commit is contained in:
0
kittens/dnd/__init__.py
Normal file
0
kittens/dnd/__init__.py
Normal file
22
kittens/dnd/main.go
Normal file
22
kittens/dnd/main.go
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
// License: GPLv3 Copyright: 2022, Kovid Goyal, <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
53
kittens/dnd/main.py
Normal file
53
kittens/dnd/main.py
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
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')
|
||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/kovidgoyal/kitty/kittens/command_palette"
|
"github.com/kovidgoyal/kitty/kittens/command_palette"
|
||||||
"github.com/kovidgoyal/kitty/kittens/desktop_ui"
|
"github.com/kovidgoyal/kitty/kittens/desktop_ui"
|
||||||
"github.com/kovidgoyal/kitty/kittens/diff"
|
"github.com/kovidgoyal/kitty/kittens/diff"
|
||||||
|
"github.com/kovidgoyal/kitty/kittens/dnd"
|
||||||
"github.com/kovidgoyal/kitty/kittens/hints"
|
"github.com/kovidgoyal/kitty/kittens/hints"
|
||||||
"github.com/kovidgoyal/kitty/kittens/hyperlinked_grep"
|
"github.com/kovidgoyal/kitty/kittens/hyperlinked_grep"
|
||||||
"github.com/kovidgoyal/kitty/kittens/icat"
|
"github.com/kovidgoyal/kitty/kittens/icat"
|
||||||
@@ -52,6 +53,8 @@ func KittyToolEntryPoints(root *cli.Command) {
|
|||||||
edit_in_kitty.EntryPoint(root)
|
edit_in_kitty.EntryPoint(root)
|
||||||
// clipboard
|
// clipboard
|
||||||
clipboard.EntryPoint(root)
|
clipboard.EntryPoint(root)
|
||||||
|
// dnd
|
||||||
|
dnd.EntryPoint(root)
|
||||||
// icat
|
// icat
|
||||||
icat.EntryPoint(root)
|
icat.EntryPoint(root)
|
||||||
// ssh
|
// ssh
|
||||||
|
|||||||
Reference in New Issue
Block a user