Configured selection highlighting colors were ignored; updating highlighting

in the config dialog would cause non-Python files to be colored as if they
were Python source; improve use of ColorDelagator.  Patch 1334. Tal Einat.
This commit is contained in:
Kurt B. Kaiser 2008-02-15 22:25:09 +00:00
parent e312cfddd3
commit f05fa33a6c
3 changed files with 30 additions and 36 deletions

View File

@ -107,16 +107,6 @@ class EditorWindow(object):
self.width = idleConf.GetOption('main','EditorWindow','width')
self.text = text = MultiCallCreator(Text)(
text_frame, name='text', padx=5, wrap='none',
foreground=idleConf.GetHighlight(currentTheme,
'normal',fgBg='fg'),
background=idleConf.GetHighlight(currentTheme,
'normal',fgBg='bg'),
highlightcolor=idleConf.GetHighlight(currentTheme,
'hilite',fgBg='fg'),
highlightbackground=idleConf.GetHighlight(currentTheme,
'hilite',fgBg='bg'),
insertbackground=idleConf.GetHighlight(currentTheme,
'cursor',fgBg='fg'),
width=self.width,
height=idleConf.GetOption('main','EditorWindow','height') )
self.top.focused_widget = self.text
@ -224,11 +214,6 @@ class EditorWindow(object):
self.num_context_lines = 50, 500, 5000000
self.per = per = self.Percolator(text)
if self.ispythonsource(filename):
self.color = color = self.ColorDelegator()
per.insertfilter(color)
else:
self.color = None
self.undo = undo = self.UndoDelegator()
per.insertfilter(undo)
@ -247,11 +232,13 @@ class EditorWindow(object):
menu=self.recent_files_menu)
self.update_recent_files_list()
self.color = None # initialized below in self.ResetColorizer
if filename:
if os.path.exists(filename) and not os.path.isdir(filename):
io.loadfile(filename)
else:
io.set_filename(filename)
self.ResetColorizer()
self.saved_change_hook()
self.set_indentation_params(self.ispythonsource(filename))
@ -572,36 +559,42 @@ class EditorWindow(object):
self.flist.filename_changed_edit(self)
self.saved_change_hook()
self.top.update_windowlist_registry(self)
if self.ispythonsource(self.io.filename):
self.addcolorizer()
else:
self.rmcolorizer()
self.ResetColorizer()
def addcolorizer(self):
def _addcolorizer(self):
if self.color:
return
self.per.removefilter(self.undo)
self.color = self.ColorDelegator()
self.per.insertfilter(self.color)
self.per.insertfilter(self.undo)
if self.ispythonsource(self.io.filename):
self.color = self.ColorDelegator()
# can add more colorizers here...
if self.color:
self.per.removefilter(self.undo)
self.per.insertfilter(self.color)
self.per.insertfilter(self.undo)
def rmcolorizer(self):
def _rmcolorizer(self):
if not self.color:
return
self.color.removecolors()
self.per.removefilter(self.undo)
self.per.removefilter(self.color)
self.color = None
self.per.insertfilter(self.undo)
def ResetColorizer(self):
"Update the colour theme if it is changed"
# Called from configDialog.py
if self.color:
self.color = self.ColorDelegator()
self.per.insertfilter(self.color)
"Update the colour theme"
# Called from self.filename_change_hook and from configDialog.py
self._rmcolorizer()
self._addcolorizer()
theme = idleConf.GetOption('main','Theme','name')
self.text.config(idleConf.GetHighlight(theme, "normal"))
normal_colors = idleConf.GetHighlight(theme, 'normal')
cursor_color = idleConf.GetHighlight(theme, 'cursor', fgBg='fg')
select_colors = idleConf.GetHighlight(theme, 'hilite')
self.text.config(
foreground=normal_colors['foreground'],
background=normal_colors['background'],
insertbackground=cursor_color,
selectforeground=select_colors['foreground'],
selectbackground=select_colors['background'],
)
def ResetFont(self):
"Update the text widgets' font if it is changed"

View File

@ -3,6 +3,10 @@ What's New in IDLE 2.6a1?
*Release date: XX-XXX-2008*
- Configured selection highlighting colors were ignored; updating highlighting
in the config dialog would cause non-Python files to be colored as if they
were Python source; improve use of ColorDelagator. Patch 1334. Tal Einat.
- ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat.
- There was an error on exit if no sys.exitfunc was defined. Issue 1647.

View File

@ -1119,15 +1119,12 @@ class ConfigDialog(Toplevel):
def ActivateConfigChanges(self):
"Dynamically apply configuration changes"
winInstances=self.parent.instance_dict.keys()
theme = idleConf.CurrentTheme()
cursor_color = idleConf.GetHighlight(theme, 'cursor', fgBg='fg')
for instance in winInstances:
instance.ResetColorizer()
instance.ResetFont()
instance.set_notabs_indentwidth()
instance.ApplyKeybindings()
instance.reset_help_menu_entries()
instance.text.configure(insertbackground=cursor_color)
def Cancel(self):
self.destroy()