summaryrefslogtreecommitdiffstats
path: root/Lib/_pyrepl/readline.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-122273: Support PyREPL history on Windows (#127141)Victor Stinner2024-11-261-1/+3
| | | Co-authored-by: devdanzin <74280297+devdanzin@users.noreply.github.com>
* gh-119310: Fix encoding when reading old history file (#121779)aorcajo2024-09-061-4/+8
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-119034, REPL: Change page up/down keys to search in history (#123607)Victor Stinner2024-09-061-1/+1
| | | | | | Change <page up> and <page down> keys of the Python REPL to history search forward/backward. Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-111201: fix auto-indent in pyrepl for muliple pound comments (#123196)Arnon Yaari2024-09-061-1/+1
|
* gh-123240: Raise input audit events in the new REPL (#123274)sobolevn2024-09-051-2/+6
|
* gh-123228: fix return type for _ReadlineWrapper.get_line_buffer() (#123281)Sergey B Kirpichev2024-08-241-4/+3
| | | Co-authored-by: Carl Friedrich Bolz-Tereick <cfbolz@gmx.de>
* gh-123149: Suppress verbose repr in new REPL (#123151)James2024-08-191-2/+2
|
* gh-121790: Fix interactive console initialization (#121793)Milan Oberkirch2024-07-151-3/+5
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-118908: Fix completions after namespace change in REPL (#120370)Lysandros Nikolaou2024-06-121-3/+10
|
* gh-119517: Fixes for pasting in pyrepl (#120253)Matt Wozniski2024-06-111-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove pyrepl's optimization for self-insert This will be replaced by a less specialized optimization. * Use line-buffering when pyrepl echoes pastes Previously echoing was totally suppressed until the entire command had been pasted and the terminal ended paste mode, but this gives the user no feedback to indicate that an operation is in progress. Drawing something to the screen once per line strikes a balance between perceived responsiveness and performance. * Remove dead code from pyrepl `msg_at_bottom` is always true. * Speed up pyrepl's screen rendering computation The Reader in pyrepl doesn't hold a complete representation of the screen area being drawn as persistent state. Instead, it recomputes it, on each keypress. This is fast enough for a few hundred bytes, but incredibly slow as the input buffer grows into the kilobytes (likely because of pasting). Rather than making some expensive and expansive changes to the repl's internal representation of the screen, add some caching: remember some data from one refresh to the next about what was drawn to the screen and, if we don't find anything that has invalidated the results that were computed last time around, reuse them. To keep this caching as simple as possible, all we'll do is look for lines in the buffer that were above the cursor the last time we were asked to update the screen, and that are still above the cursor now. We assume that nothing can affect a line that comes before both the old and new cursor location without us being informed. Based on this assumption, we can reuse old lines, which drastically speeds up the overwhelmingly common case where the user is typing near the end of the buffer. * Speed up pyrepl prompt drawing Cache the `can_colorize()` call rather than repeatedly recomputing it. This call looks up an environment variable, and is called once per character typed at the REPL. The environment variable lookup shows up as a hot spot when profiling, and we don't expect this to change while the REPL is running. * Speed up pasting multiple lines into the REPL Previously, we were checking whether the command should be accepted each time a line break was encountered, but that's not the expected behavior. In bracketed paste mode, we expect everything pasted to be part of a single block of code, and encountering a newline shouldn't behave like a user pressing <Enter> to execute a command. The user should always have a chance to review the pasted command before running it. * Use a read buffer for input in pyrepl Previously we were reading one byte at a time, which causes much slower IO than necessary. Instead, read in chunks, processing previously read data before asking for more. * Optimize finding width of a single character `wlen` finds the width of a multi-character string by adding up the width of each character, and then subtracting the width of any escape sequences. It's often called for single character strings, however, which can't possibly contain escape sequences. Optimize for that case. * Optimize disp_str for ASCII characters Since every ASCII character is known to display as single width, we can avoid not only the Unicode data lookup in `disp_str` but also the one hidden in `str_width` for them. * Speed up cursor movements in long pyrepl commands When the current pyrepl command buffer contains many lines, scrolling up becomes slow. We have optimizations in place to reuse lines above the cursor position from one refresh to the next, but don't currently try to reuse lines below the cursor position in the same way, so we wind up with quadratic behavior where all lines of the buffer below the cursor are recomputed each time the cursor moves up another line. Optimize this by only computing one screen's worth of lines beyond the cursor position. Any lines beyond that can't possibly be shown by the console, and bounding this makes scrolling up have linear time complexity instead. --------- Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* gh-111201: Improve pyrepl auto indentation (#119606)Arnon Yaari2024-05-311-8/+19
| | | | - auto-indent when editing multi-line block - ignore comments
* gh-111201: Support pyrepl on Windows (#119559)Dino Viehland2024-05-311-2/+9
| | | | Co-authored-by: Anthony Shaw <anthony.p.shaw@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-118911: Trailing whitespace in a block shouldn't prevent the user from ↵Aya Elsayed2024-05-221-2/+15
| | | | | terminating the code block (#119355) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-111201: Speed up paste mode in the REPL (#119341)Pablo Galindo Salgado2024-05-221-5/+6
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-111201: auto-indentation in _pyrepl (#119348)Arnon Yaari2024-05-221-3/+40
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-119205: Fix autocompletion bug in new repl (#119229)Koudai Aono2024-05-211-1/+3
| | | Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-111201: Remove readline dependency from the PyREPL (#119262)Lysandros Nikolaou2024-05-211-2/+2
|
* Improve `pyrepl` type-annotation coverage (#119081)Alex Waygood2024-05-171-2/+5
|
* gh-111201: Allow pasted code to contain multiple statements in the REPL ↵Pablo Galindo Salgado2024-05-071-1/+2
| | | | | (#118712) Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* gh-111201: A new Python REPL (GH-111567)Pablo Galindo Salgado2024-05-051-0/+501
Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Marta Gómez Macías <mgmacias@google.com> Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>