home · contact · privacy
Minor OSC52 / clipboard paste refactoring. master
authorChristian Heller <c.heller@plomlompom.de>
Mon, 9 Jun 2025 14:02:19 +0000 (16:02 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 9 Jun 2025 14:02:19 +0000 (16:02 +0200)
ircplom.py

index 547207242d43d21132cf094e65e4474c62d9d295..67d8ae22870b63e12205256e95871311583f903c 100755 (executable)
@@ -38,6 +38,7 @@ CMD_SHORTCUTS = {
 }
 B64_PREFIX = 'b64:'
 OSC52_PREFIX = ']52;c;'
 }
 B64_PREFIX = 'b64:'
 OSC52_PREFIX = ']52;c;'
+PASTE_DELIMITER = '\007'
 
 IRCSPEC_LINE_SEPARATOR = b'\r\n'
 IRCSPEC_TAG_ESCAPES = ((r'\:', ';'),
 
 IRCSPEC_LINE_SEPARATOR = b'\r\n'
 IRCSPEC_TAG_ESCAPES = ((r'\:', ';'),
@@ -192,7 +193,7 @@ class Terminal:
                     if not (encoded := fused[len(OSC52_PREFIX):]):
                         while True:
                             gotch = self._blessed.getch()
                     if not (encoded := fused[len(OSC52_PREFIX):]):
                         while True:
                             gotch = self._blessed.getch()
-                            if ord(gotch) == 7:
+                            if gotch == PASTE_DELIMITER:
                                 break
                             encoded += gotch
                     yield f'{B64_PREFIX}{encoded}'
                                 break
                             encoded += gotch
                     yield f'{B64_PREFIX}{encoded}'
@@ -693,7 +694,7 @@ class Window(Widget):
 
     def cmd__paste(self) -> None:
         'Write OSC 52 ? sequence to get encoded clipboard paste into stdin.'
 
     def cmd__paste(self) -> None:
         'Write OSC 52 ? sequence to get encoded clipboard paste into stdin.'
-        self._term.write(f'\033{OSC52_PREFIX}?\007',
+        self._term.write(f'\033{OSC52_PREFIX}?{PASTE_DELIMITER}',
                          self._y_status)
         self.draw()
 
                          self._y_status)
         self.draw()