| 2270 | | (defun tpu-set-control-keys nil |
|---|
| | 2273 | |
|---|
| | 2274 | (defvar tpu-control-keys-map |
|---|
| | 2275 | (let ((map (make-sparse-keymap))) |
|---|
| | 2276 | (define-key map "\C-\\" 'quoted-insert) ; ^\ |
|---|
| | 2277 | (define-key map "\C-a" 'tpu-toggle-overwrite-mode) ; ^A |
|---|
| | 2278 | (define-key map "\C-b" 'repeat-complex-command) ; ^B |
|---|
| | 2279 | (define-key map "\C-e" 'tpu-current-end-of-line) ; ^E |
|---|
| | 2280 | (define-key map "\C-h" 'tpu-next-beginning-of-line) ; ^H (BS) |
|---|
| | 2281 | (define-key map "\C-j" 'tpu-delete-previous-word) ; ^J (LF) |
|---|
| | 2282 | (define-key map "\C-k" 'tpu-define-macro-key) ; ^K |
|---|
| | 2283 | (define-key map "\C-l" 'tpu-insert-formfeed) ; ^L (FF) |
|---|
| | 2284 | (define-key map "\C-r" 'recenter) ; ^R |
|---|
| | 2285 | (define-key map "\C-u" 'tpu-delete-to-bol) ; ^U |
|---|
| | 2286 | (define-key map "\C-v" 'tpu-quoted-insert) ; ^V |
|---|
| | 2287 | (define-key map "\C-w" 'redraw-display) ; ^W |
|---|
| | 2288 | (define-key map "\C-z" 'tpu-exit) ; ^Z |
|---|
| | 2289 | map)) |
|---|
| | 2290 | |
|---|
| | 2291 | (defun tpu-set-control-keys () |
|---|
| 2272 | | (define-key global-map "\C-\\" 'quoted-insert) ; ^\ |
|---|
| 2273 | | (define-key global-map "\C-a" 'tpu-toggle-overwrite-mode) ; ^A |
|---|
| 2274 | | (define-key global-map "\C-b" 'repeat-complex-command) ; ^B |
|---|
| 2275 | | (define-key global-map "\C-e" 'tpu-current-end-of-line) ; ^E |
|---|
| 2276 | | (define-key global-map "\C-h" 'tpu-next-beginning-of-line) ; ^H (BS) |
|---|
| 2277 | | (define-key global-map "\C-j" 'tpu-delete-previous-word) ; ^J (LF) |
|---|
| 2278 | | (define-key global-map "\C-k" 'tpu-define-macro-key) ; ^K |
|---|
| 2279 | | (define-key global-map "\C-l" 'tpu-insert-formfeed) ; ^L (FF) |
|---|
| 2280 | | (define-key global-map "\C-r" 'recenter) ; ^R |
|---|
| 2281 | | (define-key global-map "\C-u" 'tpu-delete-to-bol) ; ^U |
|---|
| 2282 | | (define-key global-map "\C-v" 'tpu-quoted-insert) ; ^V |
|---|
| 2283 | | (define-key global-map "\C-w" 'redraw-display) ; ^W |
|---|
| 2284 | | (define-key global-map "\C-z" 'tpu-exit) ; ^Z |
|---|
| 2285 | | (setq tpu-control-keys t)) |
|---|
| | 2293 | (tpu-reset-control-keys 'tpu)) |
|---|
| 2289 | | (let* ((tpu (and tpu-style (not tpu-control-keys))) |
|---|
| 2290 | | (emacs (and (not tpu-style) tpu-control-keys)) |
|---|
| 2291 | | (doit (or tpu emacs))) |
|---|
| 2292 | | (cond (doit |
|---|
| 2293 | | (if emacs (setq tpu-global-map (copy-keymap global-map))) |
|---|
| 2294 | | (let ((map (if tpu tpu-global-map tpu-original-global-map))) |
|---|
| 2295 | | |
|---|
| 2296 | | (define-key global-map "\C-\\" (lookup-key map "\C-\\")) ; ^\ |
|---|
| 2297 | | (define-key global-map "\C-a" (lookup-key map "\C-a")) ; ^A |
|---|
| 2298 | | (define-key global-map "\C-b" (lookup-key map "\C-b")) ; ^B |
|---|
| 2299 | | (define-key global-map "\C-e" (lookup-key map "\C-e")) ; ^E |
|---|
| 2300 | | (define-key global-map "\C-h" (lookup-key map "\C-h")) ; ^H (BS) |
|---|
| 2301 | | (define-key global-map "\C-j" (lookup-key map "\C-j")) ; ^J (LF) |
|---|
| 2302 | | (define-key global-map "\C-k" (lookup-key map "\C-k")) ; ^K |
|---|
| 2303 | | (define-key global-map "\C-l" (lookup-key map "\C-l")) ; ^L (FF) |
|---|
| 2304 | | (define-key global-map "\C-r" (lookup-key map "\C-r")) ; ^R |
|---|
| 2305 | | (define-key global-map "\C-u" (lookup-key map "\C-u")) ; ^U |
|---|
| 2306 | | (define-key global-map "\C-v" (lookup-key map "\C-v")) ; ^V |
|---|
| 2307 | | (define-key global-map "\C-w" (lookup-key map "\C-w")) ; ^W |
|---|
| 2308 | | (define-key global-map "\C-z" (lookup-key map "\C-z")) ; ^Z |
|---|
| 2309 | | (setq tpu-control-keys tpu-style)))))) |
|---|
| | 2297 | (let ((parent (keymap-parent tpu-global-map))) |
|---|
| | 2298 | (if tpu-style |
|---|
| | 2299 | (if (eq parent tpu-control-keys-map) |
|---|
| | 2300 | nil ;All done already. |
|---|
| | 2301 | ;; Insert tpu-control-keys-map in the global map. |
|---|
| | 2302 | (set-keymap-parent tpu-control-keys-map parent) |
|---|
| | 2303 | (set-keymap-parent tpu-global-map tpu-control-keys-map)) |
|---|
| | 2304 | (if (not (eq parent tpu-control-keys-map)) |
|---|
| | 2305 | nil ;All done already. |
|---|
| | 2306 | ;; Remove tpu-control-keys-map from the global map. |
|---|
| | 2307 | (set-keymap-parent tpu-global-map (keymap-parent parent)) |
|---|
| | 2308 | (set-keymap-parent tpu-control-keys-map nil))) |
|---|
| | 2309 | (setq tpu-control-keys tpu-style))) |
|---|