bpo-45447: Add syntax highlighting for .pyi files in IDLE (GH-28950)

Also add .pyi to the python extensions in the "File-open" and "File-save" dialogues.
Add util.py to contain objects that are used in multiple idlelib modules
and have no dependencies on any of them.

Co-authored-by: E-Paine <63801254+E-Paine@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This commit is contained in:
Alex Waygood 2022-02-13 00:04:48 +00:00 committed by GitHub
parent b70690bb37
commit 50cf4991c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 83 additions and 3 deletions

View file

@ -27,6 +27,7 @@ from idlelib import query
from idlelib import replace
from idlelib import search
from idlelib.tree import wheel_event
from idlelib.util import py_extensions
from idlelib import window
# The default tab setting for a Text widget, in average-width characters.
@ -757,7 +758,7 @@ class EditorWindow:
if not filename or os.path.isdir(filename):
return True
base, ext = os.path.splitext(os.path.basename(filename))
if os.path.normcase(ext) in (".py", ".pyw"):
if os.path.normcase(ext) in py_extensions:
return True
line = self.text.get('1.0', '1.0 lineend')
return line.startswith('#!') and 'python' in line