[Python-checkins] python/dist/src/Lib/idlelib CodeContext.py, 1.3, 1.4 EditorWindow.py, 1.58, 1.59 NEWS.txt, 1.34, 1.35 PyShell.py, 1.87, 1.88 config-extensions.def, 1.14, 1.15 configHandler.py, 1.34, 1.35

kbk at users.sourceforge.net kbk at users.sourceforge.net
Sat Jun 5 21:29:24 EDT 2004


Update of /cvsroot/python/python/dist/src/Lib/idlelib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16454

Modified Files:
	CodeContext.py EditorWindow.py NEWS.txt PyShell.py 
	config-extensions.def configHandler.py 
Log Message:
Noam Raphel:  Further developemt of CodeContext feature.
The visibility state of the code context pane is now persistent between
sessions and the pane does not appear in the shell window.

M CodeContext.py
M EditorWindow.py
M NEWS.txt
M PyShell.py
M config-extensions.def
M configHandler.py


Index: CodeContext.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/CodeContext.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** CodeContext.py	26 Apr 2004 22:26:04 -0000	1.3
--- CodeContext.py	6 Jun 2004 01:29:21 -0000	1.4
***************
*** 1,5 ****
  """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
--- 1,5 ----
  """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
***************
*** 13,22 ****
  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
--- 13,21 ----
  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
***************
*** 34,42 ****
      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
--- 33,37 ----
***************
*** 46,50 ****
          self.info = list(self.interesting_lines(1))
          self.lastfirstline = 1
!         if self.default_on:
              self.toggle_code_context_event()
              self.editwin.setvar('<<toggle-code-context>>', True)
--- 41,47 ----
          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('<<toggle-code-context>>', True)
***************
*** 68,71 ****
--- 65,71 ----
              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):

Index: EditorWindow.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/EditorWindow.py,v
retrieving revision 1.58
retrieving revision 1.59
diff -C2 -d -r1.58 -r1.59
*** EditorWindow.py	24 Apr 2004 03:01:48 -0000	1.58
--- EditorWindow.py	6 Jun 2004 01:29:21 -0000	1.59
***************
*** 752,763 ****
  
      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)
--- 752,765 ----
  
      def get_standard_extension_names(self):
!         return idleConf.GetExtensions(editor_only=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)
***************
*** 771,776 ****
                  if hasattr(ins, methodname):
                      self.text.bind(vevent, getattr(ins, methodname))
-         if hasattr(ins, "menudefs"):
-             self.fill_menus(ins.menudefs, keydefs)
          return ins
  
--- 773,776 ----

Index: NEWS.txt
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/NEWS.txt,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** NEWS.txt	21 Apr 2004 20:06:22 -0000	1.34
--- NEWS.txt	6 Jun 2004 01:29:21 -0000	1.35
***************
*** 1,7 ****
  What's New in IDLE 1.1a0?
! ===================================
  
  *Release date: XX-XXX-2004*
  
  - New Extension: CodeContext.  Provides block structuring hints for code
    which has scrolled above an edit window. Patch 936169 Noam Raphael.
--- 1,15 ----
  What's New in IDLE 1.1a0?
! =========================
  
  *Release date: XX-XXX-2004*
  
+ - CodeContext hint pane visibility state is now persistent across sessions.
+   The pane no longer appears in the shell window.  Added capability to limit
+   extensions to shell window or editor windows.  Noam Raphael addition
+   to Patch 936169.
+ 
+ - Paragraph reformat width is now a configurable parameter in the
+   Options GUI.
+ 
  - New Extension: CodeContext.  Provides block structuring hints for code
    which has scrolled above an edit window. Patch 936169 Noam Raphael.
***************
*** 53,57 ****
  
  What's New in IDLE 1.0?
! ===================================
  
  *Release date: 29-Jul-2003*
--- 61,65 ----
  
  What's New in IDLE 1.0?
! =======================
  
  *Release date: 29-Jul-2003*
***************
*** 62,66 ****
  
  What's New in IDLE 1.0 release candidate 2?
! ===================================
  
  *Release date: 24-Jul-2003*
--- 70,74 ----
  
  What's New in IDLE 1.0 release candidate 2?
! ===========================================
  
  *Release date: 24-Jul-2003*
***************
*** 70,74 ****
  
  What's New in IDLE 1.0 release candidate 1?
! ===================================
  
  *Release date: 18-Jul-2003*
--- 78,82 ----
  
  What's New in IDLE 1.0 release candidate 1?
! ===========================================
  
  *Release date: 18-Jul-2003*
***************
*** 91,95 ****
  
  What's New in IDLE 1.0b2?
! ===================================
  
  *Release date: 29-Jun-2003*
--- 99,103 ----
  
  What's New in IDLE 1.0b2?
! =========================
  
  *Release date: 29-Jun-2003*
***************
*** 132,136 ****
  
  What's New in IDLEfork 0.9b1?
! ===================================
  
  *Release date: 02-Jun-2003*
--- 140,144 ----
  
  What's New in IDLEfork 0.9b1?
! =============================
  
  *Release date: 02-Jun-2003*

Index: PyShell.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/PyShell.py,v
retrieving revision 1.87
retrieving revision 1.88
diff -C2 -d -r1.87 -r1.88
*** PyShell.py	8 Mar 2004 18:15:31 -0000	1.87
--- PyShell.py	6 Jun 2004 01:29:21 -0000	1.88
***************
*** 807,810 ****
--- 807,813 ----
          self.pollinterval = 50  # millisec
  
+     def get_standard_extension_names(self):
+         return idleConf.GetExtensions(shell_only=True)
+ 
      reading = False
      executing = False

Index: config-extensions.def
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/config-extensions.def,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** config-extensions.def	24 Apr 2004 03:08:13 -0000	1.14
--- config-extensions.def	6 Jun 2004 01:29:22 -0000	1.15
***************
*** 1,2 ****
--- 1,4 ----
+ # config-extensions.def
+ #
  # IDLE reads several config files to determine user preferences.  This
  # file is the default configuration file for IDLE extensions settings.
***************
*** 4,24 ****
  # 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 <<toggle-code-context>>=   (See [CodeContext], below.)
! 
  # Currently it is necessary to manually modify this file to change extension
  # key bindings and default values. To customize, create
  # ~/.idlerc/config-extensions.cfg and append the appropriate customized
  # section(s).  Those sections will override the defaults in this file.
! 
  # Note: If a keybinding is already in use when the extension is
  # loaded, the extension's virtual event's keybinding will be set to ''.
! 
  # See config-keys.def for notes on specifying keys and extend.txt for
  # information on creating IDLE extensions.
--- 6,30 ----
  # 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
! # <<toggle-code-context>>=   (See [CodeContext], below.)
! #
  # Currently it is necessary to manually modify this file to change extension
  # key bindings and default values. To customize, create
  # ~/.idlerc/config-extensions.cfg and append the appropriate customized
  # section(s).  Those sections will override the defaults in this file.
! #
  # Note: If a keybinding is already in use when the extension is
  # loaded, the extension's virtual event's keybinding will be set to ''.
! #
  # See config-keys.def for notes on specifying keys and extend.txt for
  # information on creating IDLE extensions.
***************
*** 66,71 ****
  [CodeContext]
  enable=1
  numlines=3
! default_on=0
  bgcolor=LightGray
  fgcolor=Black
--- 72,78 ----
  [CodeContext]
  enable=1
+ enable_shell=0
  numlines=3
! visible=0
  bgcolor=LightGray
  fgcolor=Black

Index: configHandler.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/configHandler.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** configHandler.py	8 Mar 2004 18:15:31 -0000	1.34
--- configHandler.py	6 Jun 2004 01:29:22 -0000	1.35
***************
*** 216,220 ****
          return userDir
  
!     def GetOption(self, configType, section, option, default=None, type=None):
          """
          Get an option value for given config type and given general
--- 216,221 ----
          return userDir
  
!     def GetOption(self, configType, section, option, default=None, type=None,
!                   warn_on_default=True):
          """
          Get an option value for given config type and given general
***************
*** 225,229 ****
          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):
--- 226,232 ----
          either the user or the default configuration.
          configType must be one of ('main','extensions','highlight','keys')
!         If a default is returned, and warn_on_default is True, a warning is
!         printed to stderr.
! 
          """
          if self.userCfg[configType].has_option(section,option):
***************
*** 232,243 ****
              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):
          """
--- 235,253 ----
              return self.defaultCfg[configType].Get(section, option, type=type)
          else: #returning default, print warning
!             if warn_on_default:
!                 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):
+         """In user's config file, set section's option to value.
+ 
+         """
+         self.userCfg[configType].SetOption(section, option, value)
+ 
      def GetSectionList(self, configSet, configType):
          """
***************
*** 357,364 ****
          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
          """
          extns=self.RemoveKeyBindNames(
--- 367,374 ----
          return self.GetOption('main','Keys','name',default='')
  
!     def GetExtensions(self, active_only=True, editor_only=False, shell_only=False):
          """
          Gets a list of all idle extensions declared in the config files.
!         active_only - boolean, if true only return active (enabled) extensions
          """
          extns=self.RemoveKeyBindNames(
***************
*** 369,379 ****
              if extn not in extns: #user has added own extension
                  extns.append(extn)
!         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:
--- 379,399 ----
              if extn not in extns: #user has added own extension
                  extns.append(extn)
!         if active_only:
              activeExtns=[]
              for extn in extns:
!                 if self.GetOption('extensions', extn, 'enable', default=True,
!                                   type='bool'):
                      #the extension is enabled
!                     if editor_only or shell_only:
!                         if editor_only:
!                             option = "enable_editor"
!                         else:
!                             option = "enable_shell"
!                         if self.GetOption('extensions', extn,option,
!                                           default=True, type='bool',
!                                           warn_on_default=False):
!                             activeExtns.append(extn)
!                     else:
!                         activeExtns.append(extn)
              return activeExtns
          else:
***************
*** 402,406 ****
          extName=None
          vEvent='<<'+virtualEvent+'>>'
!         for extn in self.GetExtensions(activeOnly=0):
              for event in self.GetExtensionKeys(extn).keys():
                  if event == vEvent:
--- 422,426 ----
          extName=None
          vEvent='<<'+virtualEvent+'>>'
!         for extn in self.GetExtensions(active_only=0):
              for event in self.GetExtensionKeys(extn).keys():
                  if event == vEvent:
***************
*** 483,487 ****
          """
          keySet=self.GetCoreKeys(keySetName)
!         activeExtns=self.GetExtensions(activeOnly=1)
          for extn in activeExtns:
              extKeys=self.__GetRawExtensionKeys(extn)
--- 503,507 ----
          """
          keySet=self.GetCoreKeys(keySetName)
!         activeExtns=self.GetExtensions(active_only=1)
          for extn in activeExtns:
              extKeys=self.__GetRawExtensionKeys(extn)




More information about the Python-checkins mailing list