diff options
author | wohlganger <charles.wohlganger@gmail.com> | 2017-09-10 16:19:47 -0500 |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2017-09-10 17:19:47 -0400 |
commit | 58fc71c447049d0efe4e11db1b55edc307f1bede (patch) | |
tree | 237891f31c741848809fa8dab7b6652849f37fa0 /Lib/idlelib/editor.py | |
parent | d39dbf4cf18488beb190ab358b7ab38792cd5043 (diff) | |
download | cpython-git-58fc71c447049d0efe4e11db1b55edc307f1bede.tar.gz |
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/editor.py')
-rw-r--r-- | Lib/idlelib/editor.py | 64 |
1 files changed, 52 insertions, 12 deletions
diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index 43b105f726..855d375055 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -31,7 +31,6 @@ from idlelib import windows TK_TABWIDTH_DEFAULT = 8 _py_version = ' (%s)' % platform.python_version() - def _sphinx_version(): "Format sys.version_info to produce the Sphinx version string used to install the chm docs" major, minor, micro, level, serial = sys.version_info @@ -52,11 +51,22 @@ class EditorWindow(object): from idlelib import mainmenu from tkinter import Toplevel from idlelib.statusbar import MultiStatusBar + from idlelib.autocomplete import AutoComplete + from idlelib.autoexpand import AutoExpand + from idlelib.calltips import CallTips + from idlelib.codecontext import CodeContext + from idlelib.paragraph import FormatParagraph + from idlelib.parenmatch import ParenMatch + from idlelib.rstrip import RstripExtension + from idlelib.zoomheight import ZoomHeight filesystemencoding = sys.getfilesystemencoding() # for file names help_url = None def __init__(self, flist=None, filename=None, key=None, root=None): + # Delay import: runscript imports pyshell imports EditorWindow. + from idlelib.runscript import ScriptBinding + if EditorWindow.help_url is None: dochome = os.path.join(sys.base_prefix, 'Doc', 'index.html') if sys.platform.count('linux'): @@ -84,7 +94,8 @@ class EditorWindow(object): # Safari requires real file:-URLs EditorWindow.help_url = 'file://' + EditorWindow.help_url else: - EditorWindow.help_url = "https://docs.python.org/%d.%d/" % sys.version_info[:2] + EditorWindow.help_url = ("https://docs.python.org/%d.%d/" + % sys.version_info[:2]) self.flist = flist root = root or flist.root self.root = root @@ -270,6 +281,43 @@ class EditorWindow(object): self.askinteger = tkSimpleDialog.askinteger self.showerror = tkMessageBox.showerror + # Add pseudoevents for former extension fixed keys. + # (This probably needs to be done once in the process.) + text.event_add('<<autocomplete>>', '<Key-Tab>') + text.event_add('<<try-open-completions>>', '<KeyRelease-period>', + '<KeyRelease-slash>', '<KeyRelease-backslash>') + text.event_add('<<try-open-calltip>>', '<KeyRelease-parenleft>') + text.event_add('<<refresh-calltip>>', '<KeyRelease-parenright>') + text.event_add('<<paren-closed>>', '<KeyRelease-parenright>', + '<KeyRelease-bracketright>', '<KeyRelease-braceright>') + + # Former extension bindings depends on frame.text being packed + # (called from self.ResetColorizer()). + autocomplete = self.AutoComplete(self) + text.bind("<<autocomplete>>", autocomplete.autocomplete_event) + text.bind("<<try-open-completions>>", + autocomplete.try_open_completions_event) + text.bind("<<force-open-completions>>", + autocomplete.force_open_completions_event) + text.bind("<<expand-word>>", self.AutoExpand(self).expand_word_event) + text.bind("<<format-paragraph>>", + self.FormatParagraph(self).format_paragraph_event) + parenmatch = self.ParenMatch(self) + text.bind("<<flash-paren>>", parenmatch.flash_paren_event) + text.bind("<<paren-closed>>", parenmatch.paren_closed_event) + scriptbinding = ScriptBinding(self) + text.bind("<<check-module>>", scriptbinding.check_module_event) + text.bind("<<run-module>>", scriptbinding.run_module_event) + text.bind("<<do-rstrip>>", self.RstripExtension(self).do_rstrip) + calltips = self.CallTips(self) + text.bind("<<try-open-calltip>>", calltips.try_open_calltip_event) + #refresh-calltips must come after paren-closed to work right + text.bind("<<refresh-calltip>>", calltips.refresh_calltip_event) + text.bind("<<force-open-calltip>>", calltips.force_open_calltip_event) + text.bind("<<zoom-height>>", self.ZoomHeight(self).zoom_height_event) + text.bind("<<toggle-code-context>>", + self.CodeContext(self).toggle_code_context_event) + def _filename_to_unicode(self, filename): """Return filename as BMP unicode so diplayable in Tk.""" # Decode bytes to unicode. @@ -981,16 +1029,8 @@ class EditorWindow(object): def get_standard_extension_names(self): return idleConf.GetExtensions(editor_only=True) - extfiles = { # map config-extension section names to new file names - 'AutoComplete': 'autocomplete', - 'AutoExpand': 'autoexpand', - 'CallTips': 'calltips', - 'CodeContext': 'codecontext', - 'FormatParagraph': 'paragraph', - 'ParenMatch': 'parenmatch', - 'RstripExtension': 'rstrip', - 'ScriptBinding': 'runscript', - 'ZoomHeight': 'zoomheight', + extfiles = { # Map built-in config-extension section names to file names. + 'ZzDummy': 'zzdummy', } def load_extension(self, name): |