Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix drag and drop issues on KDE #275

Merged
merged 1 commit into from
Nov 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions terminatorlib/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1164,16 +1164,19 @@ def on_drag_data_received(self, widget, drag_context, x, y, selection_data,
info, _time, data):
"""Something has been dragged into the terminal. Handle it as either a
URL or another terminal."""
### FIXME this code is a mess that I don't quite understand how it works.
dbg('drag data received of type: %s' % (selection_data.get_data_type()))
# print(selection_data.get_urls())
if Gtk.targets_include_text(drag_context.list_targets()) or \
Gtk.targets_include_uri(drag_context.list_targets()):
# copy text with no modification yet to destination
txt = selection_data.get_data()

# https://bugs.launchpad.net/terminator/+bug/1518705
if info == self.TARGET_TYPE_MOZ:
txt = txt.decode('utf-16')
txt = txt.split('\n')[0]
### KDE ends it's text/x-moz-url text with CRLF, :shrug:
if not txt.endswith('\r\n'):
txt = txt.split('\n')[0]
else:
txt = txt.decode()

Expand All @@ -1188,11 +1191,12 @@ def on_drag_data_received(self, widget, drag_context, x, y, selection_data,
# iterate over all elements except the last one.
str=''
for fname in txt_lines[:-1]:
dbg('drag data fname: %s' % fname)
fname = "'%s'" % urlunquote(fname[7:].replace("'",
'\'\\\'\''))
str += fname + ' '
txt=str
### Never send a CRLF to the terminal from here
txt = txt.rstrip('\r\n')
for term in self.terminator.get_target_terms(self):
term.feed(txt)
return
Expand Down