Skip to content

gh-131507: Add support for syntax highlighting in PyREPL #131562

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ambv
Copy link
Contributor

@ambv ambv commented Mar 21, 2025

@@ -2,12 +2,56 @@
import unicodedata
import functools

from idlelib import colorizer
Copy link
Contributor

@Wulian233 Wulian233 Mar 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from idlelib import colorizer

On Windows, if you do not choose to install Tcl/Tk, IDLE will not be available

See https://github.com/python/cpython/blob/main/Tools%2Fmsi%2Ftcltk%2Ftcltk.wixproj

@@ -2,12 +2,56 @@
import unicodedata
import functools

from idlelib import colorizer
from typing import cast, Iterator, Literal, Match, NamedTuple, Pattern, Self
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are some deprecated aliases. Although there are no issues at present, it would be better to switch to collection.abc

https://docs.python.org/3.14/library/typing.html#typing.Iterator

Comment on lines +20 to +27
type ColorTag = (
Literal["KEYWORD"]
| Literal["BUILTIN"]
| Literal["COMMENT"]
| Literal["STRING"]
| Literal["DEFINITION"]
| Literal["SYNC"]
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type ColorTag = (
Literal["KEYWORD"]
| Literal["BUILTIN"]
| Literal["COMMENT"]
| Literal["STRING"]
| Literal["DEFINITION"]
| Literal["SYNC"]
)
type ColorTag = Literal["KEYWORD", "BUILTIN", "COMMENT", "STRING", "DEFINITION", "SYNC"]

@ambv ambv force-pushed the pyrepl-syntax-highlighting branch from f4bd10f to 75cd06d Compare March 22, 2025 12:36
@tomasr8
Copy link
Member

tomasr8 commented Apr 19, 2025

Here's what it looks like with the default Ubuntu dark/light themes:

The contrast of the blue color seems a bit too low for the dark theme (I had the same issue in #132126). Maybe the 'intense' variant might look better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants