Mercurial > emacs
annotate lisp/emulation/keypad.el @ 109581:06384b3caebf
Add ability to put Gtk+ tool bar on the left/right/bottom or top. Default top.
* lisp/menu-bar.el (menu-bar-showhide-tool-bar-menu-customize-enable-left)
(menu-bar-showhide-tool-bar-menu-customize-disable)
(menu-bar-showhide-tool-bar-menu-customize-enable-right)
(menu-bar-showhide-tool-bar-menu-customize-enable-top)
(menu-bar-showhide-tool-bar-menu-customize-enable-bottom): New functions
(menu-bar-showhide-tool-bar-menu): If tool bar is moveable,
make a menu for Options => toolbar that can move it.
* src/frame.c (Qtool_bar_position): New variable.
(make_frame): Set tool_bar_position to Qtop.
(frame_parms): Add tool-bar-position.
(x_report_frame_params): Store tool_bar_position.
(x_set_fringe_width): Reset wm size hint after fringe changes.
* src/frame.h (struct frame): Add tool_bar_position.
(Qbottom): Declare.
* src/gtkutil.c (FRAME_TOTAL_PIXEL_WIDTH): New macro.
(xg_frame_set_char_size): Add FRAME_TOOLBAR_WIDTH to pixelwidth.
(xg_height_or_width_changed): Use FRAME_TOTAL_PIXEL_WIDTH.
(xg_create_frame_widgets): Create a hobox for placing widgets
vertically. Use gtk_box_pack_start.
(xg_height_or_width_changed): Renamed from xg_height_changed.
(x_wm_set_size_hint): Add FRAME_TOOLBAR_WIDTH to base_width.
(xg_update_frame_menubar, free_frame_menubar): Change to
xg_height_or_width_changed.
(xg_tool_bar_detach_callback): Update left/right/top/bottom tool bar
size correctly. Remove hardcoded 4, instead use handlebox size -
toolbar size.
(xg_tool_bar_attach_callback): Update left/right/top/bottom tool bar
size correctly. Use handlebox size + toolbar size as additional
size.
(xg_pack_tool_bar): POS is a new parameter.
Set orientation of tool bar based on pos.
Only make handlebox_widget if NULL.
Check if tool bar goes to vbox or hbox depending on pos.
(xg_update_tool_bar_sizes): New function.
(update_frame_tool_bar): Remove old_req, new_req. Do not get tool bar
height, call xg_update_tool_bar_sizes instead.
(free_frame_tool_bar): Remove from hbox or vbox depending on
toolbar_in_hbox, Set all FRAME_TOOLBAR_*_(WIDTH|HEIGHT) to zero.
(xg_change_toolbar_position): New function.
* src/gtkutil.h (xg_change_toolbar_position): Declare.
* src/window.c (calc_absolute_offset): Check for FRAME_TOOLBAR_TOP_HEIGHT
and FRAME_TOOLBAR_LEFT_WIDTH.
* src/xfns.c (x_set_tool_bar_position): New function.
(xic_set_statusarea): Use FRAME_TOOLBAR_TOP_HEIGHT.
(x_frame_parm_handlers): Add x_set_tool_bar_position.
(syms_of_xfns): if USE_GTK, provide move-toolbar.
* src/xterm.c (x_set_window_size_1): Add FRAME_TOOLBAR_WIDTH to pixelwidth.
* src/xterm.h (struct x_output): Add toolbar_top_height,
toolbar_bottom_height, toolbar_left_width, toolbar_right_width. Remove
toolbar_height.
if USE_GTK: Add hbox_widget and toolbar_in_hbox.
(FRAME_TOOLBAR_TOP_HEIGHT, FRAME_TOOLBAR_BOTTOM_HEIGHT)
(FRAME_TOOLBAR_LEFT_WIDTH, FRAME_TOOLBAR_RIGHT_WIDTH): New macros.
(FRAME_TOOLBAR_HEIGHT): Is now TOP_HEIGHT + BOTTOM_HEIGHT.
author | Jan D. <jan.h.d@swipnet.se> |
---|---|
date | Thu, 29 Jul 2010 18:49:59 +0200 |
parents | 1d1d5d9bd884 |
children | 376148b31b5e |
rev | line source |
---|---|
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
1 ;;; keypad.el --- simplified keypad bindings |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
2 |
75223
cc42c775a741
(keypad-setup): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
3 ;; Copyright (C) 2002, 2003, 2004, 2005, 2006, |
106815 | 4 ;; 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
5 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
6 ;; Author: Kim F. Storm <storm@cua.dk> |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
7 ;; Keywords: keyboard convenience |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
8 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
10 |
94658
eb7b2376cae5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
94658
eb7b2376cae5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
eb7b2376cae5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; (at your option) any later version. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
15 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
20 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
94658
eb7b2376cae5
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
23 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
24 ;;; Commentary: |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
25 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
26 ;; The keypad package allows easy binding of the keypad keys to |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
27 ;; various commonly used sets of commands. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
28 ;; |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
29 ;; With the following setup, the keypad can be used for numeric data |
45296 | 30 ;; entry when NumLock is off, and to give numeric prefix arguments to |
31 ;; emacs commands, when NumLock on on. | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
32 ;; |
45296 | 33 ;; keypad-setup => Plain Numeric Keypad |
34 ;; keypad-numlock-setup => Prefix numeric args | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
35 ;; |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
36 ;; +--------+--------+--------+ |
45296 | 37 ;; | M-7 | M-8 | M-9 | <- numlock on |
38 ;; | 7 | 8 | 9 | <- numlock off | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
39 ;; +--------+--------+--------+ |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
40 ;; | M-4 | M-5 | M-6 | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
41 ;; | 4 | 5 | 6 | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
42 ;; +--------+--------+--------+ |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
43 ;; | M-1 | M-2 | M-3 | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
44 ;; | 1 | 2 | 3 | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
45 ;; +--------+--------+--------+ |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
46 ;; | M-0 | M-- | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
47 ;; | 0 | . | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
48 ;; +-----------------+--------+ |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
49 |
45296 | 50 ;; The following keypad setup is used for navigation together with |
51 ;; modes like cua-mode which uses shifted movement keys to extend the | |
52 ;; region. | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
53 ;; |
45296 | 54 ;; keypad-setup => Cursor keys |
55 ;; keypad-shifted-setup => Shifted cursor keys | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
56 ;; |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
57 ;; +--------+--------+--------+ |
45296 | 58 ;; | S-home | S-up | S-PgUp | <- shifted, numlock off |
59 ;; | Home | up | PgUp | <- unshifted, numlock off | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
60 ;; +--------+--------+--------+ |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
61 ;; | S-left |S-space |S-right | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
62 ;; | left | space | right | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
63 ;; +--------+--------+--------+ |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
64 ;; | S-end | S-down | S-PgDn | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
65 ;; | end | down | PgDn | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
66 ;; +--------+--------+--------+ |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
67 ;; | S-insert |S-delete| |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
68 ;; | insert | delete | |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
69 ;; +-----------------+--------+ |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
70 |
45296 | 71 ;; The following setup binds the unshifted keypad keys to plain |
72 ;; numeric keys when NumLock is either on or off, but the decimal key | |
73 ;; produces either a . (NumLock off) or a , (NumLock on). This is | |
74 ;; useful for e.g. Danish users where the decimal separator is a | |
75 ;; comma. | |
76 ;; | |
77 ;; keypad-setup => Plain Numeric Keypad | |
78 ;; keypad-numlock-setup => Numeric Keypad with Decimal key: , | |
79 ;; | |
80 ;; +--------+--------+--------+ | |
81 ;; | 7 | 8 | 9 | <- numlock on | |
82 ;; | 7 | 8 | 9 | <- numlock off | |
83 ;; +--------+--------+--------+ | |
84 ;; | 4 | 5 | 6 | | |
85 ;; | 4 | 5 | 6 | | |
86 ;; +--------+--------+--------+ | |
87 ;; | 1 | 2 | 3 | | |
88 ;; | 1 | 2 | 3 | | |
89 ;; +--------+--------+--------+ | |
90 ;; | 0 | , | | |
91 ;; | 0 | . | | |
92 ;; +-----------------+--------+ | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
93 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
94 ;;; Code: |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
95 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
96 (provide 'keypad) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
97 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
98 ;;; Customization |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
99 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
100 ;;;###autoload |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
101 (defcustom keypad-setup nil |
45296 | 102 "Specifies the keypad setup for unshifted keypad keys when NumLock is off. |
103 When selecting the plain numeric keypad setup, the character returned by the | |
104 decimal key must be specified." | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
105 :set (lambda (symbol value) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
106 (if value |
45296 | 107 (keypad-setup value nil nil value))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
108 :initialize 'custom-initialize-default |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
109 :link '(emacs-commentary-link "keypad.el") |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
110 :version "22.1" |
45296 | 111 :type '(choice (const :tag "Plain numeric keypad" numeric) |
112 (character :tag "Numeric Keypad with Decimal Key" | |
113 :match (lambda (widget value) (integerp value)) | |
114 :value ?.) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47484
diff
changeset
|
115 (const :tag "Numeric prefix arguments" prefix) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
116 (const :tag "Cursor keys" cursor) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
117 (const :tag "Shifted cursor keys" S-cursor) |
47484
02bdb3eae562
(keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents:
45990
diff
changeset
|
118 (const :tag "Unspecified/User-defined" none) |
45296 | 119 (other :tag "Keep existing bindings" nil)) |
45990
f9d81d6b86b5
Added :require 'keypad to defcustoms.
Kim F. Storm <storm@cua.dk>
parents:
45953
diff
changeset
|
120 :require 'keypad |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
121 :group 'keyboard) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
122 |
45296 | 123 ;;;###autoload |
124 (defcustom keypad-numlock-setup nil | |
125 "Specifies the keypad setup for unshifted keypad keys when NumLock is on. | |
126 When selecting the plain numeric keypad setup, the character returned by the | |
127 decimal key must be specified." | |
128 :set (lambda (symbol value) | |
129 (if value | |
130 (keypad-setup value t nil value))) | |
131 :initialize 'custom-initialize-default | |
132 :link '(emacs-commentary-link "keypad.el") | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
133 :version "22.1" |
45296 | 134 :type '(choice (const :tag "Plain numeric keypad" numeric) |
135 (character :tag "Numeric Keypad with Decimal Key" | |
136 :match (lambda (widget value) (integerp value)) | |
137 :value ?.) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47484
diff
changeset
|
138 (const :tag "Numeric prefix arguments" prefix) |
45296 | 139 (const :tag "Cursor keys" cursor) |
140 (const :tag "Shifted cursor keys" S-cursor) | |
47484
02bdb3eae562
(keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents:
45990
diff
changeset
|
141 (const :tag "Unspecified/User-defined" none) |
45296 | 142 (other :tag "Keep existing bindings" nil)) |
45990
f9d81d6b86b5
Added :require 'keypad to defcustoms.
Kim F. Storm <storm@cua.dk>
parents:
45953
diff
changeset
|
143 :require 'keypad |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
144 :group 'keyboard) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
145 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
146 ;;;###autoload |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
147 (defcustom keypad-shifted-setup nil |
45296 | 148 "Specifies the keypad setup for shifted keypad keys when NumLock is off. |
149 When selecting the plain numeric keypad setup, the character returned by the | |
150 decimal key must be specified." | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
151 :set (lambda (symbol value) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
152 (if value |
45296 | 153 (keypad-setup value nil t value))) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
154 :initialize 'custom-initialize-default |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
155 :link '(emacs-commentary-link "keypad.el") |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
156 :version "22.1" |
45296 | 157 :type '(choice (const :tag "Plain numeric keypad" numeric) |
158 (character :tag "Numeric Keypad with Decimal Key" | |
159 :match (lambda (widget value) (integerp value)) | |
160 :value ?.) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47484
diff
changeset
|
161 (const :tag "Numeric prefix arguments" prefix) |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
162 (const :tag "Cursor keys" cursor) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
163 (const :tag "Shifted cursor keys" S-cursor) |
47484
02bdb3eae562
(keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents:
45990
diff
changeset
|
164 (const :tag "Unspecified/User-defined" none) |
45296 | 165 (other :tag "Keep existing bindings" nil)) |
45990
f9d81d6b86b5
Added :require 'keypad to defcustoms.
Kim F. Storm <storm@cua.dk>
parents:
45953
diff
changeset
|
166 :require 'keypad |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
167 :group 'keyboard) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
168 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
169 ;;;###autoload |
45296 | 170 (defcustom keypad-numlock-shifted-setup nil |
171 "Specifies the keypad setup for shifted keypad keys when NumLock is off. | |
172 When selecting the plain numeric keypad setup, the character returned by the | |
173 decimal key must be specified." | |
174 :set (lambda (symbol value) | |
175 (if value | |
176 (keypad-setup value t t value))) | |
177 :initialize 'custom-initialize-default | |
178 :link '(emacs-commentary-link "keypad.el") | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
52401
diff
changeset
|
179 :version "22.1" |
45296 | 180 :type '(choice (const :tag "Plain numeric keypad" numeric) |
181 (character :tag "Numeric Keypad with Decimal Key" | |
182 :match (lambda (widget value) (integerp value)) | |
183 :value ?.) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47484
diff
changeset
|
184 (const :tag "Numeric prefix arguments" prefix) |
45296 | 185 (const :tag "Cursor keys" cursor) |
186 (const :tag "Shifted cursor keys" S-cursor) | |
47484
02bdb3eae562
(keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents:
45990
diff
changeset
|
187 (const :tag "Unspecified/User-defined" none) |
45296 | 188 (other :tag "Keep existing bindings" nil)) |
45990
f9d81d6b86b5
Added :require 'keypad to defcustoms.
Kim F. Storm <storm@cua.dk>
parents:
45953
diff
changeset
|
189 :require 'keypad |
45296 | 190 :group 'keyboard) |
191 | |
192 | |
193 ;;;###autoload | |
194 (defun keypad-setup (setup &optional numlock shift decimal) | |
75223
cc42c775a741
(keypad-setup): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
195 "Set keypad bindings in `function-key-map' according to SETUP. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
196 If optional second argument NUMLOCK is non-nil, the NumLock On bindings |
75223
cc42c775a741
(keypad-setup): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
68648
diff
changeset
|
197 are changed. Otherwise, the NumLock Off bindings are changed. |
45296 | 198 If optional third argument SHIFT is non-nil, the shifted keypad |
199 keys are bound. | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
200 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
201 Setup Binding |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
202 ------------------------------------------------------------- |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
203 'prefix Command prefix argument, i.e. M-0 .. M-9 and M-- |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
204 'S-cursor Bind shifted keypad keys to the shifted cursor movement keys. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
205 'cursor Bind keypad keys to the cursor movement keys. |
45296 | 206 'numeric Plain numeric keypad, i.e. 0 .. 9 and . (or DECIMAL arg) |
47484
02bdb3eae562
(keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents:
45990
diff
changeset
|
207 'none Removes all bindings for keypad keys in function-key-map; |
02bdb3eae562
(keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents:
45990
diff
changeset
|
208 this enables any user-defined bindings for the keypad keys |
02bdb3eae562
(keypad-setup, keypad-shifted-setup)
Kim F. Storm <storm@cua.dk>
parents:
45990
diff
changeset
|
209 in the global and local keymaps. |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
210 |
45296 | 211 If SETUP is 'numeric and the optional fourth argument DECIMAL is non-nil, |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
212 the decimal key on the keypad is mapped to DECIMAL instead of `.'" |
45296 | 213 (let* ((i 0) |
214 (var (cond | |
215 ((and (not numlock) (not shift)) 'keypad-setup) | |
216 ((and (not numlock) shift) 'keypad-shifted-setup) | |
217 ((and numlock (not shift)) 'keypad-numlock-setup) | |
218 ((and numlock shift) 'keypad-numlock-shifted-setup))) | |
219 (kp (cond | |
220 ((eq var 'keypad-setup) | |
221 [kp-delete kp-insert kp-end kp-down kp-next kp-left | |
222 kp-space kp-right kp-home kp-up kp-prior]) | |
223 ((eq var 'keypad-shifted-setup) | |
224 [S-kp-decimal S-kp-0 S-kp-1 S-kp-2 S-kp-3 S-kp-4 | |
225 S-kp-5 S-kp-6 S-kp-7 S-kp-8 S-kp-9]) | |
226 ((eq var 'keypad-numlock-setup) | |
227 [kp-decimal kp-0 kp-1 kp-2 kp-3 kp-4 | |
228 kp-5 kp-6 kp-7 kp-8 kp-9]) | |
229 ((eq var 'keypad-numlock-shifted-setup) | |
230 [S-kp-delete S-kp-insert S-kp-end S-kp-down S-kp-next S-kp-left | |
231 S-kp-space S-kp-right S-kp-home S-kp-up S-kp-prior]))) | |
232 (bind | |
233 (cond | |
234 ((or (eq setup 'numeric) | |
89490 | 235 (characterp setup)) |
45296 | 236 (if (eq decimal 'numeric) |
237 (setq decimal nil)) | |
238 (vector (or decimal ?.) ?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9)) | |
239 ((eq setup 'prefix) | |
240 [?\M-- ?\M-0 ?\M-1 ?\M-2 ?\M-3 ?\M-4 | |
241 ?\M-5 ?\M-6 ?\M-7 ?\M-8 ?\M-9]) | |
242 ((eq setup 'cursor) | |
243 [delete insert end down next left | |
244 space right home up prior]) | |
245 ((eq setup 'S-cursor) | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47484
diff
changeset
|
246 [S-delete S-insert S-end S-down S-next S-left |
45296 | 247 S-space S-right S-home S-up S-prior]) |
248 ((eq setup 'none) | |
249 nil) | |
250 (t | |
251 (signal 'error (list "Unknown keypad setup: " setup)))))) | |
252 | |
253 (set var setup) | |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
254 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
255 ;; Bind the keys in KP list to BIND list in function-key-map. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
256 ;; If BIND is nil, all bindings for the keys are removed. |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
257 (if (not (boundp 'function-key-map)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
258 (setq function-key-map (make-sparse-keymap))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
259 |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
260 (while (< i 11) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
261 (define-key function-key-map (vector (aref kp i)) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
262 (if bind (vector (aref bind i)))) |
45953
66857c2230b6
Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents:
45296
diff
changeset
|
263 (if (= i 6) |
66857c2230b6
Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents:
45296
diff
changeset
|
264 (cond ((eq (aref kp i) 'kp-space) |
66857c2230b6
Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents:
45296
diff
changeset
|
265 (define-key function-key-map [kp-begin] |
66857c2230b6
Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents:
45296
diff
changeset
|
266 (if bind (vector (aref bind i))))) |
66857c2230b6
Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents:
45296
diff
changeset
|
267 ((eq (aref kp i) 'S-kp-space) |
66857c2230b6
Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents:
45296
diff
changeset
|
268 (define-key function-key-map [S-kp-begin] |
66857c2230b6
Handle kp-begin like kp-space.
Kim F. Storm <storm@cua.dk>
parents:
45296
diff
changeset
|
269 (if bind (vector (aref bind i))))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47484
diff
changeset
|
270 |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
271 (setq i (1+ i))))) |
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
272 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
91327
diff
changeset
|
273 ;; arch-tag: 0899d2bd-9e12-4b4e-9aef-d0014d3b6414 |
44938
358d42530d42
Added cua-mode based files [split from original cua.el]:
Kim F. Storm <storm@cua.dk>
parents:
diff
changeset
|
274 ;;; keypad.el ends here |