diff options
Diffstat (limited to 'Lib/idlelib/editor.py')
-rw-r--r-- | Lib/idlelib/editor.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index 9b5364f0c7..b972e3db84 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -62,6 +62,8 @@ class EditorWindow(object): filesystemencoding = sys.getfilesystemencoding() # for file names help_url = None + allow_codecontext = True + def __init__(self, flist=None, filename=None, key=None, root=None): # Delay import: runscript imports pyshell imports EditorWindow. from idlelib.runscript import ScriptBinding @@ -247,6 +249,7 @@ class EditorWindow(object): self.good_load = False self.set_indentation_params(False) self.color = None # initialized below in self.ResetColorizer + self.codecontext = None if filename: if os.path.exists(filename) and not os.path.isdir(filename): if io.loadfile(filename): @@ -312,8 +315,10 @@ class EditorWindow(object): text.bind("<<refresh-calltip>>", ctip.refresh_calltip_event) text.bind("<<force-open-calltip>>", ctip.force_open_calltip_event) text.bind("<<zoom-height>>", self.ZoomHeight(self).zoom_height_event) - text.bind("<<toggle-code-context>>", - self.CodeContext(self).toggle_code_context_event) + if self.allow_codecontext: + self.codecontext = self.CodeContext(self) + text.bind("<<toggle-code-context>>", + self.codecontext.toggle_code_context_event) def _filename_to_unicode(self, filename): """Return filename as BMP unicode so displayable in Tk.""" @@ -773,6 +778,9 @@ class EditorWindow(object): self._addcolorizer() EditorWindow.color_config(self.text) + if self.codecontext is not None: + self.codecontext.update_highlight_colors() + IDENTCHARS = string.ascii_letters + string.digits + "_" def colorize_syntax_error(self, text, pos): @@ -790,7 +798,12 @@ class EditorWindow(object): "Update the text widgets' font if it is changed" # Called from configdialog.py - self.text['font'] = idleConf.GetFont(self.root, 'main','EditorWindow') + new_font = idleConf.GetFont(self.root, 'main', 'EditorWindow') + # Update the code context widget first, since its height affects + # the height of the text widget. This avoids double re-rendering. + if self.codecontext is not None: + self.codecontext.update_font(new_font) + self.text['font'] = new_font def RemoveKeybindings(self): "Remove the keybindings before they are changed." |