Mercurial > emacs
annotate lisp/calc/calc-incom.el @ 58638:67bea14002c3
(encode_terminal_buf, encode_terminal_bufsize): New
variables.
(encode_terminal_code): Argument changed. Encode all
characters at once, and return a pointer to the result of
encoding.
(write_glyphs): Decide coding here. Adjusted for the above
change.
(insert_glyphs): Likewise.
(term_init): Initialize encode_terminal_bufsize to 0.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Tue, 30 Nov 2004 08:19:32 +0000 |
parents | 938592e66a8e |
children | 324e147417aa |
rev | line source |
---|---|
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
1 ;;; calc-incom.el --- complex data type input functions for Calc |
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
2 |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
4 |
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
5 ;; Author: David Gillespie <daveg@synaptics.com> |
58550
938592e66a8e
(calc-prev-char, calc-prev-prev-char, calc-digit-value): Declare them.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57691
diff
changeset
|
6 ;; Maintainer: Jay Belanger <belanger@truman.edu> |
40785 | 7 |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is distributed in the hope that it will be useful, | |
11 ;; but WITHOUT ANY WARRANTY. No author or distributor | |
12 ;; accepts responsibility to anyone for the consequences of using it | |
13 ;; or for whether it serves any particular purpose or works at all, | |
14 ;; unless he says so in writing. Refer to the GNU Emacs General Public | |
15 ;; License for full details. | |
16 | |
17 ;; Everyone is granted permission to copy, modify and redistribute | |
18 ;; GNU Emacs, but only under the conditions described in the | |
19 ;; GNU Emacs General Public License. A copy of this license is | |
20 ;; supposed to have been given to you along with GNU Emacs so you | |
21 ;; can know your rights and responsibilities. It should be in a | |
22 ;; file named COPYING. Among other things, the copyright notice | |
23 ;; and this notice must be preserved on all copies. | |
24 | |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
25 ;;; Commentary: |
40785 | 26 |
41271
fcd507927105
Change all toplevel `setq' forms to `defvar' forms, and move them
Colin Walters <walters@gnu.org>
parents:
41047
diff
changeset
|
27 ;;; Code: |
40785 | 28 |
29 ;; This file is autoloaded from calc-ext.el. | |
30 (require 'calc-ext) | |
31 | |
32 (require 'calc-macs) | |
33 | |
34 (defun calc-Need-calc-incom () nil) | |
35 | |
36 | |
37 ;;; Incomplete forms. | |
38 | |
39 (defun calc-begin-complex () | |
40 (interactive) | |
41 (calc-wrapper | |
42 (if (or calc-algebraic-mode calc-incomplete-algebraic-mode) | |
43 (calc-alg-entry "(") | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
44 (calc-push (list 'incomplete calc-complex-mode))))) |
40785 | 45 |
46 (defun calc-end-complex () | |
47 (interactive) | |
48 (calc-comma t) | |
49 (calc-wrapper | |
50 (let ((top (calc-top 1))) | |
51 (if (and (eq (car-safe top) 'incomplete) | |
52 (eq (nth 1 top) 'intv)) | |
53 (progn | |
54 (if (< (length top) 4) | |
55 (setq top (append top '((neg (var inf var-inf)))))) | |
56 (if (< (length top) 5) | |
57 (setq top (append top '((var inf var-inf))))) | |
58 (calc-enter-result 1 "..)" (cdr top))) | |
59 (if (not (and (eq (car-safe top) 'incomplete) | |
60 (memq (nth 1 top) '(cplx polar)))) | |
61 (error "Not entering a complex number")) | |
62 (while (< (length top) 4) | |
63 (setq top (append top '(0)))) | |
64 (if (not (and (math-realp (nth 2 top)) | |
65 (math-anglep (nth 3 top)))) | |
66 (error "Components must be real")) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
67 (calc-enter-result 1 "()" (cdr top)))))) |
40785 | 68 |
69 (defun calc-begin-vector () | |
70 (interactive) | |
71 (calc-wrapper | |
72 (if (or calc-algebraic-mode calc-incomplete-algebraic-mode) | |
73 (calc-alg-entry "[") | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
74 (calc-push '(incomplete vec))))) |
40785 | 75 |
76 (defun calc-end-vector () | |
77 (interactive) | |
78 (calc-comma t) | |
79 (calc-wrapper | |
80 (let ((top (calc-top 1))) | |
81 (if (and (eq (car-safe top) 'incomplete) | |
82 (eq (nth 1 top) 'intv)) | |
83 (progn | |
84 (if (< (length top) 4) | |
85 (setq top (append top '((neg (var inf var-inf)))))) | |
86 (if (< (length top) 5) | |
87 (setq top (append top '((var inf var-inf))))) | |
88 (setcar (cdr (cdr top)) (1+ (nth 2 top))) | |
89 (calc-enter-result 1 "..]" (cdr top))) | |
90 (if (not (and (eq (car-safe top) 'incomplete) | |
91 (eq (nth 1 top) 'vec))) | |
92 (error "Not entering a vector")) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
93 (calc-pop-push-record 1 "[]" (cdr top)))))) |
40785 | 94 |
95 (defun calc-comma (&optional allow-polar) | |
96 (interactive) | |
97 (calc-wrapper | |
98 (let ((num (calc-find-first-incomplete | |
99 (nthcdr calc-stack-top calc-stack) 1))) | |
100 (if (= num 0) | |
101 (error "Not entering a vector or complex number")) | |
102 (let* ((inc (calc-top num)) | |
103 (stuff (calc-top-list (1- num))) | |
104 (new (append inc stuff))) | |
105 (if (and (null stuff) | |
106 (not allow-polar) | |
107 (or (eq (nth 1 inc) 'vec) | |
108 (< (length new) 4))) | |
109 (setq new (append new | |
110 (if (= (length new) 2) | |
111 '(0) | |
112 (nthcdr (1- (length new)) new))))) | |
113 (or allow-polar | |
114 (if (eq (nth 1 new) 'polar) | |
115 (setq new (append '(incomplete cplx) (cdr (cdr new)))) | |
116 (if (eq (nth 1 new) 'intv) | |
117 (setq new (append '(incomplete cplx) | |
118 (cdr (cdr (cdr new)))))))) | |
119 (if (and (memq (nth 1 new) '(cplx polar)) | |
120 (> (length new) 4)) | |
121 (error "Too many components in complex number")) | |
122 (if (and (eq (nth 1 new) 'intv) | |
123 (> (length new) 5)) | |
124 (error "Too many components in interval form")) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
125 (calc-pop-push num new))))) |
40785 | 126 |
127 (defun calc-semi () | |
128 (interactive) | |
129 (calc-wrapper | |
130 (let ((num (calc-find-first-incomplete | |
131 (nthcdr calc-stack-top calc-stack) 1))) | |
132 (if (= num 0) | |
133 (error "Not entering a vector or complex number")) | |
134 (let ((inc (calc-top num)) | |
135 (stuff (calc-top-list (1- num)))) | |
136 (if (eq (nth 1 inc) 'cplx) | |
137 (setq inc (append '(incomplete polar) (cdr (cdr inc)))) | |
138 (if (eq (nth 1 inc) 'intv) | |
139 (setq inc (append '(incomplete polar) (cdr (cdr (cdr inc))))))) | |
140 (cond ((eq (nth 1 inc) 'polar) | |
141 (let ((new (append inc stuff))) | |
142 (if (> (length new) 4) | |
143 (error "Too many components in complex number") | |
144 (if (= (length new) 2) | |
145 (setq new (append new '(1))))) | |
146 (calc-pop-push num new))) | |
147 ((null stuff) | |
148 (if (> (length inc) 2) | |
149 (if (math-vectorp (nth 2 inc)) | |
150 (calc-comma) | |
151 (calc-pop-push 1 | |
152 (list 'incomplete 'vec (cdr (cdr inc))) | |
153 (list 'incomplete 'vec))))) | |
154 ((math-vectorp (car stuff)) | |
155 (calc-comma)) | |
156 ((eq (car-safe (car-safe (nth (+ num calc-stack-top) | |
157 calc-stack))) 'incomplete) | |
158 (calc-end-vector) | |
159 (calc-comma) | |
160 (let ((calc-algebraic-mode nil) | |
161 (calc-incomplete-algebraic-mode nil)) | |
162 (calc-begin-vector))) | |
163 ((or (= (length inc) 2) | |
164 (math-vectorp (nth 2 inc))) | |
165 (calc-pop-push num | |
166 (append inc (list (cons 'vec stuff))) | |
167 (list 'incomplete 'vec))) | |
168 (t | |
169 (calc-pop-push num | |
170 (list 'incomplete 'vec | |
171 (cons 'vec (append (cdr (cdr inc)) stuff))) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
172 (list 'incomplete 'vec)))))))) |
40785 | 173 |
58550
938592e66a8e
(calc-prev-char, calc-prev-prev-char, calc-digit-value): Declare them.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57691
diff
changeset
|
174 ;; The following variables are initially declared in calc.el, |
938592e66a8e
(calc-prev-char, calc-prev-prev-char, calc-digit-value): Declare them.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57691
diff
changeset
|
175 ;; but are used by calc-digit-dots. |
938592e66a8e
(calc-prev-char, calc-prev-prev-char, calc-digit-value): Declare them.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57691
diff
changeset
|
176 (defvar calc-prev-char) |
938592e66a8e
(calc-prev-char, calc-prev-prev-char, calc-digit-value): Declare them.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57691
diff
changeset
|
177 (defvar calc-prev-prev-char) |
938592e66a8e
(calc-prev-char, calc-prev-prev-char, calc-digit-value): Declare them.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57691
diff
changeset
|
178 (defvar calc-digit-value) |
938592e66a8e
(calc-prev-char, calc-prev-prev-char, calc-digit-value): Declare them.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
57691
diff
changeset
|
179 |
40785 | 180 (defun calc-digit-dots () |
181 (if (eq calc-prev-char ?.) | |
182 (progn | |
183 (delete-backward-char 1) | |
184 (if (calc-minibuffer-contains ".*\\.\\'") | |
185 (delete-backward-char 1)) | |
186 (setq calc-prev-char 'dots | |
187 last-command-char 32) | |
188 (if calc-prev-prev-char | |
189 (calcDigit-nondigit) | |
190 (setq calc-digit-value nil) | |
57691
8dc3dd828d67
(calc-digit-dots): Inhibit read-only before erasing minibuffer.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
191 (let ((inhibit-read-only t)) |
8dc3dd828d67
(calc-digit-dots): Inhibit read-only before erasing minibuffer.
Jay Belanger <jay.p.belanger@gmail.com>
parents:
52401
diff
changeset
|
192 (erase-buffer)) |
40785 | 193 (exit-minibuffer))) |
194 ;; just ignore extra decimal point, anticipating ".." | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
195 (delete-backward-char 1))) |
40785 | 196 |
197 (defun calc-dots () | |
198 (interactive) | |
199 (calc-wrapper | |
200 (let ((num (calc-find-first-incomplete | |
201 (nthcdr calc-stack-top calc-stack) 1))) | |
202 (if (= num 0) | |
203 (error "Not entering an interval form")) | |
204 (let* ((inc (calc-top num)) | |
205 (stuff (calc-top-list (1- num))) | |
206 (new (append inc stuff))) | |
207 (if (not (eq (nth 1 new) 'intv)) | |
208 (setq new (append '(incomplete intv) | |
209 (if (eq (nth 1 new) 'vec) '(2) '(0)) | |
210 (cdr (cdr new))))) | |
211 (if (and (null stuff) | |
212 (= (length new) 3)) | |
213 (setq new (append new '((neg (var inf var-inf)))))) | |
214 (if (> (length new) 5) | |
215 (error "Too many components in interval form")) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
216 (calc-pop-push num new))))) |
40785 | 217 |
218 (defun calc-find-first-incomplete (stack n) | |
219 (cond ((null stack) | |
220 0) | |
221 ((eq (car-safe (car-safe (car stack))) 'incomplete) | |
222 n) | |
223 (t | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
224 (calc-find-first-incomplete (cdr stack) (1+ n))))) |
40785 | 225 |
226 (defun calc-incomplete-error (a) | |
227 (cond ((memq (nth 1 a) '(cplx polar)) | |
228 (error "Complex number is incomplete")) | |
229 ((eq (nth 1 a) 'vec) | |
230 (error "Vector is incomplete")) | |
231 ((eq (nth 1 a) 'intv) | |
232 (error "Interval form is incomplete")) | |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
233 (t (error "Object is incomplete")))) |
40785 | 234 |
52401 | 235 ;;; arch-tag: b8001270-4dc7-481b-a3e3-a952e19b390d |
41047
73f364fd8aaa
Style cleanup; don't put closing parens on their
Colin Walters <walters@gnu.org>
parents:
40785
diff
changeset
|
236 ;;; calc-incom.el ends here |