Mercurial > hg > xemacs-beta
annotate lisp/term/sup-mouse.el @ 5327:d1b17a33450b
Move the heavy lifting from cl-seq.el to C.
src/ChangeLog addition:
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
Move the heavy lifting from cl-seq.el to C, finally making those
functions first-class XEmacs citizens, with circularity checking,
built-in support for tests other than #'eql, and as much
compatibility with current Common Lisp as Paul Dietz' tests require.
* fns.c (check_eq_nokey, check_eq_key, check_eql_nokey)
(check_eql_key, check_equal_nokey, check_equal_key)
(check_equalp_nokey, check_equalp_key, check_string_match_nokey)
(check_string_match_key, check_other_nokey, check_other_key)
(check_if_nokey, check_if_key, check_match_eq_key)
(check_match_eql_key, check_match_equal_key)
(check_match_equalp_key, check_match_other_key): New. These are
basically to provide function pointers to be used by Lisp
functions that take TEST, TEST-NOT and KEY arguments.
(get_check_match_function_1, get_check_test_function)
(get_check_match_function): These functions work out which of the
previous list of functions to use, given the keywords supplied by
the user.
(count_with_tail): New. This is the bones of #'count.
(list_count_from_end, string_count_from_end): Utility functions
for #'count.
(Fcount): New, moved from cl-seq.el.
(list_position_cons_before): New. The implementation of #'member*,
and important in implementing various other functions.
(FmemberX, Fadjoin, FassocX, FrassocX, Fposition, Ffind)
(FdeleteX, FremoveX, Fdelete_duplicates, Fremove_duplicates)
(Fnsubstitute, Fsubstitute, Fsublis, Fnsublis, Fsubst, Fnsubst)
(Ftree_equal, Fmismatch, Fsearch, Fintersection, Fnintersection)
(Fsubsetp, Fset_difference, Fnset_difference, Fnunion, Funion)
(Fset_exclusive_or, Fnset_exclusive_or): New, moved here from
cl-seq.el.
(position): New. The implementation of #'find and #'position.
(list_delete_duplicates_from_end, subst, sublis, nsublis)
(tree_equal, mismatch_from_end, mismatch_list_list)
(mismatch_list_string, mismatch_list_array)
(mismatch_string_array, mismatch_string_string)
(mismatch_array_array, get_mismatch_func): Helper C functions for
the Lisp-visible functions.
(venn, nvenn): New. The implementation of the main Lisp functions that
treat lists as sets.
lisp/ChangeLog addition:
2010-12-30 Aidan Kehoe <kehoea@parhasard.net>
* cl-seq.el:
Move the heavy lifting from this file to C. Dump the
cl-parsing-keywords macro, but don't use defun* for the functions
we define that do take keywords, dynamic scope lossage makes that
not practical.
* subr.el (sort, fillarray): Move these aliases here.
(map-plist): #'nsublis is now built-in, but at this point #'eql
isn't necessarily available as a test; use #'eq.
* obsolete.el (cl-delete-duplicates): Make this available for old
compiler macros and old code.
(memql): Document that this is equivalent to #'member*, and worse.
* cl.el (adjoin, subst): Removed. These are in C.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Thu, 30 Dec 2010 01:59:52 +0000 |
parents | 85bd42a1e544 |
children | b9167d522a9a |
rev | line source |
---|---|
0 | 1 ;;; sup-mouse.el --- supdup mouse support for lisp machines |
2 | |
5291
85bd42a1e544
More permission consistency.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
772
diff
changeset
|
3 ;; Copyright (C) 1985, 1986 Free Software Foundation |
0 | 4 |
5 ;; Author: Wolfgang Rupprecht | |
6 ;; Maintainer: FSF | |
7 ;; Created: 21 Nov 1986 | |
8 ;; Keywords: hardware | |
9 | |
10 ;; (from code originally written by John Robinson@bbn for the bitgraph) | |
11 | |
5291
85bd42a1e544
More permission consistency.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
772
diff
changeset
|
12 ;; This file is part of XEmacs. |
0 | 13 |
5291
85bd42a1e544
More permission consistency.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
772
diff
changeset
|
14 ;; XEmacs is free software; you can redistribute it and/or modify |
0 | 15 ;; it under the terms of the GNU General Public License as published by |
16 ;; the Free Software Foundation; either version 2, or (at your option) | |
17 ;; any later version. | |
18 | |
5291
85bd42a1e544
More permission consistency.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
772
diff
changeset
|
19 ;; XEmacs is distributed in the hope that it will be useful, |
0 | 20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 ;; GNU General Public License for more details. | |
23 | |
24 ;; You should have received a copy of the GNU General Public License | |
5291
85bd42a1e544
More permission consistency.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
772
diff
changeset
|
25 ;; along with XEmacs; see the file COPYING. If not, write to |
0 | 26 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
27 | |
28 ;;; Code: | |
29 | |
30 ;;; User customization option: | |
31 | |
32 (defvar sup-mouse-fast-select-window nil | |
33 "*Non-nil for mouse hits to select new window, then execute; else just select.") | |
34 | |
35 (defconst mouse-left 0) | |
36 (defconst mouse-center 1) | |
37 (defconst mouse-right 2) | |
38 | |
39 (defconst mouse-2left 4) | |
40 (defconst mouse-2center 5) | |
41 (defconst mouse-2right 6) | |
42 | |
43 (defconst mouse-3left 8) | |
44 (defconst mouse-3center 9) | |
45 (defconst mouse-3right 10) | |
46 | |
47 ;;; Defuns: | |
48 | |
772 | 49 (defun sup-window-edges (&optional win) |
50 (error "not implemented") | |
51 (window-pixel-edges win)) | |
52 | |
0 | 53 (defun sup-mouse-report () |
54 "This function is called directly by the mouse, it parses and | |
55 executes the mouse commands. | |
56 | |
57 L move point * |---- These apply for mouse click in a window. | |
58 2L delete word | | |
59 3L copy word | If sup-mouse-fast-select-window is nil, | |
60 C move point and yank * | just selects that window. | |
61 2C yank pop | | |
62 R set mark * | | |
63 2R delete region | | |
64 3R copy region | | |
65 | |
66 on modeline on \"scroll bar\" in minibuffer | |
67 L scroll-up line to top execute-extended-command | |
68 C proportional goto-char line to middle mouse-help | |
69 R scroll-down line to bottom eval-expression" | |
70 | |
71 (interactive) | |
72 (let* | |
73 ;; expect a string of <esc>:<buttons>;<x-pos>;<y-pos>c | |
74 ((buttons (sup-get-tty-num ?\;)) | |
75 (x (sup-get-tty-num ?\;)) | |
76 (y (sup-get-tty-num ?c)) | |
77 (window (sup-pos-to-window x y)) | |
772 | 78 (edges (sup-window-edges window)) |
0 | 79 (old-window (selected-window)) |
80 (in-minibuf-p (eq y (1- (frame-height)))) | |
81 (same-window-p (and (not in-minibuf-p) (eq window old-window))) | |
82 (in-modeline-p (eq y (1- (nth 3 edges)))) | |
83 (in-scrollbar-p (>= x (1- (nth 2 edges))))) | |
84 (setq x (- x (nth 0 edges))) | |
85 (setq y (- y (nth 1 edges))) | |
86 | |
87 ; (error "mouse-hit %d %d %d" buttons x y) ;;;; debug | |
88 | |
89 (cond (in-modeline-p | |
90 (select-window window) | |
91 (cond ((= buttons mouse-left) | |
92 (scroll-up)) | |
93 ((= buttons mouse-right) | |
94 (scroll-down)) | |
95 ((= buttons mouse-center) | |
96 (goto-char (/ (* x | |
97 (- (point-max) (point-min))) | |
98 (1- (window-width)))) | |
99 (beginning-of-line) | |
100 (what-cursor-position))) | |
101 (select-window old-window)) | |
102 (in-scrollbar-p | |
103 (select-window window) | |
104 (scroll-up | |
105 (cond ((= buttons mouse-left) | |
106 y) | |
107 ((= buttons mouse-right) | |
108 (+ y (- 2 (window-height)))) | |
109 ((= buttons mouse-center) | |
110 (/ (+ 2 y y (- (window-height))) 2)) | |
111 (t | |
112 0))) | |
113 (select-window old-window)) | |
114 (same-window-p | |
115 (cond ((= buttons mouse-left) | |
116 (sup-move-point-to-x-y x y)) | |
117 ((= buttons mouse-2left) | |
118 (sup-move-point-to-x-y x y) | |
119 (kill-word 1)) | |
120 ((= buttons mouse-3left) | |
121 (sup-move-point-to-x-y x y) | |
122 (save-excursion | |
123 (copy-region-as-kill | |
124 (point) (progn (forward-word 1) (point)))) | |
125 (setq this-command 'yank) | |
126 ) | |
127 ((= buttons mouse-right) | |
128 (push-mark) | |
129 (sup-move-point-to-x-y x y) | |
130 (exchange-point-and-mark)) | |
131 ((= buttons mouse-2right) | |
132 (push-mark) | |
133 (sup-move-point-to-x-y x y) | |
134 (kill-region (mark) (point))) | |
135 ((= buttons mouse-3right) | |
136 (push-mark) | |
137 (sup-move-point-to-x-y x y) | |
138 (copy-region-as-kill (mark) (point)) | |
139 (setq this-command 'yank)) | |
140 ((= buttons mouse-center) | |
141 (sup-move-point-to-x-y x y) | |
142 (setq this-command 'yank) | |
143 (yank)) | |
144 ((= buttons mouse-2center) | |
145 (yank-pop 1)) | |
146 ) | |
147 ) | |
148 (in-minibuf-p | |
149 (cond ((= buttons mouse-right) | |
150 (call-interactively 'eval-expression)) | |
151 ((= buttons mouse-left) | |
152 (call-interactively 'execute-extended-command)) | |
153 ((= buttons mouse-center) | |
154 (describe-function 'sup-mouse-report)); silly self help | |
155 )) | |
156 (t ;in another window | |
157 (select-window window) | |
158 (cond ((not sup-mouse-fast-select-window)) | |
159 ((= buttons mouse-left) | |
160 (sup-move-point-to-x-y x y)) | |
161 ((= buttons mouse-right) | |
162 (push-mark) | |
163 (sup-move-point-to-x-y x y) | |
164 (exchange-point-and-mark)) | |
165 ((= buttons mouse-center) | |
166 (sup-move-point-to-x-y x y) | |
167 (setq this-command 'yank) | |
168 (yank)) | |
169 )) | |
170 ))) | |
171 | |
172 | |
173 (defun sup-get-tty-num (term-char) | |
174 "Read from terminal until TERM-CHAR is read, and return intervening number. | |
175 Upon non-numeric not matching TERM-CHAR signal an error." | |
176 (let | |
177 ((num 0) | |
178 (char (read-char))) | |
179 (while (and (>= char ?0) | |
180 (<= char ?9)) | |
181 (setq num (+ (* num 10) (- char ?0))) | |
182 (setq char (read-char))) | |
183 (or (eq term-char char) | |
184 (error "Invalid data format in mouse command")) | |
185 num)) | |
186 | |
187 (defun sup-move-point-to-x-y (x y) | |
188 "Position cursor in window coordinates. | |
189 X and Y are 0-based character positions in the window." | |
190 (move-to-window-line y) | |
191 (move-to-column x) | |
192 ) | |
193 | |
194 (defun sup-pos-to-window (x y) | |
195 "Find window corresponding to frame coordinates. | |
196 X and Y are 0-based character positions on the frame." | |
772 | 197 (let ((edges (sup-window-edges)) |
0 | 198 (window nil)) |
199 (while (and (not (eq window (selected-window))) | |
200 (or (< y (nth 1 edges)) | |
201 (>= y (nth 3 edges)) | |
202 (< x (nth 0 edges)) | |
203 (>= x (nth 2 edges)))) | |
204 (setq window (next-window window)) | |
772 | 205 (setq edges (sup-window-edges window)) |
0 | 206 ) |
207 (or window (selected-window)) | |
208 ) | |
209 ) | |
210 | |
211 ;;; sup-mouse.el ends here |