Index: CodeContext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/CodeContext.py,v retrieving revision 1.3 diff -c -r1.3 CodeContext.py *** CodeContext.py 26 Apr 2004 22:26:04 -0000 1.3 --- CodeContext.py 27 Apr 2004 20:56:53 -0000 *************** *** 1,6 **** """CodeContext - Display the block context of code at top of edit window ! Once code has scolled off the top of the screen, it can be difficult to determine which block you are in. This extension implements a pane at the top of each IDLE edit window which provides block structure hints. These hints are the lines which contain the block opening --- 1,6 ---- """CodeContext - Display the block context of code at top of edit window ! Once code has scrolled off the top of the screen, it can be difficult to determine which block you are in. This extension implements a pane at the top of each IDLE edit window which provides block structure hints. These hints are the lines which contain the block opening *************** *** 12,23 **** """ import Tkinter from configHandler import idleConf ! from PyShell import PyShell import re ! BLOCKOPENERS = dict([(x, None) for x in ("class", "def", "elif", "else", ! "except", "finally", "for", "if", ! "try", "while")]) INFINITY = 1 << 30 UPDATEINTERVAL = 100 # millisec FONTUPDATEINTERVAL = 1000 # millisec --- 12,22 ---- """ import Tkinter from configHandler import idleConf ! from sets import Set import re ! BLOCKOPENERS = Set(["class", "def", "elif", "else", "except", "finally", "for", ! "if", "try", "while"]) INFINITY = 1 << 30 UPDATEINTERVAL = 100 # millisec FONTUPDATEINTERVAL = 1000 # millisec *************** *** 33,43 **** "bgcolor", type="str", default="LightGray") fgcolor = idleConf.GetOption("extensions", "CodeContext", "fgcolor", type="str", default="Black") - default_on = idleConf.GetOption("extensions", "CodeContext", - "default_on", type="int", default=0) def __init__(self, editwin): - if isinstance(editwin, PyShell): - return self.editwin = editwin self.text = editwin.text self.textfont = self.text["font"] --- 32,38 ---- *************** *** 45,51 **** # Dummy line, which starts the "block" of the whole document: self.info = list(self.interesting_lines(1)) self.lastfirstline = 1 ! if self.default_on: self.toggle_code_context_event() self.editwin.setvar('<>', True) # Start two update cycles, one for context lines, one for font changes. --- 40,48 ---- # Dummy line, which starts the "block" of the whole document: self.info = list(self.interesting_lines(1)) self.lastfirstline = 1 ! visible = idleConf.GetOption("extensions", "CodeContext", ! "visible", type="bool", default=False) ! if visible: self.toggle_code_context_event() self.editwin.setvar('<>', True) # Start two update cycles, one for context lines, one for font changes. *************** *** 67,72 **** --- 64,72 ---- else: self.label.destroy() self.label = None + idleConf.SetOption("extensions", "CodeContext", "visible", + str(self.label is not None)) + idleConf.SaveUserCfgFiles() def get_line_info(self, linenum): """Get the line indent value, text, and any block start keyword Index: EditorWindow.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/EditorWindow.py,v retrieving revision 1.58 diff -c -r1.58 EditorWindow.py *** EditorWindow.py 24 Apr 2004 03:01:48 -0000 1.58 --- EditorWindow.py 27 Apr 2004 20:56:57 -0000 *************** *** 751,764 **** traceback.print_exc() def get_standard_extension_names(self): ! return idleConf.GetExtensions() def load_extension(self, name): mod = __import__(name, globals(), locals(), []) cls = getattr(mod, name) ins = cls(self) self.extensions[name] = ins - keydefs=idleConf.GetExtensionBindings(name) if keydefs: self.apply_bindings(keydefs) for vevent in keydefs.keys(): --- 751,766 ---- traceback.print_exc() def get_standard_extension_names(self): ! return idleConf.GetExtensions(editorOnly=True) def load_extension(self, name): mod = __import__(name, globals(), locals(), []) cls = getattr(mod, name) + keydefs=idleConf.GetExtensionBindings(name) + if hasattr(cls, "menudefs"): + self.fill_menus(cls.menudefs, keydefs) ins = cls(self) self.extensions[name] = ins if keydefs: self.apply_bindings(keydefs) for vevent in keydefs.keys(): *************** *** 770,777 **** methodname = methodname + "_event" if hasattr(ins, methodname): self.text.bind(vevent, getattr(ins, methodname)) - if hasattr(ins, "menudefs"): - self.fill_menus(ins.menudefs, keydefs) return ins def apply_bindings(self, keydefs=None): --- 772,777 ---- Index: PyShell.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/PyShell.py,v retrieving revision 1.87 diff -c -r1.87 PyShell.py *** PyShell.py 8 Mar 2004 18:15:31 -0000 1.87 --- PyShell.py 27 Apr 2004 20:57:01 -0000 *************** *** 806,811 **** --- 806,814 ---- # self.pollinterval = 50 # millisec + def get_standard_extension_names(self): + return idleConf.GetExtensions(shellOnly=True) + reading = False executing = False canceled = False Index: config-extensions.def =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/config-extensions.def,v retrieving revision 1.14 diff -c -r1.14 config-extensions.def *** config-extensions.def 24 Apr 2004 03:08:13 -0000 1.14 --- config-extensions.def 27 Apr 2004 20:57:01 -0000 *************** *** 3,16 **** # # Each extension must have at least one section, named after the extension # module. This section must contain an 'enable' item (=1 to enable the ! # extension, =0 to disable it) and also contain any other general configuration ! # items for the extension. Each extension must define at least one section ! # named ExtensionName_bindings or ExtensionName_cfgBindings. If present, ! # ExtensionName_bindings defines virtual event bindings for the extension that ! # are not user re-configurable. If present, ExtensionName_cfgBindings ! # defines virtual event bindings for the extension that may be sensibly ! # re-configured. If there are no keybindings for a menus' virtual events, ! # include lines like <>= (See [CodeContext], below.) # Currently it is necessary to manually modify this file to change extension # key bindings and default values. To customize, create --- 3,18 ---- # # Each extension must have at least one section, named after the extension # module. This section must contain an 'enable' item (=1 to enable the ! # extension, =0 to disable it), it may contain 'enable_editor' or 'enable_shell' ! # items, to apply it only to editor/shell windows, and may also contain any ! # other general configuration items for the extension. ! # Each extension must define at least one section named ExtensionName_bindings ! # or ExtensionName_cfgBindings. If present, ExtensionName_bindings defines ! # virtual event bindings for the extension that are not user re-configurable. ! # If present, ExtensionName_cfgBindings defines virtual event bindings for the ! # extension that may be sensibly re-configured. ! # If there are no keybindings for a menus' virtual events, include lines like ! # <>= (See [CodeContext], below.) # Currently it is necessary to manually modify this file to change extension # key bindings and default values. To customize, create *************** *** 65,72 **** [CodeContext] enable=1 numlines=3 ! default_on=0 bgcolor=LightGray fgcolor=Black [CodeContext_bindings] --- 67,75 ---- [CodeContext] enable=1 + enable_shell=0 numlines=3 ! visible=0 bgcolor=LightGray fgcolor=Black [CodeContext_bindings] Index: configHandler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/configHandler.py,v retrieving revision 1.34 diff -c -r1.34 configHandler.py *** configHandler.py 8 Mar 2004 18:15:31 -0000 1.34 --- configHandler.py 27 Apr 2004 20:57:03 -0000 *************** *** 215,221 **** sys.stderr.write(warn) return userDir ! def GetOption(self, configType, section, option, default=None, type=None): """ Get an option value for given config type and given general configuration section/option or return a default. If type is specified, --- 215,222 ---- sys.stderr.write(warn) return userDir ! def GetOption(self, configType, section, option, default=None, type=None, ! warnOnDefault=True): """ Get an option value for given config type and given general configuration section/option or return a default. If type is specified, *************** *** 224,244 **** fallback to a useable passed-in default if the option isn't present in either the user or the default configuration. configType must be one of ('main','extensions','highlight','keys') ! If a default is returned a warning is printed to stderr. """ if self.userCfg[configType].has_option(section,option): return self.userCfg[configType].Get(section, option, type=type) elif self.defaultCfg[configType].has_option(section,option): return self.defaultCfg[configType].Get(section, option, type=type) else: #returning default, print warning ! warning=('\n Warning: configHandler.py - IdleConf.GetOption -\n' ! ' problem retrieving configration option %r\n' ! ' from section %r.\n' ! ' returning default value: %r\n' % ! (option, section, default)) ! sys.stderr.write(warning) return default def GetSectionList(self, configSet, configType): """ Get a list of sections from either the user or default config for --- 225,254 ---- fallback to a useable passed-in default if the option isn't present in either the user or the default configuration. configType must be one of ('main','extensions','highlight','keys') ! If a default is returned, and warnOnDefault is True, a warning is ! printed to stderr. """ if self.userCfg[configType].has_option(section,option): return self.userCfg[configType].Get(section, option, type=type) elif self.defaultCfg[configType].has_option(section,option): return self.defaultCfg[configType].Get(section, option, type=type) else: #returning default, print warning ! if warnOnDefault: ! warning=('\n Warning: configHandler.py - IdleConf.GetOption -\n' ! ' problem retrieving configration option %r\n' ! ' from section %r.\n' ! ' returning default value: %r\n' % ! (option, section, default)) ! sys.stderr.write(warning) return default + def SetOption(self, configType, section, option, value): + """ + Set the option in the given section to value, in a user configuration + file. + """ + self.userCfg[configType].SetOption(section, option, value) + def GetSectionList(self, configSet, configType): """ Get a list of sections from either the user or default config for *************** *** 356,362 **** """ return self.GetOption('main','Keys','name',default='') ! def GetExtensions(self, activeOnly=1): """ Gets a list of all idle extensions declared in the config files. activeOnly - boolean, if true only return active (enabled) extensions --- 366,372 ---- """ return self.GetOption('main','Keys','name',default='') ! def GetExtensions(self, activeOnly=True, editorOnly=False, shellOnly=False): """ Gets a list of all idle extensions declared in the config files. activeOnly - boolean, if true only return active (enabled) extensions *************** *** 371,380 **** if activeOnly: activeExtns=[] for extn in extns: ! if self.GetOption('extensions',extn,'enable',default=1, type='bool'): #the extension is enabled ! activeExtns.append(extn) return activeExtns else: return extns --- 381,397 ---- if activeOnly: activeExtns=[] for extn in extns: ! if self.GetOption('extensions',extn,'enable',default=True, type='bool'): #the extension is enabled ! if editorOnly or shellOnly: ! if editorOnly: option = "enable_editor" ! else: option = "enable_shell" ! if self.GetOption('extensions',extn,option,default=True, ! type='bool',warnOnDefault=False): ! activeExtns.append(extn) ! else: ! activeExtns.append(extn) return activeExtns else: return extns