summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/codecontext.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/idlelib/codecontext.py')
-rw-r--r--Lib/idlelib/codecontext.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/Lib/idlelib/codecontext.py b/Lib/idlelib/codecontext.py
index 09dc078..779b5b8 100644
--- a/Lib/idlelib/codecontext.py
+++ b/Lib/idlelib/codecontext.py
@@ -1,4 +1,4 @@
-"""codecontext - Extension to display the block context above the edit window
+"""codecontext - display the block context above the edit window
Once code has scrolled off the top of a window, it can be difficult to
determine which block you are in. This extension implements a pane at the top
@@ -25,10 +25,8 @@ FONTUPDATEINTERVAL = 1000 # millisec
getspacesfirstword =\
lambda s, c=re.compile(r"^(\s*)(\w*)"): c.match(s).groups()
+
class CodeContext:
- menudefs = [('options', [('!Code Conte_xt', '<<toggle-code-context>>')])]
- context_depth = idleConf.GetOption("extensions", "CodeContext",
- "numlines", type="int", default=3)
bgcolor = idleConf.GetOption("extensions", "CodeContext",
"bgcolor", type="str", default="LightGray")
fgcolor = idleConf.GetOption("extensions", "CodeContext",
@@ -45,15 +43,20 @@ class CodeContext:
# starts the toplevel 'block' of the module.
self.info = [(0, -1, "", False)]
self.topvisible = 1
- visible = idleConf.GetOption("extensions", "CodeContext",
- "visible", type="bool", default=False)
- if visible:
- self.toggle_code_context_event()
- self.editwin.setvar('<<toggle-code-context>>', True)
+ self.reload()
# Start two update cycles, one for context lines, one for font changes.
self.text.after(UPDATEINTERVAL, self.timer_event)
self.text.after(FONTUPDATEINTERVAL, self.font_timer_event)
+ @classmethod
+ def reload(cls):
+ cls.context_depth = idleConf.GetOption("extensions", "CodeContext",
+ "numlines", type="int", default=3)
+ cls.bgcolor = idleConf.GetOption("extensions", "CodeContext",
+ "bgcolor", type="str", default="LightGray")
+ cls.fgcolor = idleConf.GetOption("extensions", "CodeContext",
+ "fgcolor", type="str", default="Black")
+
def toggle_code_context_event(self, event=None):
if not self.label:
# Calculate the border width and horizontal padding required to
@@ -86,7 +89,7 @@ class CodeContext:
else:
self.label.destroy()
self.label = None
- idleConf.SetOption("extensions", "CodeContext", "visible",
+ idleConf.SetOption("main", "Theme", "contexton",
str(self.label is not None))
idleConf.SaveUserCfgFiles()
return "break"
@@ -177,3 +180,6 @@ class CodeContext:
self.textfont = newtextfont
self.label["font"] = self.textfont
self.text.after(FONTUPDATEINTERVAL, self.font_timer_event)
+
+
+CodeContext.reload()