summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/EditorWindow.py
diff options
context:
space:
mode:
authorKurt B. Kaiser <kbk@shore.net>2008-04-27 21:07:41 (GMT)
committerKurt B. Kaiser <kbk@shore.net>2008-04-27 21:07:41 (GMT)
commit93cdae5f814292da17c38374d0cfa314b96fd3be (patch)
tree8db13b28475d28468763db5a7d57de10d611f888 /Lib/idlelib/EditorWindow.py
parentef1e58b6f39b4691a10a184a68536e32e5eedbce (diff)
downloadcpython-93cdae5f814292da17c38374d0cfa314b96fd3be.zip
cpython-93cdae5f814292da17c38374d0cfa314b96fd3be.tar.gz
cpython-93cdae5f814292da17c38374d0cfa314b96fd3be.tar.bz2
Home / Control-A toggles between left margin and end of leading white
space. Patch 1196903 Jeff Shute. M idlelib/PyShell.py M idlelib/EditorWindow.py M idlelib/NEWS.txt
Diffstat (limited to 'Lib/idlelib/EditorWindow.py')
-rw-r--r--Lib/idlelib/EditorWindow.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
index b1c9734..8d35198c 100644
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -153,6 +153,7 @@ class EditorWindow(object):
text.bind("<Right>", self.move_at_edge_if_selection(1))
text.bind("<<del-word-left>>", self.del_word_left)
text.bind("<<del-word-right>>", self.del_word_right)
+ text.bind("<<beginning-of-line>>", self.home_callback)
if flist:
flist.inversedict[self] = key
@@ -281,6 +282,50 @@ class EditorWindow(object):
self.flist.new(dirname)
return "break"
+ def home_callback(self, event):
+ if (event.state & 12) != 0 and event.keysym == "Home":
+ # state&1==shift, state&4==control, state&8==alt
+ return # <Modifier-Home>; fall back to class binding
+
+ if self.text.index("iomark") and \
+ self.text.compare("iomark", "<=", "insert lineend") and \
+ self.text.compare("insert linestart", "<=", "iomark"):
+ insertpt = int(self.text.index("iomark").split(".")[1])
+ else:
+ line = self.text.get("insert linestart", "insert lineend")
+ for insertpt in xrange(len(line)):
+ if line[insertpt] not in (' ','\t'):
+ break
+ else:
+ insertpt=len(line)
+
+ lineat = int(self.text.index("insert").split('.')[1])
+
+ if insertpt == lineat:
+ insertpt = 0
+
+ dest = "insert linestart+"+str(insertpt)+"c"
+
+ if (event.state&1) == 0:
+ # shift not pressed
+ self.text.tag_remove("sel", "1.0", "end")
+ else:
+ if not self.text.index("sel.first"):
+ self.text.mark_set("anchor","insert")
+
+ first = self.text.index(dest)
+ last = self.text.index("anchor")
+
+ if self.text.compare(first,">",last):
+ first,last = last,first
+
+ self.text.tag_remove("sel", "1.0", "end")
+ self.text.tag_add("sel", first, last)
+
+ self.text.mark_set("insert", dest)
+ self.text.see("insert")
+ return "break"
+
def set_status_bar(self):
self.status_bar = self.MultiStatusBar(self.top)
if macosxSupport.runningAsOSXApp():