From: Christian Heller Date: Tue, 10 Jun 2025 02:32:41 +0000 (+0200) Subject: Minor code re-organization. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%22https:/validator.w3.org/foo.html?a=commitdiff_plain;h=83d450e0db7bc4cd8ac928d30e491d92374f9819;p=ircplom Minor code re-organization. --- diff --git a/ircplom.py b/ircplom.py index 0e1381d..e4493ec 100755 --- a/ircplom.py +++ b/ircplom.py @@ -16,7 +16,6 @@ from typing import ( from blessed import Terminal as BlessedTerminal -PORT = 6667 TIMEOUT_CONNECT = 5 TIMEOUT_LOOP = 0.1 CONN_RECV_BUFSIZE = 1024 @@ -38,6 +37,7 @@ CMD_SHORTCUTS = { 'disconnect': 'window.disconnect', 'reconnect': 'window.reconnect' } + B64_PREFIX = 'b64:' OSC52_PREFIX = ']52;c;' PASTE_DELIMITER = '\007' @@ -46,6 +46,7 @@ PROMPT_TEMPLATE = '> ' PROMPT_ELL_IN = '<…' PROMPT_ELL_OUT = '…>' +PORT = 6667 IRCSPEC_LINE_SEPARATOR = b'\r\n' IRCSPEC_TAG_ESCAPES = ((r'\:', ';'), (r'\s', ' '), @@ -563,14 +564,14 @@ class PromptWidget(ScrollableWidget): if self._cursor_x > len(self._input_buffer): content += ' ' half_width = self._width // 2 - to_write = f'{prompt}{content}' offset = 0 - if len(to_write) > self._width and self._cursor_x > half_width: - prompt = f'{PROMPT_TEMPLATE}{PROMPT_ELL_IN}' + if len(prompt) + len(content) > self._width\ + and self._cursor_x > half_width: + prompt += PROMPT_ELL_IN if self._cursor_x > len(content) - half_width: offset = len(content) - self._width + len(prompt) else: - offset = self._cursor_x - half_width + len(prompt) // 2 + offset = self._cursor_x - half_width + (len(prompt) // 2) cursor_x_to_write = len(prompt) - 1 + self._cursor_x - offset to_write = f'{prompt}{content[offset:]}' if len(to_write) > self._width: