-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-131507: Add support for syntax highlighting in PyREPL #133247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 22 commits
e921a80
fb95911
b428513
2bdcd06
8c70c45
4d7ae36
9585bd6
b1f2557
01e1129
20eff49
8d3648a
656fea3
dac8961
7891fa7
362a21b
ffebbbe
388e494
9b60382
f835dba
9003d05
ff1f92b
bd84cd8
080f300
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
|
||
from __future__ import annotations | ||
import os | ||
import time | ||
|
||
# Categories of actions: | ||
# killing | ||
|
@@ -31,6 +32,7 @@ | |
# finishing | ||
# [completion] | ||
|
||
from .trace import trace | ||
|
||
# types | ||
if False: | ||
|
@@ -471,19 +473,24 @@ def do(self) -> None: | |
|
||
|
||
class paste_mode(Command): | ||
|
||
def do(self) -> None: | ||
self.reader.paste_mode = not self.reader.paste_mode | ||
self.reader.dirty = True | ||
|
||
|
||
class enable_bracketed_paste(Command): | ||
def do(self) -> None: | ||
self.reader.paste_mode = True | ||
self.reader.in_bracketed_paste = True | ||
|
||
class disable_bracketed_paste(Command): | ||
def do(self) -> None: | ||
self.reader.paste_mode = False | ||
self.reader.in_bracketed_paste = False | ||
self.reader.dirty = True | ||
class perform_bracketed_paste(Command): | ||
def do(self) -> None: | ||
done = "\x1b[201~" | ||
ambv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
data = "" | ||
start = time.time() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leftover from testing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The trace below shows time. I can move the import up. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then use |
||
while done not in data: | ||
self.reader.console.wait(100) | ||
ev = self.reader.console.getpending() | ||
data += ev.data | ||
trace( | ||
"bracketed pasting of {l} chars done in {s:.2f}s", | ||
l=len(data), | ||
s=time.time() - start, | ||
) | ||
self.reader.insert(data.replace(done, "")) | ||
self.reader.last_refresh_cache.invalidated = True |
Uh oh!
There was an error while loading. Please reload this page.