This commit is contained in:
ton
2024-10-07 10:13:40 +07:00
parent aa1631742f
commit 3a7d696db6
9729 changed files with 1832837 additions and 161742 deletions

View File

@@ -111,7 +111,7 @@ class ConfigDialog(Toplevel):
load_configs: Load pages except for extensions.
activate_config_changes: Tell editors to reload.
"""
self.frame = frame = Frame(self, padding="5px")
self.frame = frame = Frame(self, padding=5)
self.frame.grid(sticky="nwes")
self.note = note = Notebook(frame)
self.extpage = ExtPage(note)
@@ -211,14 +211,8 @@ class ConfigDialog(Toplevel):
contents=help_common+help_pages.get(page, ''))
def deactivate_current_config(self):
"""Remove current key bindings.
Iterate over window instances defined in parent and remove
the keybindings.
"""
# Before a config is saved, some cleanup of current
# config must be done - remove the previous keybindings.
win_instances = self.parent.instance_dict.keys()
for instance in win_instances:
"""Remove current key bindings in current windows."""
for instance in self.parent.instance_dict:
instance.RemoveKeybindings()
def activate_config_changes(self):
@@ -227,8 +221,7 @@ class ConfigDialog(Toplevel):
Dynamically update the current parent window instances
with some of the configuration changes.
"""
win_instances = self.parent.instance_dict.keys()
for instance in win_instances:
for instance in self.parent.instance_dict:
instance.ResetColorizer()
instance.ResetFont()
instance.set_notabs_indentwidth()
@@ -583,22 +576,23 @@ class HighPage(Frame):
(*)theme_message: Label
"""
self.theme_elements = {
'Normal Code or Text': ('normal', '00'),
'Code Context': ('context', '01'),
'Python Keywords': ('keyword', '02'),
'Python Definitions': ('definition', '03'),
'Python Builtins': ('builtin', '04'),
'Python Comments': ('comment', '05'),
'Python Strings': ('string', '06'),
'Selected Text': ('hilite', '07'),
'Found Text': ('hit', '08'),
'Cursor': ('cursor', '09'),
'Editor Breakpoint': ('break', '10'),
'Shell Prompt': ('console', '11'),
'Error Text': ('error', '12'),
'Shell User Output': ('stdout', '13'),
'Shell User Exception': ('stderr', '14'),
'Line Number': ('linenumber', '16'),
# Display-name: internal-config-tag-name.
'Normal Code or Text': 'normal',
'Code Context': 'context',
'Python Keywords': 'keyword',
'Python Definitions': 'definition',
'Python Builtins': 'builtin',
'Python Comments': 'comment',
'Python Strings': 'string',
'Selected Text': 'hilite',
'Found Text': 'hit',
'Cursor': 'cursor',
'Editor Breakpoint': 'break',
'Shell Prompt': 'console',
'Error Text': 'error',
'Shell User Output': 'stdout',
'Shell User Exception': 'stderr',
'Line Number': 'linenumber',
}
self.builtin_name = tracers.add(
StringVar(self), self.var_changed_builtin_name)
@@ -658,7 +652,7 @@ class HighPage(Frame):
# event.widget.winfo_top_level().highlight_target.set(elem)
self.highlight_target.set(elem)
text.tag_bind(
self.theme_elements[element][0], '<ButtonPress-1>', tem)
self.theme_elements[element], '<ButtonPress-1>', tem)
text['state'] = 'disabled'
self.style.configure('frame_color_set.TFrame', borderwidth=1,
relief='solid')
@@ -765,8 +759,7 @@ class HighPage(Frame):
self.builtinlist.SetMenu(item_list, item_list[0])
self.set_theme_type()
# Load theme element option menu.
theme_names = list(self.theme_elements.keys())
theme_names.sort(key=lambda x: self.theme_elements[x][1])
theme_names = list(self.theme_elements)
self.targetlist.SetMenu(theme_names, theme_names[0])
self.paint_theme_sample()
self.set_highlight_target()
@@ -893,7 +886,7 @@ class HighPage(Frame):
new_color = self.color.get()
self.style.configure('frame_color_set.TFrame', background=new_color)
plane = 'foreground' if self.fg_bg_toggle.get() else 'background'
sample_element = self.theme_elements[self.highlight_target.get()][0]
sample_element = self.theme_elements[self.highlight_target.get()]
self.highlight_sample.tag_config(sample_element, **{plane: new_color})
theme = self.custom_name.get()
theme_element = sample_element + '-' + plane
@@ -1007,7 +1000,7 @@ class HighPage(Frame):
frame_color_set
"""
# Set the color sample area.
tag = self.theme_elements[self.highlight_target.get()][0]
tag = self.theme_elements[self.highlight_target.get()]
plane = 'foreground' if self.fg_bg_toggle.get() else 'background'
color = self.highlight_sample.tag_cget(tag, plane)
self.style.configure('frame_color_set.TFrame', background=color)
@@ -1037,7 +1030,7 @@ class HighPage(Frame):
else: # User theme
theme = self.custom_name.get()
for element_title in self.theme_elements:
element = self.theme_elements[element_title][0]
element = self.theme_elements[element_title]
colors = idleConf.GetHighlight(theme, element)
if element == 'cursor': # Cursor sample needs special painting.
colors['background'] = idleConf.GetHighlight(
@@ -1477,12 +1470,13 @@ class KeysPage(Frame):
reselect = True
list_index = self.bindingslist.index(ANCHOR)
keyset = idleConf.GetKeySet(keyset_name)
bind_names = list(keyset.keys())
# 'set' is dict mapping virtual event to list of key events.
bind_names = list(keyset)
bind_names.sort()
self.bindingslist.delete(0, END)
for bind_name in bind_names:
key = ' '.join(keyset[bind_name])
bind_name = bind_name[2:-2] # Trim off the angle brackets.
bind_name = bind_name[2:-2] # Trim double angle brackets.
if keyset_name in changes['keys']:
# Handle any unsaved changes to this key set.
if bind_name in changes['keys'][keyset_name]: