[Idle-dev] CVS: idle configHandler.py,1.13,1.14

Stephen M. Gava elguavas@users.sourceforge.net
Wed, 23 Jan 2002 22:00:49 -0800


Update of /cvsroot/idlefork/idle
In directory usw-pr-cvs1:/tmp/cvs-serv17437

Modified Files:
	configHandler.py 
Log Message:
further work on saving configs


Index: configHandler.py
===================================================================
RCS file: /cvsroot/idlefork/idle/configHandler.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** configHandler.py	2002/01/21 06:38:21	1.13
--- configHandler.py	2002/01/24 06:00:47	1.14
***************
*** 24,28 ****
          ConfigParser.__init__(self,defaults=cfgDefaults)
      
!     def Get(self, section, option, type=None):
          """
          Get an option value for given section/option or return default.
--- 24,28 ----
          ConfigParser.__init__(self,defaults=cfgDefaults)
      
!     def Get(self, section, option, type=None, default=None):
          """
          Get an option value for given section/option or return default.
***************
*** 36,41 ****
              getVal=self.get
          if self.has_option(section,option):
!             #return getVal(section, option, raw, vars)
              return getVal(section, option)
  
      def GetOptionList(self,section):
--- 36,43 ----
              getVal=self.get
          if self.has_option(section,option):
!             #return getVal(section, option, raw, vars, default)
              return getVal(section, option)
+         else:
+             return default
  
      def GetOptionList(self,section):
***************
*** 189,200 ****
                  raise 'Invalid fgBg specified'
              
! 
!     def GetTheme(self, name=None):
!         """
!         Gets the requested theme or returns a final fallback theme in case 
!         one can't be obtained from either the user or default config files.
          """
!         pass
!     
      def CurrentTheme(self):
          """
--- 191,245 ----
                  raise 'Invalid fgBg specified'
              
!     def GetThemeDict(self,type,themeName):
          """
!         type - string, 'default' or 'user' theme type
!         themeName - string, theme name
!         Returns a dictionary which holds {option:value} for each element
!         in the specified theme. Values are loaded over a set of ultimate last
!         fallback defaults to guarantee that all theme elements are present in 
!         a newly created theme.
!         """
!         if type == 'user':
!             cfgParser=self.userCfg['highlight']
!         elif type == 'default':
!             cfgParser=self.defaultCfg['highlight']
!         else:
!             raise 'Invalid theme type specified'
!         #foreground and background values are provded for each theme element
!         #(apart from cursor) even though all these values are not yet used
!         #by idle, to allow for their use in the future. Default values are
!         #generally black and white.
!         theme={ 'normal-foreground':'#000000', 
!                 'normal-background':'#ffffff', 
!                 'keyword-foreground':'#000000', 
!                 'keyword-background':'#ffffff', 
!                 'comment-foreground':'#000000', 
!                 'comment-background':'#ffffff', 
!                 'string-foreground':'#000000',
!                 'string-background':'#ffffff',
!                 'definition-foreground':'#000000', 
!                 'definition-background':'#ffffff',
!                 'hilite-foreground':'#000000',
!                 'hilite-background':'gray',
!                 'break-foreground':'#ffffff',
!                 'break-background':'#000000',
!                 'hit-foreground':'#ffffff',
!                 'hit-background':'#000000',
!                 'error-foreground':'#ffffff',
!                 'error-background':'#000000', 
!                 #cursor (only foreground can be set) 
!                 'cursor-foreground':'#000000', 
!                 #shell window
!                 'stdout-foreground':'#000000',
!                 'stdout-background':'#ffffff',
!                 'stderr-foreground':'#000000',
!                 'stderr-background':'#ffffff',
!                 'console-foreground':'#000000',
!                 'console-background':'#ffffff' }
!         for element in theme.keys():
!             colour=cfgParser.Get(type,themeName,element,default=theme[element])        
!             theme[element]=colour
!         return theme
!         
      def CurrentTheme(self):
          """
***************
*** 203,207 ****
          return self.GetOption('main','Theme','name',default='')
          
- 
      def CurrentKeys(self):
          """
--- 248,251 ----
***************
*** 300,305 ****
          return extBinds 
          
-     
-     
      def GetKeyBinding(self, keySetName, eventStr):
          """
--- 344,347 ----
***************
*** 314,323 ****
  
      def GetCurrentKeySet(self):
          """
!         Returns a dictionary of: all current core keybindings, plus the 
          keybindings for all currently active extensions. If a binding defined
          in an extension is already in use, that binding is disabled.
          """
!         currentKeySet=self.GetCoreKeys(keySetName=self.CurrentKeys())
          activeExtns=self.GetExtensions(activeOnly=1)
          for extn in activeExtns:
--- 356,368 ----
  
      def GetCurrentKeySet(self):
+         return self.GetKeySet(self.CurrentKeys())
+     
+     def GetKeySet(self,keySetName):
          """
!         Returns a dictionary of: all requested core keybindings, plus the 
          keybindings for all currently active extensions. If a binding defined
          in an extension is already in use, that binding is disabled.
          """
!         keySet=self.GetCoreKeys(keySetName)
          activeExtns=self.GetExtensions(activeOnly=1)
          for extn in activeExtns:
***************
*** 325,343 ****
              if extKeys: #the extension defines keybindings
                  for event in extKeys.keys():
!                     if extKeys[event] in currentKeySet.values():
                          #the binding is already in use
                          extKeys[event]='' #disable this binding
!                     currentKeySet[event]=extKeys[event] #add binding
!         return currentKeySet
!     
      def GetCoreKeys(self, keySetName=None):
          """
          returns the requested set of core keybindings, with fallbacks if
          required.
          """
-         #keybindings loaded from the config file(s) are loaded _over_ these
-         #defaults, so if there is a problem getting any core binding there will
-         #be an 'ultimate last resort fallback' to the CUA-ish bindings
-         #defined here.
          keyBindings={
              '<<Copy>>': ['<Control-c>', '<Control-C>'],
--- 370,388 ----
              if extKeys: #the extension defines keybindings
                  for event in extKeys.keys():
!                     if extKeys[event] in keySet.values():
                          #the binding is already in use
                          extKeys[event]='' #disable this binding
!                     keySet[event]=extKeys[event] #add binding
!         return keySet
! 
      def GetCoreKeys(self, keySetName=None):
          """
          returns the requested set of core keybindings, with fallbacks if
          required.
+         Keybindings loaded from the config file(s) are loaded _over_ these
+         defaults, so if there is a problem getting any core binding there will
+         be an 'ultimate last resort fallback' to the CUA-ish bindings
+         defined here.
          """
          keyBindings={
              '<<Copy>>': ['<Control-c>', '<Control-C>'],