mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Start work on drag source implementation
This commit is contained in:
11
kittens/dnd/drag.go
Normal file
11
kittens/dnd/drag.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package dnd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
|
||||
type drag_status struct {
|
||||
active bool
|
||||
}
|
||||
@@ -607,7 +607,7 @@ func (dnd *dnd) on_drop_move(cell_x, cell_y int, has_more bool, offered_mimes st
|
||||
}
|
||||
}
|
||||
dnd.drop_status.in_window = cell_x > -1 && cell_y > -1
|
||||
if !dnd.drop_status.in_window || dnd.drag_started { // disallow self drag and drop
|
||||
if !dnd.drop_status.in_window || dnd.drag_status.active { // disallow self drag and drop
|
||||
dnd.reset_drop()
|
||||
}
|
||||
mimes_changed := !slices.Equal(prev_status.accepted_mimes, dnd.drop_status.accepted_mimes)
|
||||
@@ -622,7 +622,7 @@ func (dnd *dnd) on_drop_move(cell_x, cell_y int, has_more bool, offered_mimes st
|
||||
needs_rerender = needs_rerender || dnd.drop_status.in_window != prev_status.in_window
|
||||
if is_drop {
|
||||
needs_rerender = true
|
||||
if dnd.drop_status.action == 0 || len(dnd.drop_status.accepted_mimes) == 0 || dnd.drag_started {
|
||||
if dnd.drop_status.action == 0 || len(dnd.drop_status.accepted_mimes) == 0 || dnd.drag_status.active {
|
||||
dnd.end_drop(false)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ type dnd struct {
|
||||
tdir_counter int
|
||||
is_case_sensitive_filesystem bool
|
||||
data_has_been_dropped bool
|
||||
drag_started bool
|
||||
drag_status drag_status
|
||||
in_test_mode bool
|
||||
copy_button_region, move_button_region button_region
|
||||
confirm_drop struct {
|
||||
@@ -183,19 +183,6 @@ func (dnd *dnd) run_loop() (err error) {
|
||||
}
|
||||
|
||||
dnd.lp.OnDnDData = func(cmd loop.DndCommand) error {
|
||||
// TODO: Use lp.QueueDnDData to implement drag and drop protocol
|
||||
// If allow_drags, start a drag when the terminal sends the t=o
|
||||
// event. Presend data for any drag_source objects that have non nil
|
||||
// data fields and whose data size is <= 1MB. Set drag_started to true.
|
||||
// reset drag_started at the end of the drag. Use opts.DragAction to
|
||||
// set what actions are allowed.
|
||||
|
||||
// When acting as a drag source, dont forget to implement support for
|
||||
// remote dragging, which means providing data for the text/uri-list
|
||||
// mime type file:// entries when the terminal requests it using the
|
||||
// dnd protocol. If the action chosen is move, delete the files
|
||||
// corresponding to the drag sources, including the files in the
|
||||
// uri-list and exit.
|
||||
switch cmd.Type {
|
||||
case 'T':
|
||||
switch string(cmd.Payload) {
|
||||
|
||||
@@ -48,7 +48,7 @@ func (dnd *dnd) render_screen() error {
|
||||
}
|
||||
lp.ClearScreen()
|
||||
dnd.copy_button_region, dnd.move_button_region = button_region{}, button_region{}
|
||||
if dnd.drag_started {
|
||||
if dnd.drag_status.active {
|
||||
lp.Println("Dragging data...")
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user