bpo-37692: Improve highlight config sample (#14983)
Use an example shell interaction in the sample and better labels for shell elements.
This commit is contained in:
parent
17a058ed6f
commit
b222955355
|
@ -808,7 +808,7 @@ class HighPage(Frame):
|
||||||
(*)theme_message: Label
|
(*)theme_message: Label
|
||||||
"""
|
"""
|
||||||
self.theme_elements = {
|
self.theme_elements = {
|
||||||
'Normal Text': ('normal', '00'),
|
'Normal Code or Text': ('normal', '00'),
|
||||||
'Code Context': ('context', '01'),
|
'Code Context': ('context', '01'),
|
||||||
'Python Keywords': ('keyword', '02'),
|
'Python Keywords': ('keyword', '02'),
|
||||||
'Python Definitions': ('definition', '03'),
|
'Python Definitions': ('definition', '03'),
|
||||||
|
@ -819,10 +819,10 @@ class HighPage(Frame):
|
||||||
'Found Text': ('hit', '08'),
|
'Found Text': ('hit', '08'),
|
||||||
'Cursor': ('cursor', '09'),
|
'Cursor': ('cursor', '09'),
|
||||||
'Editor Breakpoint': ('break', '10'),
|
'Editor Breakpoint': ('break', '10'),
|
||||||
'Shell Normal Text': ('console', '11'),
|
'Shell Prompt': ('console', '11'),
|
||||||
'Shell Error Text': ('error', '12'),
|
'Error Text': ('error', '12'),
|
||||||
'Shell Stdout Text': ('stdout', '13'),
|
'Shell User Output': ('stdout', '13'),
|
||||||
'Shell Stderr Text': ('stderr', '14'),
|
'Shell User Exception': ('stderr', '14'),
|
||||||
'Line Number': ('linenumber', '16'),
|
'Line Number': ('linenumber', '16'),
|
||||||
}
|
}
|
||||||
self.builtin_name = tracers.add(
|
self.builtin_name = tracers.add(
|
||||||
|
@ -852,27 +852,26 @@ class HighPage(Frame):
|
||||||
takefocus=FALSE, highlightthickness=0, wrap=NONE)
|
takefocus=FALSE, highlightthickness=0, wrap=NONE)
|
||||||
text.bind('<Double-Button-1>', lambda e: 'break')
|
text.bind('<Double-Button-1>', lambda e: 'break')
|
||||||
text.bind('<B1-Motion>', lambda e: 'break')
|
text.bind('<B1-Motion>', lambda e: 'break')
|
||||||
text_and_tags=(
|
string_tags=(
|
||||||
('\n', 'normal'),
|
('# Click selects item.', 'comment'), ('\n', 'normal'),
|
||||||
('#you can click here', 'comment'), ('\n', 'normal'),
|
('code context section', 'context'), ('\n', 'normal'),
|
||||||
('#to choose items', 'comment'), ('\n', 'normal'),
|
('| cursor', 'cursor'), ('\n', 'normal'),
|
||||||
('code context section', 'context'), ('\n\n', 'normal'),
|
|
||||||
('def', 'keyword'), (' ', 'normal'),
|
('def', 'keyword'), (' ', 'normal'),
|
||||||
('func', 'definition'), ('(param):\n ', 'normal'),
|
('func', 'definition'), ('(param):\n ', 'normal'),
|
||||||
('"""string"""', 'string'), ('\n var0 = ', 'normal'),
|
('"Return None."', 'string'), ('\n var0 = ', 'normal'),
|
||||||
("'string'", 'string'), ('\n var1 = ', 'normal'),
|
("'string'", 'string'), ('\n var1 = ', 'normal'),
|
||||||
("'selected'", 'hilite'), ('\n var2 = ', 'normal'),
|
("'selected'", 'hilite'), ('\n var2 = ', 'normal'),
|
||||||
("'found'", 'hit'), ('\n var3 = ', 'normal'),
|
("'found'", 'hit'), ('\n var3 = ', 'normal'),
|
||||||
('list', 'builtin'), ('(', 'normal'),
|
('list', 'builtin'), ('(', 'normal'),
|
||||||
('None', 'keyword'), (')\n', 'normal'),
|
('None', 'keyword'), (')\n', 'normal'),
|
||||||
(' breakpoint("line")', 'break'), ('\n\n', 'normal'),
|
(' breakpoint("line")', 'break'), ('\n\n', 'normal'),
|
||||||
(' error ', 'error'), (' ', 'normal'),
|
('>>>', 'console'), (' 3.14**2\n', 'normal'),
|
||||||
('cursor |', 'cursor'), ('\n ', 'normal'),
|
('9.8596', 'stdout'), ('\n', 'normal'),
|
||||||
('shell', 'console'), (' ', 'normal'),
|
('>>>', 'console'), (' pri ', 'normal'),
|
||||||
('stdout', 'stdout'), (' ', 'normal'),
|
('n', 'error'), ('t(\n', 'normal'),
|
||||||
('stderr', 'stderr'), ('\n\n', 'normal'))
|
('SyntaxError', 'stderr'), ('\n', 'normal'))
|
||||||
for texttag in text_and_tags:
|
for string, tag in string_tags:
|
||||||
text.insert(END, texttag[0], texttag[1])
|
text.insert(END, string, tag)
|
||||||
n_lines = len(text.get('1.0', END).splitlines())
|
n_lines = len(text.get('1.0', END).splitlines())
|
||||||
for lineno in range(1, n_lines):
|
for lineno in range(1, n_lines):
|
||||||
text.insert(f'{lineno}.0',
|
text.insert(f'{lineno}.0',
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Improve highlight config sample with example shell interaction and better
|
||||||
|
labels for shell elements.
|
Loading…
Reference in New Issue