From: Christian Heller Date: Mon, 9 Jun 2025 14:02:19 +0000 (+0200) Subject: Minor OSC52 / clipboard paste refactoring. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%22https:/validator.w3.org/foo.html?a=commitdiff_plain;h=7f2d9522d7ef8d6fb49dbdac853e642dc698e8eb;p=ircplom Minor OSC52 / clipboard paste refactoring. --- diff --git a/ircplom.py b/ircplom.py index 5472072..67d8ae2 100755 --- a/ircplom.py +++ b/ircplom.py @@ -38,6 +38,7 @@ CMD_SHORTCUTS = { } B64_PREFIX = 'b64:' OSC52_PREFIX = ']52;c;' +PASTE_DELIMITER = '\007' 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 ord(gotch) == 7: + if gotch == PASTE_DELIMITER: 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.' - self._term.write(f'\033{OSC52_PREFIX}?\007', + self._term.write(f'\033{OSC52_PREFIX}?{PASTE_DELIMITER}', self._y_status) self.draw()