]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/realgud/common/key.el
Add 'packages/realgud/' from commit 'd811316e6a0f4eeee8a1347f504c196c86baa2cb'
[gnu-emacs-elpa] / packages / realgud / realgud / common / key.el
1 ;;; Copyright (C) 2010-2011, 2014-2015 Rocky Bernstein <rocky@gnu.org>
2 (require 'load-relative)
3 (require-relative "custom" nil "realgud-")
4
5 (defcustom realgud-populate-common-fn-keys-function
6 'realgud-populate-common-fn-keys-standard
7 "The function to call to populate key bindings common to all dbgr windows.
8 This includes the secondary windows, the debugger shell, and all
9 Ruby source buffers when the debugger is active.
10
11 This variable can be bound to the following:
12
13 * nil -- Don't bind any keys.
14
15 * `realgud-populate-common-fn-keys-standard' -- Bind the function
16 keys according to a widely used debugger convention:
17
18 \\{realgud-example-map-standard}
19
20 * `realgud-populate-common-fn-keys-eclipse' -- Bind according to Eclipse.
21
22 \\{realgud-example-map-eclipse}
23
24 * `realgud-populate-common-fn-keys-netbeans' -- Bind according to NetBeans.
25
26 \\{realgud-example-map-netbeans}
27
28 * Any other value is expected to be a callable function that takes one
29 argument, the keymap, and populates it with suitable keys."
30 :type 'function
31 :group 'realgud)
32
33 ;; -------------------------------------------------------------------
34 ;; Key bindings
35 ;;
36
37 (defun realgud-populate-common-fn-keys-standard (&optional map)
38 "Bind the debugger function key layout used by many debuggers.
39
40 \\{realgud-example-map-standard}"
41 (define-key map [f5] 'realgud-continue)
42 (define-key map [S-f5] 'realgud:cmd-quit)
43 ;; (define-key map [f9] 'realgud-toggle-source-breakpoint)
44 (define-key map [f9] 'realgud:cmd-break)
45 ;; (define-key map [C-f9] 'realgud-toggle-source-breakpoint-enabled)
46 (define-key map [f10] 'realgud:cmd-next)
47 (define-key map [f11] 'realgud:cmd-step)
48 (define-key map [S-f11] 'realgud:cmd-finish)
49 (define-key map [M-down] 'realgud-track-hist-newer)
50 (define-key map [A-down] 'realgud-track-hist-newer)
51 (define-key map [M-kp-2] 'realgud-track-hist-newer)
52 (define-key map [M-up] 'realgud-track-hist-older)
53 (define-key map [A-up] 'realgud-track-hist-older)
54 (define-key map [M-kp-8] 'realgud-track-hist-older)
55 (define-key map [M-kp-up] 'realgud-track-hist-older)
56 (define-key map [M-kp-down] 'realgud-track-hist-newer)
57 (define-key map [M-print] 'realgud-track-hist-older)
58 (define-key map [M-S-down] 'realgud-track-hist-newest)
59 (define-key map [M-S-up] 'realgud-track-hist-oldest)
60 (define-key map "\C-c " 'realgud:cmd-break)
61 )
62
63 ;; TODO: add eclipse, and netbeans
64
65 (defun realgud-populate-common-keys (map)
66 "Define the keys that are used by all debugger buffers, including
67 source-code buffers
68
69 The variable `realgud-populate-common-fn-keys-function' controls the layout."
70 (define-key map "\C-x\C-a\C-q" 'realgud-short-key-mode)
71 (if realgud-populate-common-fn-keys-function
72 (funcall realgud-populate-common-fn-keys-function map))
73 (realgud-populate-common-fn-keys-standard map)
74 )
75
76 (defun realgud-populate-src-buffer-map-plain (map)
77 "Bind ordinary text characters used in debugger source-code buffers.
78
79 This does not touch change menus; for that see `realgud-populate-debugger-menu'.
80 Nor does it touch prefix keys; for that see `realgud-populate-keys-standard'"
81 ;; Common Debugger functions
82 (let ((prefix-map (make-sparse-keymap)))
83 (define-key map "b" 'realgud:cmd-break)
84 (define-key map "D" 'realgud:cmd-delete)
85 (define-key map [delete] 'realgud:cmd-delete)
86 (define-key map " " 'realgud:cmd-step)
87 (define-key map "f" 'realgud:cmd-finish)
88 (define-key map "n" 'realgud:cmd-next)
89 (define-key map "q" 'realgud:cmd-quit)
90 (define-key map "r" 'realgud:cmd-restart)
91 (define-key map "R" 'realgud:cmd-restart)
92 (define-key map "s" 'realgud:cmd-step)
93 (define-key map "!" 'realgud:cmd-shell)
94
95 ;; FIXME: these can go to a common routine. See also shortkey.el
96 ;; and backtrace-mode.el
97 (define-key map "<" 'realgud:cmd-newer-frame)
98 (define-key map ">" 'realgud:cmd-older-frame)
99 (define-key map "d" 'realgud:cmd-newer-frame)
100 (define-key map "u" 'realgud:cmd-older-frame)
101 (define-key map "C" 'realgud-window-cmd-undisturb-src)
102 (define-key map "F" 'realgud:window-bt)
103 (define-key map "Q" 'realgud:cmd-terminate)
104 (define-key map "S" 'realgud-window-src-undisturb-cmd)
105 (define-key map "U" 'realgud:cmd-until)
106
107 (define-key map [M-down] 'realgud-track-hist-newer)
108 (define-key map [M-kp-2] 'realgud-track-hist-newer)
109 (define-key map [M-up] 'realgud-track-hist-older)
110 (define-key map [M-kp-8] 'realgud-track-hist-older)
111 (define-key map [M-kp-up] 'realgud-track-hist-older)
112 (define-key map [M-kp-down] 'realgud-track-hist-newer)
113 (define-key map [M-print] 'realgud-track-hist-older)
114 (define-key map [M-S-down] 'realgud-track-hist-newest)
115 (define-key map [M-S-up] 'realgud-track-hist-oldest)
116 ))
117
118 (provide-me "realgud-")