mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-20 15:35:03 +02:00
More work on the dnd kitten
This commit is contained in:
@@ -337,8 +337,10 @@ class PTY:
|
||||
def __init__(
|
||||
self, argv=None, rows=25, columns=80, scrollback=100, cell_width=10, cell_height=20,
|
||||
cwd=None, env=None, stdin_fd=None, stdout_fd=None, needs_da1=True, window_id=0,
|
||||
log_data_flow=False,
|
||||
):
|
||||
self.is_child = False
|
||||
self.log_data_flow = log_data_flow
|
||||
if isinstance(argv, str):
|
||||
argv = shlex.split(argv)
|
||||
self.write_buf = b''
|
||||
@@ -423,6 +425,8 @@ class PTY:
|
||||
def write_to_child(self, data, flush=False):
|
||||
if isinstance(data, str):
|
||||
data = data.encode('utf-8')
|
||||
if self.log_data_flow:
|
||||
print('t -> c:', data)
|
||||
self.write_buf += data
|
||||
if flush:
|
||||
self.process_input_from_child(0)
|
||||
@@ -446,6 +450,8 @@ class PTY:
|
||||
data = os.read(self.master_fd, io.DEFAULT_BUFFER_SIZE)
|
||||
bytes_read += len(data)
|
||||
self.received_bytes += data
|
||||
if self.log_data_flow:
|
||||
print('c -> t:', data)
|
||||
parse_bytes(self.screen, data)
|
||||
return bytes_read
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ from kitty.fast_data_types import (
|
||||
dnd_set_test_write_func,
|
||||
dnd_test_cleanup_fake_window,
|
||||
dnd_test_create_fake_window,
|
||||
dnd_test_drag_finish,
|
||||
dnd_test_fake_drop_data,
|
||||
dnd_test_fake_drop_event,
|
||||
dnd_test_probe_state,
|
||||
@@ -328,10 +329,29 @@ class TestDnDKitten(BaseTest):
|
||||
f.write(os.urandom(1113))
|
||||
create_fs(self.src_data_dir)
|
||||
self.finish_setup(cli_args=(f'--drag=image/png:{img_drag_path}', self.src_data_dir)) # )))
|
||||
with self.subTest(remote=False):
|
||||
self.dnd_kitten_drag(False, img_drag_path)
|
||||
self.dnd_kitten_drag(False, img_drag_path)
|
||||
self.exit_kitten()
|
||||
|
||||
def dnd_kitten_drag(self, remote_client, img_drop_path):
|
||||
# self.pty.log_data_flow = True
|
||||
copy, move = self.get_button_geometry()
|
||||
dnd_test_start_drag_offer(self.capture.window_id, 1, 1)
|
||||
self.wait_for_state('drag_operations', 3)
|
||||
self.wait_for_state('can_offer', True)
|
||||
self.wait_for_state('drag_operations', 0)
|
||||
def wait_for_drag_active(active=True):
|
||||
self.send_dnd_command_to_kitten('DRAG_ACTIVE')
|
||||
self.wait_for_responses('DRAG_ACTIVE' if active else 'DRAG_INACTIVE')
|
||||
def start_drag(x, y, expected):
|
||||
dnd_test_start_drag_offer(self.capture.window_id, x, y)
|
||||
wait_for_drag_active()
|
||||
self.wait_for_state('drag_operations', expected)
|
||||
def end_drag(canceled=True):
|
||||
dnd_test_drag_finish(self.capture.window_id, canceled)
|
||||
wait_for_drag_active(False)
|
||||
self.wait_for_state('drag_operations', 0)
|
||||
start_drag(1, 1, 3)
|
||||
self.assertEqual(set(self.probe_state('drag_mimes')), {'image/png', 'text/uri-list'})
|
||||
end_drag()
|
||||
start_drag(copy[0] + 1, copy[1] + 1, 1)
|
||||
end_drag()
|
||||
start_drag(move[0] + 1, move[1] + 1, 2)
|
||||
end_drag()
|
||||
|
||||
Reference in New Issue
Block a user