More work on dnd kitten

This commit is contained in:
Kovid Goyal
2026-05-01 13:01:03 +05:30
parent cff2e6efcf
commit a89b7099ad
2 changed files with 17 additions and 2 deletions

View File

@@ -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()
}

View File

@@ -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