summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/editor.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-06-27 04:02:32 (GMT)
committerterryjreedy <tjreedy@udel.edu>2017-06-27 04:02:32 (GMT)
commit213ce12adfc9281c6f381bb45d132e9de8ffd450 (patch)
treedb01c6fdab2e3a9c986d5b49c5294d309ae11f56 /Lib/idlelib/editor.py
parent9a02ae3d3d645f0c8178f3362694f473bab6fe3e (diff)
downloadcpython-213ce12adfc9281c6f381bb45d132e9de8ffd450.zip
cpython-213ce12adfc9281c6f381bb45d132e9de8ffd450.tar.gz
cpython-213ce12adfc9281c6f381bb45d132e9de8ffd450.tar.bz2
bpo-29910: IDLE no longer deletes a character after commenting out a region (#825)
This happened because shortcut has a class binding and 'break' was not returned. Fix other potential conflicts between IDLE and default key bindings. * Add news item * Update NEWS
Diffstat (limited to 'Lib/idlelib/editor.py')
-rw-r--r--Lib/idlelib/editor.py30
1 files changed, 24 insertions, 6 deletions
diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py
index 13b4a51..5b64ef4 100644
--- a/Lib/idlelib/editor.py
+++ b/Lib/idlelib/editor.py
@@ -1,4 +1,3 @@
-import importlib
import importlib.abc
import importlib.util
import os
@@ -147,7 +146,7 @@ class EditorWindow(object):
text.bind("<<python-docs>>", self.python_docs)
text.bind("<<about-idle>>", self.about_dialog)
text.bind("<<open-config-dialog>>", self.config_dialog)
- text.bind("<<open-module>>", self.open_module)
+ text.bind("<<open-module>>", self.open_module_event)
text.bind("<<do-nothing>>", lambda event: "break")
text.bind("<<select-all>>", self.select_all)
text.bind("<<remove-selection>>", self.remove_selection)
@@ -294,7 +293,7 @@ class EditorWindow(object):
def home_callback(self, event):
if (event.state & 4) != 0 and event.keysym == "Home":
# state&4==Control. If <Control-Home>, use the Tk binding.
- return
+ return None
if self.text.index("iomark") and \
self.text.compare("iomark", "<=", "insert lineend") and \
self.text.compare("insert linestart", "<=", "iomark"):
@@ -423,6 +422,7 @@ class EditorWindow(object):
rmenu.tk_popup(event.x_root, event.y_root)
if iswin:
self.text.config(cursor="ibeam")
+ return "break"
rmenu_specs = [
# ("Label", "<<virtual-event>>", "statefuncname"), ...
@@ -464,11 +464,13 @@ class EditorWindow(object):
"Handle Help 'About IDLE' event."
# Synchronize with macosx.overrideRootMenu.about_dialog.
help_about.AboutDialog(self.top)
+ return "break"
def config_dialog(self, event=None):
"Handle Options 'Configure IDLE' event."
# Synchronize with macosx.overrideRootMenu.config_dialog.
configdialog.ConfigDialog(self.top,'Settings')
+ return "break"
def help_dialog(self, event=None):
"Handle Help 'IDLE Help' event."
@@ -478,6 +480,7 @@ class EditorWindow(object):
else:
parent = self.top
help.show_idlehelp(parent)
+ return "break"
def python_docs(self, event=None):
if sys.platform[:3] == 'win':
@@ -497,7 +500,7 @@ class EditorWindow(object):
def copy(self,event):
if not self.text.tag_ranges("sel"):
# There is no selection, so do nothing and maybe interrupt.
- return
+ return None
self.text.event_generate("<<Copy>>")
return "break"
@@ -515,6 +518,7 @@ class EditorWindow(object):
def remove_selection(self, event=None):
self.text.tag_remove("sel", "1.0", "end")
self.text.see("insert")
+ return "break"
def move_at_edge_if_selection(self, edge_index):
"""Cursor move begins at start or end of selection
@@ -575,8 +579,9 @@ class EditorWindow(object):
return "break"
text.mark_set("insert", "%d.0" % lineno)
text.see("insert")
+ return "break"
- def open_module(self, event=None):
+ def open_module(self):
"""Get module name from user and open it.
Return module path or None for calls by open_class_browser
@@ -600,21 +605,27 @@ class EditorWindow(object):
self.io.loadfile(file_path)
return file_path
+ def open_module_event(self, event):
+ self.open_module()
+ return "break"
+
def open_class_browser(self, event=None):
filename = self.io.filename
if not (self.__class__.__name__ == 'PyShellEditorWindow'
and filename):
filename = self.open_module()
if filename is None:
- return
+ return "break"
head, tail = os.path.split(filename)
base, ext = os.path.splitext(tail)
from idlelib import browser
browser.ClassBrowser(self.flist, base, [head])
+ return "break"
def open_path_browser(self, event=None):
from idlelib import pathbrowser
pathbrowser.PathBrowser(self.flist)
+ return "break"
def open_turtle_demo(self, event = None):
import subprocess
@@ -623,6 +634,7 @@ class EditorWindow(object):
'-c',
'from turtledemo.__main__ import main; main()']
subprocess.Popen(cmd, shell=False)
+ return "break"
def gotoline(self, lineno):
if lineno is not None and lineno > 0:
@@ -879,6 +891,7 @@ class EditorWindow(object):
def center_insert_event(self, event):
self.center()
+ return "break"
def center(self, mark="insert"):
text = self.text
@@ -910,6 +923,7 @@ class EditorWindow(object):
def close_event(self, event):
self.close()
+ return "break"
def maybesave(self):
if self.io:
@@ -1357,6 +1371,7 @@ class EditorWindow(object):
line = lines[pos]
lines[pos] = '##' + line
self.set_region(head, tail, chars, lines)
+ return "break"
def uncomment_region_event(self, event):
head, tail, chars, lines = self.get_region()
@@ -1370,6 +1385,7 @@ class EditorWindow(object):
line = line[1:]
lines[pos] = line
self.set_region(head, tail, chars, lines)
+ return "break"
def tabify_region_event(self, event):
head, tail, chars, lines = self.get_region()
@@ -1382,6 +1398,7 @@ class EditorWindow(object):
ntabs, nspaces = divmod(effective, tabwidth)
lines[pos] = '\t' * ntabs + ' ' * nspaces + line[raw:]
self.set_region(head, tail, chars, lines)
+ return "break"
def untabify_region_event(self, event):
head, tail, chars, lines = self.get_region()
@@ -1390,6 +1407,7 @@ class EditorWindow(object):
for pos in range(len(lines)):
lines[pos] = lines[pos].expandtabs(tabwidth)
self.set_region(head, tail, chars, lines)
+ return "break"
def toggle_tabs_event(self, event):
if self.askyesno(