summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/codecontext.py
diff options
context:
space:
mode:
authorwohlganger <charles.wohlganger@gmail.com>2017-09-10 21:19:47 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2017-09-10 21:19:47 (GMT)
commit58fc71c447049d0efe4e11db1b55edc307f1bede (patch)
tree237891f31c741848809fa8dab7b6652849f37fa0 /Lib/idlelib/codecontext.py
parentd39dbf4cf18488beb190ab358b7ab38792cd5043 (diff)
downloadcpython-58fc71c447049d0efe4e11db1b55edc307f1bede.zip
cpython-58fc71c447049d0efe4e11db1b55edc307f1bede.tar.gz
cpython-58fc71c447049d0efe4e11db1b55edc307f1bede.tar.bz2
bpo-27099: IDLE - Convert built-in extensions to regular features (#2494)
About 10 IDLE features were implemented as supposedly optional extensions. Their different behavior could be confusing or worse for users and not good for maintenance. Hence the conversion. The main difference for users is that user configurable key bindings for builtin features are now handled uniformly. Now, editing a binding in a keyset only affects its value in the keyset. All bindings are defined together in the system-specific default keysets in config- extensions.def. All custom keysets are saved as a whole in config- extension.cfg. All take effect as soon as one clicks Apply or Ok. The affected events are '<<force-open-completions>>', '<<expand-word>>', '<<force-open-calltip>>', '<<flash-paren>>', '<<format-paragraph>>', '<<run-module>>', '<<check-module>>', and '<<zoom-height>>'. Any (global) customizations made before 3.6.3 will not affect their keyset- specific customization after 3.6.3. and vice versa. Inital patch by Charles Wohlganger, revised by Terry Jan Reedy.
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()