mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-06-09 17:41:36 +00:00
OSC 52: Fix specifying both clipboard and primary in OSC 52 requests not supported
This commit is contained in:
parent
1696524949
commit
5754fa2260
2 changed files with 22 additions and 12 deletions
|
|
@ -112,6 +112,8 @@ Detailed list of changes
|
|||
|
||||
- macOS: Fix a regression causing a crash when using :opt:`focus_follows_mouse` (:iss:`8437`)
|
||||
|
||||
- OSC 52: Fix specifying both clipboard and primary in OSC 52 requests not supported
|
||||
|
||||
0.40.0 [2025-03-08]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
|||
|
|
@ -76,11 +76,15 @@ TARGETS_MIME = '.'
|
|||
class ClipboardType(IntEnum):
|
||||
clipboard = GLFW_CLIPBOARD
|
||||
primary_selection = GLFW_PRIMARY_SELECTION
|
||||
unknown = -311
|
||||
|
||||
@staticmethod
|
||||
def from_osc52_where_field(where: str) -> 'ClipboardType':
|
||||
where = where or 's0'
|
||||
return ClipboardType.clipboard if 'c' in where or 's' in where else ClipboardType.primary_selection
|
||||
if where in ('c', 's'):
|
||||
return ClipboardType.clipboard
|
||||
if where == 'p':
|
||||
return ClipboardType.primary_selection
|
||||
return ClipboardType.unknown
|
||||
|
||||
|
||||
class Clipboard:
|
||||
|
|
@ -394,18 +398,22 @@ class ClipboardRequestManager:
|
|||
else:
|
||||
where = str(data, "utf-8", 'replace')
|
||||
data = data[len(data):]
|
||||
destinations = {ClipboardType.from_osc52_where_field(where) for where in where}
|
||||
destinations.discard(ClipboardType.unknown)
|
||||
if len(data) == 1 and data.tobytes() == b'?':
|
||||
rr = ReadRequest(is_primary_selection=ClipboardType.from_osc52_where_field(where) is ClipboardType.primary_selection)
|
||||
self.handle_read_request(rr)
|
||||
for d in destinations:
|
||||
rr = ReadRequest(is_primary_selection=d is ClipboardType.primary_selection)
|
||||
self.handle_read_request(rr)
|
||||
else:
|
||||
wr = self.in_flight_write_request
|
||||
if wr is None:
|
||||
wr = self.in_flight_write_request = WriteRequest(ClipboardType.from_osc52_where_field(where) is ClipboardType.primary_selection)
|
||||
wr.add_base64_data(data)
|
||||
if is_partial:
|
||||
return
|
||||
self.in_flight_write_request = None
|
||||
self.handle_write_request(wr)
|
||||
for d in destinations:
|
||||
wr = self.in_flight_write_request
|
||||
if wr is None:
|
||||
wr = self.in_flight_write_request = WriteRequest(d is ClipboardType.primary_selection)
|
||||
wr.add_base64_data(data)
|
||||
if is_partial:
|
||||
return
|
||||
self.in_flight_write_request = None
|
||||
self.handle_write_request(wr)
|
||||
|
||||
def handle_write_request(self, wr: WriteRequest) -> None:
|
||||
wr.flush_base64_data()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue