Mercurial > emacs
view 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 |
line wrap: on
line source
;;; keypad.el --- simplified keypad bindings ;; Copyright (C) 2002, 2003, 2004, 2005, 2006, ;; 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: Kim F. Storm <storm@cua.dk> ;; Keywords: keyboard convenience ;; This file is part of GNU Emacs. ;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. ;;; Commentary: ;; The keypad package allows easy binding of the keypad keys to ;; various commonly used sets of commands. ;; ;; With the following setup, the keypad can be used for numeric data ;; entry when NumLock is off, and to give numeric prefix arguments to ;; emacs commands, when NumLock on on. ;; ;; keypad-setup => Plain Numeric Keypad ;; keypad-numlock-setup => Prefix numeric args ;; ;; +--------+--------+--------+ ;; | M-7 | M-8 | M-9 | <- numlock on ;; | 7 | 8 | 9 | <- numlock off ;; +--------+--------+--------+ ;; | M-4 | M-5 | M-6 | ;; | 4 | 5 | 6 | ;; +--------+--------+--------+ ;; | M-1 | M-2 | M-3 | ;; | 1 | 2 | 3 | ;; +--------+--------+--------+ ;; | M-0 | M-- | ;; | 0 | . | ;; +-----------------+--------+ ;; The following keypad setup is used for navigation together with ;; modes like cua-mode which uses shifted movement keys to extend the ;; region. ;; ;; keypad-setup => Cursor keys ;; keypad-shifted-setup => Shifted cursor keys ;; ;; +--------+--------+--------+ ;; | S-home | S-up | S-PgUp | <- shifted, numlock off ;; | Home | up | PgUp | <- unshifted, numlock off ;; +--------+--------+--------+ ;; | S-left |S-space |S-right | ;; | left | space | right | ;; +--------+--------+--------+ ;; | S-end | S-down | S-PgDn | ;; | end | down | PgDn | ;; +--------+--------+--------+ ;; | S-insert |S-delete| ;; | insert | delete | ;; +-----------------+--------+ ;; The following setup binds the unshifted keypad keys to plain ;; numeric keys when NumLock is either on or off, but the decimal key ;; produces either a . (NumLock off) or a , (NumLock on). This is ;; useful for e.g. Danish users where the decimal separator is a ;; comma. ;; ;; keypad-setup => Plain Numeric Keypad ;; keypad-numlock-setup => Numeric Keypad with Decimal key: , ;; ;; +--------+--------+--------+ ;; | 7 | 8 | 9 | <- numlock on ;; | 7 | 8 | 9 | <- numlock off ;; +--------+--------+--------+ ;; | 4 | 5 | 6 | ;; | 4 | 5 | 6 | ;; +--------+--------+--------+ ;; | 1 | 2 | 3 | ;; | 1 | 2 | 3 | ;; +--------+--------+--------+ ;; | 0 | , | ;; | 0 | . | ;; +-----------------+--------+ ;;; Code: (provide 'keypad) ;;; Customization ;;;###autoload (defcustom keypad-setup nil "Specifies the keypad setup for unshifted keypad keys when NumLock is off. When selecting the plain numeric keypad setup, the character returned by the decimal key must be specified." :set (lambda (symbol value) (if value (keypad-setup value nil nil value))) :initialize 'custom-initialize-default :link '(emacs-commentary-link "keypad.el") :version "22.1" :type '(choice (const :tag "Plain numeric keypad" numeric) (character :tag "Numeric Keypad with Decimal Key" :match (lambda (widget value) (integerp value)) :value ?.) (const :tag "Numeric prefix arguments" prefix) (const :tag "Cursor keys" cursor) (const :tag "Shifted cursor keys" S-cursor) (const :tag "Unspecified/User-defined" none) (other :tag "Keep existing bindings" nil)) :require 'keypad :group 'keyboard) ;;;###autoload (defcustom keypad-numlock-setup nil "Specifies the keypad setup for unshifted keypad keys when NumLock is on. When selecting the plain numeric keypad setup, the character returned by the decimal key must be specified." :set (lambda (symbol value) (if value (keypad-setup value t nil value))) :initialize 'custom-initialize-default :link '(emacs-commentary-link "keypad.el") :version "22.1" :type '(choice (const :tag "Plain numeric keypad" numeric) (character :tag "Numeric Keypad with Decimal Key" :match (lambda (widget value) (integerp value)) :value ?.) (const :tag "Numeric prefix arguments" prefix) (const :tag "Cursor keys" cursor) (const :tag "Shifted cursor keys" S-cursor) (const :tag "Unspecified/User-defined" none) (other :tag "Keep existing bindings" nil)) :require 'keypad :group 'keyboard) ;;;###autoload (defcustom keypad-shifted-setup nil "Specifies the keypad setup for shifted keypad keys when NumLock is off. When selecting the plain numeric keypad setup, the character returned by the decimal key must be specified." :set (lambda (symbol value) (if value (keypad-setup value nil t value))) :initialize 'custom-initialize-default :link '(emacs-commentary-link "keypad.el") :version "22.1" :type '(choice (const :tag "Plain numeric keypad" numeric) (character :tag "Numeric Keypad with Decimal Key" :match (lambda (widget value) (integerp value)) :value ?.) (const :tag "Numeric prefix arguments" prefix) (const :tag "Cursor keys" cursor) (const :tag "Shifted cursor keys" S-cursor) (const :tag "Unspecified/User-defined" none) (other :tag "Keep existing bindings" nil)) :require 'keypad :group 'keyboard) ;;;###autoload (defcustom keypad-numlock-shifted-setup nil "Specifies the keypad setup for shifted keypad keys when NumLock is off. When selecting the plain numeric keypad setup, the character returned by the decimal key must be specified." :set (lambda (symbol value) (if value (keypad-setup value t t value))) :initialize 'custom-initialize-default :link '(emacs-commentary-link "keypad.el") :version "22.1" :type '(choice (const :tag "Plain numeric keypad" numeric) (character :tag "Numeric Keypad with Decimal Key" :match (lambda (widget value) (integerp value)) :value ?.) (const :tag "Numeric prefix arguments" prefix) (const :tag "Cursor keys" cursor) (const :tag "Shifted cursor keys" S-cursor) (const :tag "Unspecified/User-defined" none) (other :tag "Keep existing bindings" nil)) :require 'keypad :group 'keyboard) ;;;###autoload (defun keypad-setup (setup &optional numlock shift decimal) "Set keypad bindings in `function-key-map' according to SETUP. If optional second argument NUMLOCK is non-nil, the NumLock On bindings are changed. Otherwise, the NumLock Off bindings are changed. If optional third argument SHIFT is non-nil, the shifted keypad keys are bound. Setup Binding ------------------------------------------------------------- 'prefix Command prefix argument, i.e. M-0 .. M-9 and M-- 'S-cursor Bind shifted keypad keys to the shifted cursor movement keys. 'cursor Bind keypad keys to the cursor movement keys. 'numeric Plain numeric keypad, i.e. 0 .. 9 and . (or DECIMAL arg) 'none Removes all bindings for keypad keys in function-key-map; this enables any user-defined bindings for the keypad keys in the global and local keymaps. If SETUP is 'numeric and the optional fourth argument DECIMAL is non-nil, the decimal key on the keypad is mapped to DECIMAL instead of `.'" (let* ((i 0) (var (cond ((and (not numlock) (not shift)) 'keypad-setup) ((and (not numlock) shift) 'keypad-shifted-setup) ((and numlock (not shift)) 'keypad-numlock-setup) ((and numlock shift) 'keypad-numlock-shifted-setup))) (kp (cond ((eq var 'keypad-setup) [kp-delete kp-insert kp-end kp-down kp-next kp-left kp-space kp-right kp-home kp-up kp-prior]) ((eq var 'keypad-shifted-setup) [S-kp-decimal S-kp-0 S-kp-1 S-kp-2 S-kp-3 S-kp-4 S-kp-5 S-kp-6 S-kp-7 S-kp-8 S-kp-9]) ((eq var 'keypad-numlock-setup) [kp-decimal kp-0 kp-1 kp-2 kp-3 kp-4 kp-5 kp-6 kp-7 kp-8 kp-9]) ((eq var 'keypad-numlock-shifted-setup) [S-kp-delete S-kp-insert S-kp-end S-kp-down S-kp-next S-kp-left S-kp-space S-kp-right S-kp-home S-kp-up S-kp-prior]))) (bind (cond ((or (eq setup 'numeric) (characterp setup)) (if (eq decimal 'numeric) (setq decimal nil)) (vector (or decimal ?.) ?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9)) ((eq setup 'prefix) [?\M-- ?\M-0 ?\M-1 ?\M-2 ?\M-3 ?\M-4 ?\M-5 ?\M-6 ?\M-7 ?\M-8 ?\M-9]) ((eq setup 'cursor) [delete insert end down next left space right home up prior]) ((eq setup 'S-cursor) [S-delete S-insert S-end S-down S-next S-left S-space S-right S-home S-up S-prior]) ((eq setup 'none) nil) (t (signal 'error (list "Unknown keypad setup: " setup)))))) (set var setup) ;; Bind the keys in KP list to BIND list in function-key-map. ;; If BIND is nil, all bindings for the keys are removed. (if (not (boundp 'function-key-map)) (setq function-key-map (make-sparse-keymap))) (while (< i 11) (define-key function-key-map (vector (aref kp i)) (if bind (vector (aref bind i)))) (if (= i 6) (cond ((eq (aref kp i) 'kp-space) (define-key function-key-map [kp-begin] (if bind (vector (aref bind i))))) ((eq (aref kp i) 'S-kp-space) (define-key function-key-map [S-kp-begin] (if bind (vector (aref bind i))))))) (setq i (1+ i))))) ;; arch-tag: 0899d2bd-9e12-4b4e-9aef-d0014d3b6414 ;;; keypad.el ends here