annotate lisp/calc/calc-keypd.el @ 108778:6c819187f088

* image.el (image-animated-p): When delay between animated images is 0, set it to 10 (0.1 sec). (Bug#6258)
author Juri Linkov <juri@jurta.org>
date Tue, 25 May 2010 18:54:53 +0300
parents 1d1d5d9bd884
children 56b71cddc9c5 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
41265
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
1 ;;; calc-keypd.el --- mouse-capable keypad input for Calc
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
2
64325
1db49616ce05 Update copyright information.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 62442
diff changeset
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001, 2002, 2003, 2004,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105792
diff changeset
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
41265
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
5
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
6 ;; Author: David Gillespie <daveg@synaptics.com>
77465
1154f082efd9 Update maintainer's address.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 76595
diff changeset
7 ;; Maintainer: Jay Belanger <jay.p.belanger@gmail.com>
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
8
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
10
94654
6c9af2bfcfee 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
76595
497d17a80bb8 Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94654
6c9af2bfcfee 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
6c9af2bfcfee Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
14 ;; (at your option) any later version.
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
15
76595
497d17a80bb8 Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
497d17a80bb8 Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
497d17a80bb8 Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
497d17a80bb8 Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
19 ;; GNU General Public License for more details.
497d17a80bb8 Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
20
497d17a80bb8 Change form of license text to match rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94654
6c9af2bfcfee 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/>.
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
23
41265
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
24 ;;; Commentary:
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
25
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
26 ;;; Code:
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
27
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
28 ;; This file is autoloaded from calc-ext.el.
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
29
58660
4ad5e0d74a81 Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
30 (require 'calc-ext)
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
31 (require 'calc-macs)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
32
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
33 (defvar calc-keypad-buffer nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
34 (defvar calc-keypad-menu 0)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
35 (defvar calc-keypad-full-layout nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
36 (defvar calc-keypad-input nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
37 (defvar calc-keypad-prev-input nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
38 (defvar calc-keypad-said-hello nil)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
39
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
40 ;;; |----+----+----+----+----+----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
41 ;;; | ENTER |+/- |EEX |UNDO| <- |
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
42 ;;; |-----+---+-+--+--+-+---++----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
43 ;;; | INV | 7 | 8 | 9 | / |
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
44 ;;; |-----+-----+-----+-----+-----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
45 ;;; | HYP | 4 | 5 | 6 | * |
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
46 ;;; |-----+-----+-----+-----+-----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
47 ;;; |EXEC | 1 | 2 | 3 | - |
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
48 ;;; |-----+-----+-----+-----+-----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
49 ;;; | OFF | 0 | . | PI | + |
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
50 ;;; |-----+-----+-----+-----+-----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
51 (defvar calc-keypad-layout
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
52 '( ( ( "ENTER" calc-enter calc-roll-down calc-roll-up calc-over )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
53 ( "ENTER" calc-enter calc-roll-down calc-roll-up calc-over )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
54 ( "+/-" calc-change-sign calc-inv (progn -4 calc-pack) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
55 ( "EEX" ("e") (progn calc-num-prefix calc-pack-interval)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
56 (progn -5 calc-pack) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
57 ( "UNDO" calc-undo calc-redo calc-last-args )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
58 ( "<-" calc-pop (progn 0 calc-pop)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
59 (progn calc-num-prefix calc-pop) ) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
60 ( ( "INV" calc-inverse )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
61 ( "7" ("7") calc-round )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
62 ( "8" ("8") (progn 2 calc-clean-num) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
63 ( "9" ("9") calc-float )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
64 ( "/" calc-divide (progn calc-inverse calc-power) ) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
65 ( ( "HYP" calc-hyperbolic )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
66 ( "4" ("4") calc-ln calc-log10 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
67 ( "5" ("5") calc-exp calc-exp10 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
68 ( "6" ("6") calc-abs )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
69 ( "*" calc-times calc-power ) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
70 ( ( "EXEC" calc-keypad-execute )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
71 ( "1" ("1") calc-arcsin calc-sin )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
72 ( "2" ("2") calc-arccos calc-cos )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
73 ( "3" ("3") calc-arctan calc-tan )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
74 ( "-" calc-minus calc-conj ) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
75 ( ( "OFF" calc-keypad-off )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
76 ( "0" ("0") calc-imaginary )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
77 ( "." (".") calc-precision )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
78 ( "PI" calc-pi )
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40945
diff changeset
79 ( "+" calc-plus calc-sqrt ) ) ))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
80
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
81 (defvar calc-keypad-menus '( calc-keypad-math-menu
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
82 calc-keypad-funcs-menu
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
83 calc-keypad-binary-menu
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
84 calc-keypad-vector-menu
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
85 calc-keypad-modes-menu
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
86 calc-keypad-user-menu ) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
87
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
88 ;;; |----+----+----+----+----+----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
89 ;;; |FLR |CEIL|RND |TRNC|CLN2|FLT |
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
90 ;;; |----+----+----+----+----+----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
91 ;;; | LN |EXP | |ABS |IDIV|MOD |
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
92 ;;; |----+----+----+----+----+----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
93 ;;; |SIN |COS |TAN |SQRT|y^x |1/x |
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
94
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
95 (defvar calc-keypad-math-menu
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
96 '( ( ( "FLR" calc-floor )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
97 ( "CEIL" calc-ceiling )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
98 ( "RND" calc-round )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
99 ( "TRNC" calc-trunc )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
100 ( "CLN2" (progn 2 calc-clean-num) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
101 ( "FLT" calc-float ) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
102 ( ( "LN" calc-ln )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
103 ( "EXP" calc-exp )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
104 ( "" nil )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
105 ( "ABS" calc-abs )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
106 ( "IDIV" calc-idiv )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
107 ( "MOD" calc-mod ) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
108 ( ( "SIN" calc-sin )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
109 ( "COS" calc-cos )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
110 ( "TAN" calc-tan )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
111 ( "SQRT" calc-sqrt )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
112 ( "y^x" calc-power )
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40945
diff changeset
113 ( "1/x" calc-inv ) ) ))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
114
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
115 ;;; |----+----+----+----+----+----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
116 ;;; |IGAM|BETA|IBET|ERF |BESJ|BESY|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
117 ;;; |----+----+----+----+----+----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
118 ;;; |IMAG|CONJ| RE |ATN2|RAND|RAGN|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
119 ;;; |----+----+----+----+----+----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
120 ;;; |GCD |FACT|DFCT|BNOM|PERM|NXTP|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
121
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
122 (defvar calc-keypad-funcs-menu
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
123 '( ( ( "IGAM" calc-inc-gamma )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
124 ( "BETA" calc-beta )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
125 ( "IBET" calc-inc-beta )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
126 ( "ERF" calc-erf )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
127 ( "BESJ" calc-bessel-J )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
128 ( "BESY" calc-bessel-Y ) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
129 ( ( "IMAG" calc-imaginary )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
130 ( "CONJ" calc-conj )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
131 ( "RE" calc-re calc-im )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
132 ( "ATN2" calc-arctan2 )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
133 ( "RAND" calc-random )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
134 ( "RAGN" calc-random-again ) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
135 ( ( "GCD" calc-gcd calc-lcm )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
136 ( "FACT" calc-factorial calc-gamma )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
137 ( "DFCT" calc-double-factorial )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
138 ( "BNOM" calc-choose )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
139 ( "PERM" calc-perm )
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40945
diff changeset
140 ( "NXTP" calc-next-prime calc-prev-prime ) ) ))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
141
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
142 ;;; |----+----+----+----+----+----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
143 ;;; |AND | OR |XOR |NOT |LSH |RSH |
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
144 ;;; |----+----+----+----+----+----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
145 ;;; |DEC |HEX |OCT |BIN |WSIZ|ARSH|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
146 ;;; |----+----+----+----+----+----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
147 ;;; | A | B | C | D | E | F |
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
148
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
149 (defvar calc-keypad-binary-menu
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
150 '( ( ( "AND" calc-and calc-diff )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
151 ( "OR" calc-or )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
152 ( "XOR" calc-xor )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
153 ( "NOT" calc-not calc-clip )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
154 ( "LSH" calc-lshift-binary calc-rotate-binary )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
155 ( "RSH" calc-rshift-binary ) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
156 ( ( "DEC" calc-decimal-radix )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
157 ( "HEX" calc-hex-radix )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
158 ( "OCT" calc-octal-radix )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
159 ( "BIN" calc-binary-radix )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
160 ( "WSIZ" calc-word-size )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
161 ( "ARSH" calc-rshift-arith ) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
162 ( ( "A" ("A") )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
163 ( "B" ("B") )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
164 ( "C" ("C") )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
165 ( "D" ("D") )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
166 ( "E" ("E") )
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40945
diff changeset
167 ( "F" ("F") ) ) ))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
168
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
169 ;;; |----+----+----+----+----+----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
170 ;;; |SUM |PROD|MAX |MAP*|MAP^|MAP$|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
171 ;;; |----+----+----+----+----+----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
172 ;;; |INV |DET |TRN |IDNT|CRSS|"x" |
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
173 ;;; |----+----+----+----+----+----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
174 ;;; |PACK|UNPK|INDX|BLD |LEN |... |
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
175
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
176 (defvar calc-keypad-vector-menu
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
177 '( ( ( "SUM" calc-vector-sum calc-vector-alt-sum calc-vector-mean )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
178 ( "PROD" calc-vector-product nil calc-vector-sdev )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
179 ( "MAX" calc-vector-max calc-vector-min calc-vector-median )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
180 ( "MAP*" (lambda () (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
181 (calc-map '(2 calcFunc-mul "*"))) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
182 ( "MAP^" (lambda () (interactive)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
183 (calc-map '(2 calcFunc-pow "^"))) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
184 ( "MAP$" calc-map-stack ) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
185 ( ( "MINV" calc-inv )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
186 ( "MDET" calc-mdet )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
187 ( "MTRN" calc-transpose calc-conj-transpose )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
188 ( "IDNT" (progn calc-num-prefix calc-ident) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
189 ( "CRSS" calc-cross )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
190 ( "\"x\"" "\excalc-algebraic-entry\rx\r"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
191 "\excalc-algebraic-entry\ry\r"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
192 "\excalc-algebraic-entry\rz\r"
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
193 "\excalc-algebraic-entry\rt\r") )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
194 ( ( "PACK" calc-pack )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
195 ( "UNPK" calc-unpack )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
196 ( "INDX" (progn calc-num-prefix calc-index) "\C-u\excalc-index\r" )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
197 ( "BLD" (progn calc-num-prefix calc-build-vector) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
198 ( "LEN" calc-vlength )
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40945
diff changeset
199 ( "..." calc-full-vectors ) ) ))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
200
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
201 ;;; |----+----+----+----+----+----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
202 ;;; |FLT |FIX |SCI |ENG |GRP | |
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
203 ;;; |----+----+----+----+----+----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
204 ;;; |RAD |DEG |FRAC|POLR|SYMB|PREC|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
205 ;;; |----+----+----+----+----+----|
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
206 ;;; |SWAP|RLL3|RLL4|OVER|STO |RCL |
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
207
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
208 (defvar calc-keypad-modes-menu
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
209 '( ( ( "FLT" calc-normal-notation
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
210 (progn calc-num-prefix calc-normal-notation) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
211 ( "FIX" (progn 2 calc-fix-notation)
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
212 (progn calc-num-prefix calc-fix-notation) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
213 ( "SCI" calc-sci-notation
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
214 (progn calc-num-prefix calc-sci-notation) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
215 ( "ENG" calc-eng-notation
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
216 (progn calc-num-prefix calc-eng-notation) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
217 ( "GRP" calc-group-digits "\C-u-3\excalc-group-digits\r" )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
218 ( "" nil ) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
219 ( ( "RAD" calc-radians-mode )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
220 ( "DEG" calc-degrees-mode )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
221 ( "FRAC" calc-frac-mode )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
222 ( "POLR" calc-polar-mode )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
223 ( "SYMB" calc-symbolic-mode )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
224 ( "PREC" calc-precision ) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
225 ( ( "SWAP" calc-roll-down )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
226 ( "RLL3" (progn 3 calc-roll-up) (progn 3 calc-roll-down) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
227 ( "RLL4" (progn 4 calc-roll-up) (progn 4 calc-roll-down) )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
228 ( "OVER" calc-over )
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
229 ( "STO" calc-keypad-store )
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40945
diff changeset
230 ( "RCL" calc-keypad-recall ) ) ))
40785
2fb9d407ae73 Initial import of Calc 2.02f.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
231
41265
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
232 (define-derived-mode calc-keypad-mode fundamental-mode "Calculator"
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
233 "Major mode for Calc keypad input."
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
234 (define-key calc-keypad-mode-map " " 'calc-keypad-press)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
235 (define-key calc-keypad-mode-map (kbd "RET") 'calc-keypad-press)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
236 (define-key calc-keypad-mode-map (kbd "TAB") 'calc-keypad-menu)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
237 (define-key calc-keypad-mode-map "q" 'calc-keypad-off)
58854
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
238 (define-key calc-keypad-mode-map [down-mouse-1] 'ignore)
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
239 (define-key calc-keypad-mode-map [drag-mouse-1] 'ignore)
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
240 (define-key calc-keypad-mode-map [double-mouse-1] 'ignore)
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
241 (define-key calc-keypad-mode-map [triple-mouse-1] 'ignore)
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
242 (define-key calc-keypad-mode-map [down-mouse-2] 'ignore)
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
243 (define-key calc-keypad-mode-map [drag-mouse-2] 'ignore)
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
244 (define-key calc-keypad-mode-map [double-mouse-2] 'ignore)
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
245 (define-key calc-keypad-mode-map [triple-mouse-2] 'ignore)
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
246 (define-key calc-keypad-mode-map [down-mouse-3] 'ignore)
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
247 (define-key calc-keypad-mode-map [drag-mouse-3] 'ignore)
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
248 (define-key calc-keypad-mode-map [double-mouse-3] 'ignore)
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
249 (define-key calc-keypad-mode-map [triple-mouse-3] 'ignore)
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
250 (define-key calc-keypad-mode-map [mouse-3] 'calc-keypad-right-click)
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
251 (define-key calc-keypad-mode-map [mouse-2] 'calc-keypad-middle-click)
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
252 (define-key calc-keypad-mode-map [mouse-1] 'calc-keypad-left-click)
41265
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
253 (put 'calc-keypad-mode 'mode-class 'special)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
254 (make-local-variable 'calc-main-buffer))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
255
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
256 (defun calc-do-keypad (&optional full-display interactive)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
257 (calc-create-buffer)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
258 (let ((calcbuf (current-buffer)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
259 (unless (bufferp calc-keypad-buffer)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
260 (set-buffer (setq calc-keypad-buffer (get-buffer-create "*Calc Keypad*")))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
261 (calc-keypad-mode)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
262 (setq calc-main-buffer calcbuf)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
263 (calc-keypad-redraw)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
264 (calc-trail-buffer))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
265 (let ((width 29)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
266 (height 17)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
267 win old-win)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
268 (if (setq win (get-buffer-window "*Calculator*"))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
269 (delete-window win))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
270 (if (setq win (get-buffer-window "*Calc Trail*"))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
271 (if (one-window-p)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
272 (switch-to-buffer (other-buffer))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
273 (delete-window win)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
274 (if (setq win (get-buffer-window calc-keypad-buffer))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
275 (progn
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
276 (bury-buffer "*Calculator*")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
277 (bury-buffer "*Calc Trail*")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
278 (bury-buffer calc-keypad-buffer)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
279 (if (one-window-p)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
280 (switch-to-buffer (other-buffer))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
281 (delete-window win)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
282 (setq calc-was-keypad-mode t
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
283 old-win (get-largest-window))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
284 (if (or (< (window-height old-win) (+ height 6))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
285 (< (window-width old-win) (+ width 15))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
286 full-display)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
287 (delete-other-windows old-win))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
288 (if (< (window-height old-win) (+ height 4))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
289 (error "Screen is not tall enough for this mode"))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
290 (if full-display
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
291 (progn
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
292 (setq win (split-window old-win (- (window-height old-win)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
293 height 1)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
294 (set-window-buffer old-win (calc-trail-buffer))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
295 (set-window-buffer win calc-keypad-buffer)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
296 (set-window-start win 1)
65900
13cc64069e8c (calc-do-keypad): Widen keypad window for fullscreen keypad.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 64325
diff changeset
297 (setq win (split-window win (+ width 7) t))
41265
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
298 (set-window-buffer win calcbuf))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
299 (if (or t ; left-side keypad not yet fully implemented
105792
2c12fbae77c2 * calc/calc.el (calc, calc-refresh, calc-trail-buffer, calc-record)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101001
diff changeset
300 (< (with-current-buffer (window-buffer old-win)
41265
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
301 (current-column))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
302 (/ (window-width) 2)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
303 (setq win (split-window old-win (- (window-width old-win)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
304 width 2)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
305 t))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
306 (setq old-win (split-window old-win (+ width 2) t)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
307 (set-window-buffer win calc-keypad-buffer)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
308 (set-window-start win 1)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
309 (split-window win (- (window-height win) height 1))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
310 (set-window-buffer win calcbuf))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
311 (select-window old-win)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
312 (message "Welcome to GNU Emacs Calc! Use the left and right mouse buttons")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
313 (run-hooks 'calc-keypad-start-hook)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
314 (and calc-keypad-said-hello interactive
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
315 (progn
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
316 (sit-for 2)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
317 (message "")))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
318 (setq calc-keypad-said-hello t)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
319 (setq calc-keypad-input nil)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
320
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
321 (defun calc-keypad-off ()
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
322 (interactive)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
323 (if calc-standalone-flag
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
324 (save-buffers-kill-emacs nil)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
325 (calc-keypad)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
326
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
327 (defun calc-keypad-redraw ()
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
328 (set-buffer calc-keypad-buffer)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
329 (setq buffer-read-only t)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
330 (setq calc-keypad-full-layout (append (symbol-value (nth calc-keypad-menu
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
331 calc-keypad-menus))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
332 calc-keypad-layout))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
333 (let ((buffer-read-only nil)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
334 (row calc-keypad-full-layout)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
335 (y 0))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
336 (erase-buffer)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
337 (insert "\n")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
338 (while row
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
339 (let ((col (car row)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
340 (while col
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
341 (let* ((key (car col))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
342 (cwid (if (>= y 4)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
343 5
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
344 (if (and (= y 3) (eq col (car row)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
345 (progn (setq col (cdr col)) 9)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
346 4)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
347 (name (if (and calc-standalone-flag
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
348 (eq (nth 1 key) 'calc-keypad-off))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
349 "EXIT"
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
350 (if (> (length (car key)) cwid)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
351 (substring (car key) 0 cwid)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
352 (car key))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
353 (wid (length name))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
354 (pad (- cwid (/ wid 2))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
355 (insert (make-string (/ (- cwid wid) 2) 32)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
356 name
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
357 (make-string (/ (- cwid wid -1) 2) 32)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
358 (if (equal name "MENU")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
359 (int-to-string (1+ calc-keypad-menu))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
360 "|")))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
361 (or (setq col (cdr col))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
362 (insert "\n")))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
363 (insert (if (>= y 4)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
364 "-----+-----+-----+-----+-----"
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
365 (if (= y 3)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
366 "-----+---+-+--+--+-+---++----"
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
367 "----+----+----+----+----+----"))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
368 (if (= y 7) "+\n" "|\n"))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
369 (setq y (1+ y)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
370 row (cdr row)))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
371 (setq calc-keypad-prev-input t)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
372 (calc-keypad-show-input)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
373 (goto-char (point-min)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
374
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
375 (defun calc-keypad-show-input ()
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
376 (or (equal calc-keypad-input calc-keypad-prev-input)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
377 (let ((buffer-read-only nil))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
378 (save-excursion
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
379 (goto-char (point-min))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
380 (forward-line 1)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
381 (delete-region (point-min) (point))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
382 (if calc-keypad-input
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
383 (insert "Calc: " calc-keypad-input "\n")
97462
6ceebc15f462 (calc-keypad-show-input): Remove version number.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 94654
diff changeset
384 (insert "----+----+--Calc---+----+----"
41265
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
385 (int-to-string (1+ calc-keypad-menu))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
386 "\n")))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
387 (setq calc-keypad-prev-input calc-keypad-input))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
388
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
389 (defun calc-keypad-press ()
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
390 (interactive)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
391 (unless (eq major-mode 'calc-keypad-mode)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
392 (error "Must be in *Calc Keypad* buffer for this command"))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
393 (let* ((row (save-excursion
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
394 (beginning-of-line)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
395 (count-lines (point-min) (point))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
396 (y (/ row 2))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
397 (x (/ (current-column) (if (>= y 4) 6 5)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
398 radix frac inv
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
399 (hyp (with-current-buffer calc-main-buffer
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
400 (setq radix calc-number-radix
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
401 frac calc-prefer-frac
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
402 inv calc-inverse-flag)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
403 calc-hyperbolic-flag))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
404 (invhyp t)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
405 (menu (symbol-value (nth calc-keypad-menu calc-keypad-menus)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
406 (input calc-keypad-input)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
407 (iexpon (and input
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
408 (or (string-match "\\*[0-9]+\\.\\^" input)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
409 (and (<= radix 14) (string-match "e" input)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
410 (match-end 0)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
411 (key (nth x (nth y calc-keypad-full-layout)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
412 (cmd (or (nth (if inv (if hyp 4 2) (if hyp 3 99)) key)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
413 (setq invhyp nil)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
414 (nth 1 key)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
415 (isstring (and (consp cmd) (stringp (car cmd))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
416 (calc-is-keypad-press t))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
417 (if invhyp (calc-wrapper)) ; clear Inv and Hyp flags
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
418 (unwind-protect
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
419 (cond ((or (null cmd)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
420 (= (% row 2) 0))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
421 (beep))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
422 ((and (> (minibuffer-depth) 0))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
423 (cond (isstring
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
424 (push (aref (car cmd) 0) unread-command-events))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
425 ((eq cmd 'calc-pop)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
426 (push ?\177 unread-command-events))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
427 ((eq cmd 'calc-enter)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
428 (push 13 unread-command-events))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
429 ((eq cmd 'calc-undo)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
430 (push 7 unread-command-events))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
431 (t
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
432 (beep))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
433 ((and input (string-match "STO\\|RCL" input))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
434 (cond ((and isstring (string-match "[0-9]" (car cmd)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
435 (setq calc-keypad-input nil)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
436 (let ((var (intern (concat "var-q" (car cmd)))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
437 (cond ((equal input "STO+") (calc-store-plus var))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
438 ((equal input "STO-") (calc-store-minus var))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
439 ((equal input "STO*") (calc-store-times var))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
440 ((equal input "STO/") (calc-store-div var))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
441 ((equal input "STO^") (calc-store-power var))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
442 ((equal input "STOn") (calc-store-neg 1 var))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
443 ((equal input "STO&") (calc-store-inv 1 var))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
444 ((equal input "STO") (calc-store-into var))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
445 (t (calc-recall var)))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
446 ((memq cmd '(calc-pop calc-undo))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
447 (setq calc-keypad-input nil))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
448 ((and (equal input "STO")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
449 (setq frac (assq cmd '( ( calc-plus . "+" )
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
450 ( calc-minus . "-" )
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
451 ( calc-times . "*" )
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
452 ( calc-divide . "/" )
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
453 ( calc-power . "^")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
454 ( calc-change-sign . "n")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
455 ( calc-inv . "&") ))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
456 (setq calc-keypad-input (concat input (cdr frac))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
457 (t
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
458 (beep))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
459 (isstring
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
460 (setq cmd (car cmd))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
461 (if (or (and (equal cmd ".")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
462 input
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
463 (string-match "[.:e^]" input))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
464 (and (equal cmd "e")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
465 input
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
466 (or (and (<= radix 14) (string-match "e" input))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
467 (string-match "\\^\\|[-.:]\\'" input)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
468 (and (not (equal cmd "."))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
469 (let ((case-fold-search nil))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
470 (string-match cmd "0123456789ABCDEF"
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
471 (if (string-match
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
472 "[e^]" (or input ""))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
473 10 radix)))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
474 (beep)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
475 (setq calc-keypad-input (concat
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
476 (and (/= radix 10)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
477 (or (not input)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
478 (equal input "-"))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
479 (format "%d#" radix))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
480 (and (or (not input)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
481 (equal input "-"))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
482 (or (and (equal cmd "e") "1")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
483 (and (equal cmd ".")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
484 (if frac "1" "0"))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
485 input
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
486 (if (and (equal cmd ".") frac)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
487 ":"
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
488 (if (and (equal cmd "e")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
489 (or (not input)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
490 (string-match
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
491 "#" input))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
492 (> radix 14))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
493 (format "*%d.^" radix)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
494 cmd))))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
495 ((and (eq cmd 'calc-change-sign)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
496 input)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
497 (let* ((epos (or iexpon 0))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
498 (suffix (substring input epos)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
499 (setq calc-keypad-input (concat
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
500 (substring input 0 epos)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
501 (if (string-match "\\`-" suffix)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
502 (substring suffix 1)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
503 (concat "-" suffix))))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
504 ((and (eq cmd 'calc-pop)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
505 input)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
506 (if (equal input "")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
507 (beep)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
508 (setq calc-keypad-input (substring input 0
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
509 (or (string-match
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
510 "\\*[0-9]+\\.\\^\\'"
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
511 input)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
512 -1)))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
513 ((and (eq cmd 'calc-undo)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
514 input)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
515 (setq calc-keypad-input nil))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
516 (t
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
517 (if input
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
518 (let ((val (math-read-number input)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
519 (setq calc-keypad-input nil)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
520 (if val
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
521 (calc-wrapper
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
522 (calc-push-list (list (calc-record
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
523 (calc-normalize val)))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
524 (or (equal input "")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
525 (beep))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
526 (setq cmd nil))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
527 (if (eq cmd 'calc-enter) (setq cmd nil))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
528 (setq prefix-arg current-prefix-arg)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
529 (if cmd
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
530 (if (and (consp cmd) (eq (car cmd) 'progn))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
531 (while (setq cmd (cdr cmd))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
532 (if (integerp (car cmd))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
533 (setq prefix-arg (car cmd))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
534 (command-execute (car cmd))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
535 (command-execute cmd)))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
536 (set-buffer calc-keypad-buffer)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
537 (calc-keypad-show-input))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
538
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
539 (defun calc-keypad-left-click (event)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
540 "Handle a left-button mouse click in Calc Keypad window."
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
541 (interactive "e")
58854
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
542 (with-current-buffer calc-keypad-buffer
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
543 (goto-char (posn-point (event-start event)))
44ab2f75bc0f (calc-keypad-mode): Unbind unused mouse events.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 58660
diff changeset
544 (calc-keypad-press)))
41265
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
545
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
546 (defun calc-keypad-right-click (event)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
547 "Handle a right-button mouse click in Calc Keypad window."
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
548 (interactive "e")
105792
2c12fbae77c2 * calc/calc.el (calc, calc-refresh, calc-trail-buffer, calc-record)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101001
diff changeset
549 (with-current-buffer calc-keypad-buffer
41265
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
550 (calc-keypad-menu)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
551
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
552 (defun calc-keypad-middle-click (event)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
553 "Handle a middle-button mouse click in Calc Keypad window."
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
554 (interactive "e")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
555 (with-current-buffer calc-keypad-buffer
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
556 (calc-keypad-menu-back)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
557
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
558 (defun calc-keypad-menu ()
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
559 (interactive)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
560 (unless (eq major-mode 'calc-keypad-mode)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
561 (error "Must be in *Calc Keypad* buffer for this command"))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
562 (while (progn (setq calc-keypad-menu (% (1+ calc-keypad-menu)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
563 (length calc-keypad-menus)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
564 (not (symbol-value (nth calc-keypad-menu calc-keypad-menus)))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
565 (calc-keypad-redraw))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
566
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
567 (defun calc-keypad-menu-back ()
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
568 (interactive)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
569 (or (eq major-mode 'calc-keypad-mode)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
570 (error "Must be in *Calc Keypad* buffer for this command"))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
571 (while (progn (setq calc-keypad-menu (% (1- (+ calc-keypad-menu
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
572 (length calc-keypad-menus)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
573 (length calc-keypad-menus)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
574 (not (symbol-value (nth calc-keypad-menu calc-keypad-menus)))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
575 (calc-keypad-redraw))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
576
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
577 (defun calc-keypad-store ()
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
578 (interactive)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
579 (setq calc-keypad-input "STO"))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
580
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
581 (defun calc-keypad-recall ()
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
582 (interactive)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
583 (setq calc-keypad-input "RCL"))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
584
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
585 (defun calc-pack-interval (mode)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
586 (interactive "p")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
587 (if (or (< mode 0) (> mode 3))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
588 (error "Open/close code should be in the range from 0 to 3"))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
589 (calc-pack (- -6 mode)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
590
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
591 (defun calc-keypad-execute ()
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
592 (interactive)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
593 (let* ((prompt "Calc keystrokes: ")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
594 (flush 'x-flush-mouse-queue)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
595 (prefix nil)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
596 keys cmd)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
597 (save-excursion
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
598 (calc-select-buffer)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
599 (while (progn
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
600 (setq keys (read-key-sequence prompt))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
601 (setq cmd (key-binding keys))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
602 (if (or (memq cmd '(calc-inverse
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
603 calc-hyperbolic
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
604 universal-argument
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
605 digit-argument
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
606 negative-argument))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
607 (and prefix (string-match "\\`\e?[-0-9]\\'" keys)))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
608 (progn
101001
14b421290b2f Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
609 (setq last-command-event (aref keys (1- (length keys))))
41265
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
610 (command-execute cmd)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
611 (setq flush 'not-any-more
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
612 prefix t
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
613 prompt (concat prompt (key-description keys) " ")))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
614 (eq cmd flush))))) ; skip mouse-up event
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
615 (message "")
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
616 (if (commandp cmd)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
617 (command-execute cmd)
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
618 (error "Not a Calc command: %s" (key-description keys)))))
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
619
58660
4ad5e0d74a81 Add a provide statement.
Jay Belanger <jay.p.belanger@gmail.com>
parents: 52401
diff changeset
620 (provide 'calc-keypd)
41265
eb26445485bc (calc-keypad-mode): New.
Colin Walters <walters@gnu.org>
parents: 41047
diff changeset
621
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 79702
diff changeset
622 ;; arch-tag: 4ba0d360-2bb6-40b8-adfa-eb373765b3f9
41047
73f364fd8aaa Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents: 40945
diff changeset
623 ;;; calc-keypd.el ends here