summaryrefslogtreecommitdiffstats
path: root/Tools/idle/Bindings.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-10-10 18:48:31 (GMT)
committerGuido van Rossum <guido@python.org>1998-10-10 18:48:31 (GMT)
commit3b4ca0ddad8d1e224f71e89f4c7fbc8de5c6edc4 (patch)
tree1a66ed7c7eec87f31d61a2a083096e5cad89a39c /Tools/idle/Bindings.py
parentdc1adabcb86ee0813c9bae2d5cc59be5cad1ff31 (diff)
downloadcpython-3b4ca0ddad8d1e224f71e89f4c7fbc8de5c6edc4.zip
cpython-3b4ca0ddad8d1e224f71e89f4c7fbc8de5c6edc4.tar.gz
cpython-3b4ca0ddad8d1e224f71e89f4c7fbc8de5c6edc4.tar.bz2
Initial checking of Tk-based Python IDE.
Features: text editor with syntax coloring and undo; subclassed into interactive Python shell which adds history.
Diffstat (limited to 'Tools/idle/Bindings.py')
-rw-r--r--Tools/idle/Bindings.py92
1 files changed, 92 insertions, 0 deletions
diff --git a/Tools/idle/Bindings.py b/Tools/idle/Bindings.py
new file mode 100644
index 0000000..9e2e791
--- /dev/null
+++ b/Tools/idle/Bindings.py
@@ -0,0 +1,92 @@
+# The first item of each tuple is the virtual event;
+# each of the remaining items is an actual key binding for the event.
+# (This conveniently forms an argument list for event_add().)
+
+win_bindings = [
+ ("<<beginning-of-line>>", "<Control-a>", "<Home>"),
+
+ ("<<expand-word>>", "<Meta-slash>", "<Alt-slash>"),
+
+ ("<<newline-and-indent>>", "<Key-Return>", "<KP_Enter>"),
+ ("<<plain-newline-and-indent>>", "<Control-j>"),
+
+ ("<<interrupt-execution>>", "<Control-c>"),
+ ("<<end-of-file>>", "<Control-d>"),
+
+ ("<<dedent-region>>", "<Control-bracketleft>"),
+ ("<<indent-region>>", "<Control-bracketright>"),
+
+ ("<<comment-region>>", "<Meta-Key-3>", "<Alt-Key-3>"),
+ ("<<uncomment-region>>", "<Meta-Key-4>", "<Alt-Key-4>"),
+
+ ("<<history-previous>>", "<Meta-p>", "<Alt-p>"),
+ ("<<history-next>>", "<Meta-n>", "<Alt-n>"),
+
+ ("<<toggle-auto-coloring>>", "<Control-slash>"),
+
+ ("<<close-all-windows>>", "<Control-q>"),
+ ("<<open-new-window>>", "<Control-n>"),
+ ("<<open-window-from-file>>", "<Control-o>"),
+ ("<<save-window>>", "<Control-s>"),
+ ("<<save-window-as-file>>", "<Control-w>"),
+ ("<<save-copy-of-window-as-file>>", "<Meta-w>"),
+
+ ("<<find>>", "<Control-f>"),
+ ("<<find-next>>", "<F3>"),
+ ("<<find-same>>", "<Control-F3>"),
+ ("<<goto-line>>", "<Alt-g>", "<Meta-g>"),
+
+ ("<<undo>>", "<Control-z>"),
+ ("<<redo>>", "<Control-y>"),
+ ("<<dump-undo-state>>", "<Control-backslash>"),
+]
+
+emacs_bindings = [
+ ("<<beginning-of-line>>", "<Control-a>", "<Home>"),
+ ("<<center-insert>>", "<Control-l>"),
+
+ ("<<expand-word>>", "<Meta-slash>", "<Alt-slash>"),
+
+ ("<<newline-and-indent>>", "<Key-Return>", "<KP_Enter>"),
+ ("<<plain-newline-and-indent>>", "<Control-j>"),
+
+ ("<<interrupt-execution>>", "<Control-c>"),
+ ("<<end-of-file>>", "<Control-d>"),
+
+ ("<<dedent-region>>",
+ "<Meta-bracketleft>", "<Alt-bracketleft>", "<Control-bracketleft>"),
+ ("<<indent-region>>",
+ "<Meta-bracketright>", "<Alt-bracketright>", "<Control-bracketright>"),
+
+ ("<<comment-region>>", "<Meta-Key-3>", "<Alt-Key-3>"),
+ ("<<uncomment-region>>", "<Meta-Key-4>", "<Alt-Key-4>"),
+
+ ("<<history-previous>>", "<Meta-p>", "<Alt-p>"),
+ ("<<history-next>>", "<Meta-n>", "<Alt-n>"),
+
+ ("<<toggle-auto-coloring>>", "<Control-slash>"),
+
+ ("<<close-all-windows>>", "<Control-x><Control-c>"),
+ ("<<close-window>>", "<Control-x><Control-0>"),
+ ("<<open-new-window>>", "<Control-x><Control-n>"),
+ ("<<open-window-from-file>>", "<Control-x><Control-f>"),
+ ("<<save-window>>", "<Control-x><Control-s>"),
+ ("<<save-window-as-file>>", "<Control-x><Control-w>"),
+ ("<<save-copy-of-window-as-file>>", "<Control-x><w>"),
+
+ ("<<find>>", "<Control-u><Control-u><Control-s>"),
+ ("<<find-next>>", "<Control-u><Control-s>"),
+ ("<<find-same>>", "<Control-s>"),
+ ("<<goto-line>>", "<Alt-g>", "<Meta-g>"),
+
+ ("<<undo>>", "<Control-z>"),
+ ("<<redo>>", "<Alt-z>", "<Meta-z>"),
+ ("<<dump-undo-state>>", "<Control-backslash>"),
+]
+
+default_bindings = emacs_bindings
+
+def apply_bindings(text, bindings=default_bindings):
+ event_add = text.event_add
+ for args in bindings:
+ apply(event_add, args)