diff options
author | Ćukasz Langa <lukasz@langa.pl> | 2025-05-02 18:22:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-02 18:22:31 (GMT) |
commit | fac41f56d4b6b858cb52b40529855cce85cdbdcc (patch) | |
tree | 70490d6d77240385c4ca99281c7e5333261e89dd /Lib/_pyrepl/unix_console.py | |
parent | bfcbb28223b733b9cb88f152a059a9e1416f3467 (diff) | |
download | cpython-fac41f56d4b6b858cb52b40529855cce85cdbdcc.zip cpython-fac41f56d4b6b858cb52b40529855cce85cdbdcc.tar.gz cpython-fac41f56d4b6b858cb52b40529855cce85cdbdcc.tar.bz2 |
gh-131507: Add support for syntax highlighting in PyREPL (GH-133247)
Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Diffstat (limited to 'Lib/_pyrepl/unix_console.py')
-rw-r--r-- | Lib/_pyrepl/unix_console.py | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/Lib/_pyrepl/unix_console.py b/Lib/_pyrepl/unix_console.py index 96379bc..07b160d 100644 --- a/Lib/_pyrepl/unix_console.py +++ b/Lib/_pyrepl/unix_console.py @@ -150,8 +150,6 @@ class UnixConsole(Console): self.pollob = poll() self.pollob.register(self.input_fd, select.POLLIN) - self.input_buffer = b"" - self.input_buffer_pos = 0 curses.setupterm(term or None, self.output_fd) self.term = term @@ -199,22 +197,8 @@ class UnixConsole(Console): self.event_queue = EventQueue(self.input_fd, self.encoding) self.cursor_visible = 1 - def more_in_buffer(self) -> bool: - return bool( - self.input_buffer - and self.input_buffer_pos < len(self.input_buffer) - ) - def __read(self, n: int) -> bytes: - if not self.more_in_buffer(): - self.input_buffer = os.read(self.input_fd, 10000) - - ret = self.input_buffer[self.input_buffer_pos : self.input_buffer_pos + n] - self.input_buffer_pos += len(ret) - if self.input_buffer_pos >= len(self.input_buffer): - self.input_buffer = b"" - self.input_buffer_pos = 0 - return ret + return os.read(self.input_fd, n) def change_encoding(self, encoding: str) -> None: @@ -422,7 +406,6 @@ class UnixConsole(Console): """ return ( not self.event_queue.empty() - or self.more_in_buffer() or bool(self.pollob.poll(timeout)) ) @@ -525,6 +508,7 @@ class UnixConsole(Console): e.raw += e.raw amount = struct.unpack("i", ioctl(self.input_fd, FIONREAD, b"\0\0\0\0"))[0] + trace("getpending({a})", a=amount) raw = self.__read(amount) data = str(raw, self.encoding, "replace") e.data += data |