summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/EditorWindow.py
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2003-01-17 04:04:06 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2003-01-17 04:04:06 (GMT)
commit5ec186b1cbf06cf66262882fb5b6f54a893e48a5 (patch)
tree65ffeb7feeb6c59b640773435b3282c6110a79f5 /Lib/idlelib/EditorWindow.py
parent9fd0799ff5e125e31f26a6240dac6064832b501c (diff)
downloadcpython-5ec186b1cbf06cf66262882fb5b6f54a893e48a5.zip
cpython-5ec186b1cbf06cf66262882fb5b6f54a893e48a5.tar.gz
cpython-5ec186b1cbf06cf66262882fb5b6f54a893e48a5.tar.bz2
Patch 611069 (Christos Georgiou) IDLE TODO:left/right when selected text
M EditorWindow.py M NEWS.txt M TODO.txt
Diffstat (limited to 'Lib/idlelib/EditorWindow.py')
-rw-r--r--Lib/idlelib/EditorWindow.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
index b9522fc..fcb1612 100644
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -132,6 +132,8 @@ class EditorWindow:
text.bind("<<untabify-region>>",self.untabify_region_event)
text.bind("<<toggle-tabs>>",self.toggle_tabs_event)
text.bind("<<change-indentwidth>>",self.change_indentwidth_event)
+ text.bind("<Left>", self.move_at_edge_if_selection(0))
+ text.bind("<Right>", self.move_at_edge_if_selection(1))
if flist:
flist.inversedict[self] = key
@@ -344,6 +346,26 @@ class EditorWindow:
self.text.tag_remove("sel", "1.0", "end")
self.text.see("insert")
+ def move_at_edge_if_selection(self, edge_index):
+ """Cursor move begins at start or end of selection
+
+ When a left/right cursor key is pressed create and return to Tkinter a
+ function which causes a cursor move from the associated edge of the
+ selection.
+
+ """
+ self_text_index = self.text.index
+ self_text_mark_set = self.text.mark_set
+ edges_table = ("sel.first+1c", "sel.last-1c")
+ def move_at_edge(event):
+ if (event.state & 5) == 0: # no shift(==1) or control(==4) pressed
+ try:
+ self_text_index("sel.first")
+ self_text_mark_set("insert", edges_table[edge_index])
+ except TclError:
+ pass
+ return move_at_edge
+
def find_event(self, event):
SearchDialog.find(self.text)
return "break"