3 ;;; Copyright (C) 2003-2005 Peter Graves
4 ;;; $Id: key-pressed.lisp,v 1.8 2005/11/18 01:47:25 piso Exp $
6 ;;; This program is free software; you can redistribute it and/or
7 ;;; modify it under the terms of the GNU General Public License
8 ;;; as published by the Free Software Foundation; either version 2
9 ;;; of the License, or (at your option) any later version.
11 ;;; This program is distributed in the hope that it will be useful,
12 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with this program; if not, write to the Free Software
18 ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 (unless (find-package "KEY-PRESSED")
21 (make-package "KEY-PRESSED" :nicknames
'("KP") :use
'("CL" "J")))
23 (in-package "KEY-PRESSED")
27 (defcommand open-file
)
28 (defcommand open-file-in-other-window
)
29 (defcommand open-file-in-other-frame
)
30 ;; (defcommand new-buffer)
31 (defcommand recent-files
)
34 (defcommand save-copy
)
36 (defcommand kill-buffer
)
37 (defcommand properties
)
38 (defcommand next-buffer
)
39 (defcommand prev-buffer
)
40 (defcommand new-frame
)
41 ;; (defcommand execute-command "executeCommand")
42 ;; (defcommand j-print "print")
43 (defcommand save-all-exit
)
45 (defcommand jump-to-line
)
46 (defcommand jump-to-column
)
47 (defcommand j-find
"find")
48 (defcommand incremental-find
)
49 (defcommand list-occurrences
)
50 (defcommand find-in-files
)
51 (defcommand list-files
)
52 (defcommand sidebar-list-tags
)
53 (defcommand j-replace
"replace")
54 (defcommand replace-in-files
)
56 (defcommand goto-bookmark
)
58 (defcommand describe-key
)
59 (defcommand next-frame
)
60 (defcommand select-word
)
61 (defcommand kill-frame
)
62 (defcommand toggle-sidebar
)
63 (defcommand sidebar-list-buffers
)
64 (defcommand split-window
)
65 (defcommand unsplit-window
)
66 (defcommand other-window
)
69 ;;; Incremental find needs special handling.
70 (defun invoke-incremental-find ()
71 (location-bar-cancel-input)
73 (invoke-later 'incremental-find
))
75 (defvar *table
* (make-hash-table :test
#'equalp
))
77 ;;; Object can be a symbol or a function.
78 (defun assign-key (key object
)
79 (setf (gethash key
*table
*) object
))
81 ;;; The hook function.
82 (defun key-pressed (&rest args
)
83 (let* ((key (car args
))
84 (value (gethash key
*table
*)))
87 (and (symbolp value
) (fboundp value
))))
93 (location-bar-cancel-input)
96 (assign-key "Ctrl Alt O"
97 #'(lambda () (open-file-in-other-window) (update-location-bar)))
98 (assign-key "Ctrl Shift O" 'open-file-in-other-frame
)
99 ;; Ctrl N is used for history in textfields.
100 ;; (assign-key "Ctrl N" 'new-buffer)
101 (assign-key "Alt R" 'recent-files
)
102 (assign-key "Ctrl S" 'save
)
103 (assign-key "Ctrl Shift S" 'save-as
)
104 (assign-key "Ctrl Alt S" 'save-copy
)
105 (assign-key "F2" 'save-all
)
106 (assign-key "Ctrl F4" 'kill-buffer
)
107 (assign-key "Ctrl W" 'kill-buffer
)
108 (assign-key "Alt P" 'properties
)
109 (assign-key "Alt NumPad Right"
110 #'(lambda () (restore-focus) (next-buffer)))
111 (assign-key "Alt Right"
112 #'(lambda () (restore-focus) (next-buffer)))
113 (assign-key "Alt NumPad Left"
114 #'(lambda () (restore-focus) (prev-buffer)))
115 (assign-key "Alt Left"
116 #'(lambda () (restore-focus) (prev-buffer)))
117 (assign-key "Ctrl Shift N" 'new-frame
)
118 (assign-key "Alt X" 'execute-command
)
119 ;; Ctrl P is used for history in textfields.
120 ;; (assign-key "Ctrl P" 'j-print)
121 (assign-key "Ctrl Shift Q" 'save-all-exit
)
122 (assign-key "Ctrl Q" 'quit
)
123 (assign-key "Ctrl J" 'jump-to-line
)
124 (assign-key "Ctrl Shift J" 'jump-to-column
)
126 #'(lambda () (location-bar-cancel-input) (restore-focus) (j-find)))
127 (assign-key "Ctrl F" 'invoke-incremental-find
)
128 (assign-key "Alt L" 'list-occurrences
)
129 (assign-key "F6" 'find-in-files
)
130 (assign-key "Ctrl Shift F" 'find-in-files
)
131 (assign-key "Ctrl L" 'list-files
)
132 (assign-key "Ctrl Shift L" 'sidebar-list-tags
)
133 (assign-key "Ctrl R" 'j-replace
)
134 (assign-key "Ctrl Shift R" 'replace-in-files
)
135 (assign-key "Ctrl D" 'dir
)
136 (assign-key "Ctrl 0" 'goto-bookmark
)
137 (assign-key "Ctrl 1" 'goto-bookmark
)
138 (assign-key "Ctrl 2" 'goto-bookmark
)
139 (assign-key "Ctrl 3" 'goto-bookmark
)
140 (assign-key "Ctrl 4" 'goto-bookmark
)
141 (assign-key "Ctrl 5" 'goto-bookmark
)
142 (assign-key "Ctrl 6" 'goto-bookmark
)
143 (assign-key "Ctrl 7" 'goto-bookmark
)
144 (assign-key "Ctrl 8" 'goto-bookmark
)
145 (assign-key "Ctrl 9" 'goto-bookmark
)
146 (assign-key "F1" 'help
)
147 (assign-key "Alt K" 'describe-key
)
148 (assign-key "Alt N" 'next-frame
)
149 (assign-key "Alt W" 'select-word
)
150 (assign-key "Ctrl Shift W" 'kill-frame
)
151 (assign-key "Alt =" 'toggle-sidebar
)
152 (assign-key "Alt B" 'sidebar-list-buffers
)
153 (assign-key "F10" 'split-window
)
154 (assign-key "Shift F10" 'unsplit-window
)
155 (assign-key "Alt O" 'other-window
)
157 #'(lambda () (restore-focus) (shell)))
160 (add-hook 'key-pressed-hook
'key-pressed
)
161 (set-global-property "enableKeyPressedHook" t
)
163 ;; NOTE: ENABLE-KEY-PRESSED-HOOK will be reset to its default value (NIL) when
164 ;; preferences are reloaded (which happens automatically when you edit your
165 ;; preferences file). To prevent this (and keep the key-pressed hook working
166 ;; properly across preference file edits), add this line to ~/.j/prefs:
168 ;; enableKeyPressedHook = true