mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 18:51:41 +02:00
More work on dnd kitten
This commit is contained in:
@@ -14,6 +14,10 @@ var _ = fmt.Print
|
||||
type drag_status struct {
|
||||
active bool
|
||||
terminal_accepted_drag bool
|
||||
offered_mimes []string
|
||||
accepted_mime int
|
||||
accepted_operation int
|
||||
dropped bool
|
||||
}
|
||||
|
||||
func (dnd *dnd) on_potential_drag_start(cell_x, cell_y int) (err error) {
|
||||
@@ -37,6 +41,7 @@ func (dnd *dnd) on_potential_drag_start(cell_x, cell_y int) (err error) {
|
||||
dnd.lp.QueueDnDData(DC{Type: 'p', X: i, Operation: actions})
|
||||
}
|
||||
}
|
||||
dnd.drag_status.offered_mimes = mimes
|
||||
// TODO: set the drag image
|
||||
dnd.lp.QueueDnDData(DC{Type: 'P', X: -1}) // start drag
|
||||
dnd.drag_status.active = true
|
||||
@@ -64,9 +69,14 @@ func (dnd *dnd) reset_drag() {
|
||||
|
||||
func (dnd *dnd) on_drag_event(x, y int) (err error) {
|
||||
switch x {
|
||||
case 1:
|
||||
dnd.drag_status.accepted_mime = y
|
||||
case 2:
|
||||
dnd.drag_status.accepted_operation = y
|
||||
case 3:
|
||||
dnd.drag_status.dropped = true
|
||||
case 4:
|
||||
dnd.reset_drag()
|
||||
return dnd.render_screen()
|
||||
}
|
||||
return
|
||||
return dnd.render_screen()
|
||||
}
|
||||
|
||||
@@ -50,6 +50,11 @@ func (dnd *dnd) render_screen() error {
|
||||
dnd.copy_button_region, dnd.move_button_region = button_region{}, button_region{}
|
||||
if dnd.drag_status.active {
|
||||
lp.Println("Dragging data...")
|
||||
if dnd.drag_status.dropped {
|
||||
lp.Println("The dragged data has been dropped, waiting for data transfer requests...")
|
||||
} else if dnd.drag_status.accepted_operation > 0 {
|
||||
lp.Println("Another window is willing to accept the dragged data")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
y := 0
|
||||
|
||||
Reference in New Issue
Block a user