mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 18:28:49 +00:00 
			
		
		
		
	 d6c397bf77
			
		
	
	
		d6c397bf77
		
	
	
	
	
		
			
			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.
(cherry picked from commit 58fc71c)
		
	
			
		
			
				
	
	
		
			42 lines
		
	
	
	
		
			961 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
	
		
			961 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| "Example extension, also used for testing."
 | |
| 
 | |
| from idlelib.config import idleConf
 | |
| 
 | |
| ztext = idleConf.GetOption('extensions', 'ZzDummy', 'z-text')
 | |
| 
 | |
| 
 | |
| class ZzDummy:
 | |
| 
 | |
| ##    menudefs = [
 | |
| ##        ('format', [
 | |
| ##            ('Z in', '<<z-in>>'),
 | |
| ##            ('Z out', '<<z-out>>'),
 | |
| ##        ] )
 | |
| ##    ]
 | |
| 
 | |
|     def __init__(self, editwin):
 | |
|         self.text = editwin.text
 | |
|         z_in = False
 | |
| 
 | |
|     @classmethod
 | |
|     def reload(cls):
 | |
|         cls.ztext = idleConf.GetOption('extensions', 'ZzDummy', 'z-text')
 | |
| 
 | |
|     def z_in_event(self, event):
 | |
|         """
 | |
|         """
 | |
|         text = self.text
 | |
|         text.undo_block_start()
 | |
|         for line in range(1, text.index('end')):
 | |
|             text.insert('%d.0', ztest)
 | |
|         text.undo_block_stop()
 | |
|         return "break"
 | |
| 
 | |
|     def z_out_event(self, event): pass
 | |
| 
 | |
| ZzDummy.reload()
 | |
| 
 | |
| ##if __name__ == "__main__":
 | |
| ##    import unittest
 | |
| ##    unittest.main('idlelib.idle_test.test_zzdummy',
 | |
| ##            verbosity=2, exit=False)
 |