/[climacs]/climacs/gui.lisp
ViewVC logotype

Contents of /climacs/gui.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.47 - (show annotations)
Wed Jan 5 05:09:04 2005 UTC (9 years, 3 months ago) by rstrandh
Branch: MAIN
Changes since 1.46: +64 -39 lines
Added (non-incremental for now) search functions.
1 ;;; -*- Mode: Lisp; Package: CLIMACS-GUI -*-
2
3 ;;; (c) copyright 2004 by
4 ;;; Robert Strandh (strandh@labri.fr)
5 ;;; (c) copyright 2004 by
6 ;;; Elliott Johnson (ejohnson@fasl.info)
7
8 ;;; This library is free software; you can redistribute it and/or
9 ;;; modify it under the terms of the GNU Library General Public
10 ;;; License as published by the Free Software Foundation; either
11 ;;; version 2 of the License, or (at your option) any later version.
12 ;;;
13 ;;; This library is distributed in the hope that it will be useful,
14 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ;;; Library General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU Library General Public
19 ;;; License along with this library; if not, write to the
20 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 ;;; Boston, MA 02111-1307 USA.
22
23 ;;; GUI for the Climacs editor.
24
25 (in-package :climacs-gui)
26
27 (defclass filename-mixin ()
28 ((filename :initform nil :accessor filename)))
29
30 (defclass climacs-buffer (standard-buffer abbrev-mixin filename-mixin name-mixin)
31 ((needs-saving :initform nil :accessor needs-saving))
32 (:default-initargs :name "*scratch*"))
33
34
35 (defclass climacs-pane (application-pane)
36 ((buffer :initform (make-instance 'climacs-buffer) :accessor buffer)
37 (point :initform nil :initarg :point :reader point)
38 (syntax :initarg :syntax :accessor syntax)
39 (mark :initform nil :initarg :mark :reader mark)))
40
41 (defmethod initialize-instance :after ((pane climacs-pane) &rest args)
42 (declare (ignore args))
43 (with-slots (buffer point syntax mark) pane
44 (when (null point)
45 (setf point (make-instance 'standard-right-sticky-mark
46 :buffer buffer)))
47 (when (null mark)
48 (setf mark (make-instance 'standard-right-sticky-mark
49 :buffer buffer)))
50 (setf syntax (make-instance 'texinfo-syntax :pane pane))))
51
52 (defclass minibuffer-pane (application-pane) ())
53
54 (defmethod stream-accept :before ((pane minibuffer-pane) type &rest args)
55 (declare (ignore type args))
56 (window-clear pane))
57
58 (define-application-frame climacs ()
59 ((win :reader win))
60 (:panes
61 (win (make-pane 'climacs-pane
62 :width 900 :height 400
63 :name 'win
64 :incremental-redisplay t
65 :display-function 'display-win))
66 (info :application
67 :width 900 :height 20 :max-height 20
68 :name 'info :background +light-gray+
69 :scroll-bars nil
70 :incremental-redisplay t
71 :display-function 'display-info)
72 (int (make-pane 'minibuffer-pane
73 :width 900 :height 20 :max-height 20 :min-height 20
74 :scroll-bars nil)))
75 (:layouts
76 (default
77 (vertically (:scroll-bars nil)
78 (scrolling (:width 900 :height 400) win)
79 info
80 int))
81 (without-interactor
82 (vertically (:scroll-bars nil)
83 (scrolling (:width 900 :height 400) win)
84 info)))
85 (:top-level (climacs-top-level)))
86
87 (defmethod redisplay-frame-panes :after ((frame climacs) &rest args)
88 (declare (ignore args))
89 (clear-modify (buffer (win frame))))
90
91 (defun climacs ()
92 "Starts up a climacs session"
93 (let ((frame (make-application-frame 'climacs)))
94 (run-frame-top-level frame)))
95
96 (defun display-message (format-string &rest format-args)
97 (apply #'format *standard-input* format-string format-args))
98
99 (defun display-info (frame pane)
100 (let* ((win (win frame))
101 (buf (buffer win))
102 (name-info (format nil " ~a ~a Syntax: ~a"
103 (if (needs-saving buf) "**" "--")
104 (name buf)
105 (name (syntax win)))))
106 (princ name-info pane)))
107
108 (defun display-win (frame pane)
109 "The display function used by the climacs application frame."
110 (declare (ignore frame))
111 (redisplay-pane pane))
112
113 (defun find-gestures (gestures start-table)
114 (loop with table = (find-command-table start-table)
115 for (gesture . rest) on gestures
116 for item = (find-keystroke-item gesture table :errorp nil)
117 while item
118 do (if (eq (command-menu-item-type item) :command)
119 (return (if (null rest) item nil))
120 (setf table (command-menu-item-value item)))
121 finally (return item)))
122
123 (defvar *kill-ring* (initialize-kill-ring 7))
124 (defparameter *current-gesture* nil)
125
126 (defun meta-digit (gesture)
127 (position gesture
128 '((#\0 :meta) (#\1 :meta) (#\2 :meta) (#\3 :meta) (#\4 :meta)
129 (#\5 :meta) (#\6 :meta) (#\7 :meta) (#\8 :meta) (#\9 :meta))
130 :test #'event-matches-gesture-name-p))
131
132 (defun climacs-read-gesture ()
133 (loop for gesture = (read-gesture :stream *standard-input*)
134 when (event-matches-gesture-name-p gesture '(#\g :control))
135 do (throw 'outer-loop nil)
136 until (or (characterp gesture)
137 (and (typep gesture 'keyboard-event)
138 (or (keyboard-event-character gesture)
139 (not (member (keyboard-event-key-name
140 gesture)
141 '(:control-left :control-right
142 :shift-left :shift-right
143 :meta-left :meta-right
144 :super-left :super-right
145 :hyper-left :hyper-right
146 :shift-lock :caps-lock
147 :alt-left :alt-right))))))
148 finally (return gesture)))
149
150 (defun read-numeric-argument (&key (stream *standard-input*))
151 (let ((gesture (climacs-read-gesture)))
152 (cond ((event-matches-gesture-name-p gesture '(#\u :control))
153 (let ((numarg 4))
154 (loop for gesture = (climacs-read-gesture)
155 while (event-matches-gesture-name-p gesture '(#\u :control))
156 do (setf numarg (* 4 numarg))
157 finally (unread-gesture gesture :stream stream))
158 (let ((gesture (climacs-read-gesture)))
159 (cond ((and (characterp gesture)
160 (digit-char-p gesture 10))
161 (setf numarg (- (char-code gesture) (char-code #\0)))
162 (loop for gesture = (climacs-read-gesture)
163 while (and (characterp gesture)
164 (digit-char-p gesture 10))
165 do (setf gesture (+ (* 10 numarg)
166 (- (char-code gesture) (char-code #\0))))
167 finally (unread-gesture gesture :stream stream)
168 (return (values numarg t))))
169 (t
170 (values numarg t))))))
171 ((meta-digit gesture)
172 (let ((numarg (meta-digit gesture)))
173 (loop for gesture = (climacs-read-gesture)
174 while (meta-digit gesture)
175 do (setf numarg (+ (* 10 numarg) (meta-digit gesture)))
176 finally (unread-gesture gesture :stream stream)
177 (return (values numarg t)))))
178 (t (unread-gesture gesture :stream stream)
179 (values 1 nil)))))
180
181 (defun climacs-top-level (frame &key
182 command-parser command-unparser
183 partial-command-parser prompt)
184 (declare (ignore command-parser command-unparser partial-command-parser prompt))
185 (setf (slot-value frame 'win) (find-pane-named frame 'win))
186 (let ((*standard-output* (find-pane-named frame 'win))
187 (*standard-input* (find-pane-named frame 'int))
188 (*print-pretty* nil)
189 (*abort-gestures* nil))
190 (redisplay-frame-panes frame :force-p t)
191 (loop (catch 'outer-loop
192 (loop with gestures = '()
193 with numarg = 1 ; FIXME (read-numeric-argument :stream *standard-input*)
194 do (setf *current-gesture* (climacs-read-gesture))
195 (setf gestures (nconc gestures (list *current-gesture*)))
196 (let ((item (find-gestures gestures 'global-climacs-table)))
197 (cond ((not item)
198 (beep) (setf gestures '()))
199 ((eq (command-menu-item-type item) :command)
200 (let ((command (command-menu-item-value item)))
201 (unless (consp command)
202 (setf command (list command)))
203 (setf command (substitute-numeric-argument-marker command numarg))
204 (handler-case
205 (execute-frame-command frame command)
206 (error (condition)
207 (beep)
208 (format *error-output* "~a~%" condition)))
209 (setf gestures '())))
210 (t nil)))
211 (let ((buffer (buffer (win frame))))
212 (when (modified-p buffer)
213 (setf (needs-saving buffer) t)))
214 (redisplay-frame-panes frame)))
215 (beep)
216 (let ((buffer (buffer (win frame))))
217 (when (modified-p buffer)
218 (setf (needs-saving buffer) t)))
219 (redisplay-frame-panes frame))))
220
221 (defmacro define-named-command (command-name args &body body)
222 `(define-climacs-command ,(if (listp command-name) `(,@command-name :name t) `(,command-name :name t)) ,args ,@body))
223
224 (define-named-command (com-quit) ()
225 (frame-exit *application-frame*))
226
227 (define-command com-self-insert ()
228 (unless (constituentp *current-gesture*)
229 (possibly-expand-abbrev (point (win *application-frame*))))
230 (insert-object (point (win *application-frame*)) *current-gesture*))
231
232 (define-named-command com-beginning-of-line ()
233 (beginning-of-line (point (win *application-frame*))))
234
235 (define-named-command com-end-of-line ()
236 (end-of-line (point (win *application-frame*))))
237
238 (define-named-command com-delete-object ()
239 (delete-range (point (win *application-frame*))))
240
241 (define-named-command com-backward-delete-object ()
242 (delete-range (point (win *application-frame*)) -1))
243
244 (define-named-command com-transpose-objects ()
245 (let* ((point (point (win *application-frame*))))
246 (unless (beginning-of-buffer-p point)
247 (when (end-of-line-p point)
248 (backward-object point))
249 (let ((object (object-after point)))
250 (delete-range point)
251 (backward-object point)
252 (insert-object point object)
253 (forward-object point)))))
254
255 (defgeneric backward-object (mark &optional count))
256 (defmethod backward-object ((mark climacs-buffer::mark-mixin)
257 &optional (count 1))
258 (decf (offset mark) count))
259
260 (defgeneric forward-object (mark &optional count))
261 (defmethod forward-object ((mark climacs-buffer::mark-mixin)
262 &optional (count 1))
263 (incf (offset mark) count))
264
265 (define-named-command com-backward-object ()
266 (backward-object (point (win *application-frame*))))
267
268 (define-named-command com-forward-object ()
269 (forward-object (point (win *application-frame*))))
270
271 (define-named-command com-transpose-words ()
272 (let* ((point (point (win *application-frame*))))
273 (let (bw1 bw2 ew1 ew2)
274 (backward-word point)
275 (setf bw1 (offset point))
276 (forward-word point)
277 (setf ew1 (offset point))
278 (forward-word point)
279 (when (= (offset point) ew1)
280 ;; this is emacs' message in the minibuffer
281 (error "Don't have two things to transpose"))
282 (setf ew2 (offset point))
283 (backward-word point)
284 (setf bw2 (offset point))
285 (let ((w2 (buffer-sequence (buffer point) bw2 ew2))
286 (w1 (buffer-sequence (buffer point) bw1 ew1)))
287 (delete-word point)
288 (insert-sequence point w1)
289 (backward-word point)
290 (backward-word point)
291 (delete-word point)
292 (insert-sequence point w2)
293 (forward-word point)))))
294
295 (define-named-command com-transpose-lines ()
296 (let ((point (point (win *application-frame*))))
297 (beginning-of-line point)
298 (unless (beginning-of-buffer-p point)
299 (previous-line point))
300 (let* ((bol (offset point))
301 (eol (progn (end-of-line point)
302 (offset point)))
303 (line (buffer-sequence (buffer point) bol eol)))
304 (delete-region bol point)
305 ;; Remove newline at end of line as well.
306 (unless (end-of-buffer-p point)
307 (delete-range point))
308 ;; If the current line is at the end of the buffer, we want to
309 ;; be able to insert past it, so we need to get an extra line
310 ;; at the end.
311 (when (progn (end-of-line point)
312 (end-of-buffer-p point))
313 (insert-object point #\Newline))
314 (next-line point)
315 (insert-sequence point line)
316 (insert-object point #\Newline))))
317
318 (define-named-command com-previous-line ()
319 (previous-line (point (win *application-frame*))))
320
321 (define-named-command com-next-line ()
322 (next-line (point (win *application-frame*))))
323
324 (define-named-command com-open-line ()
325 (open-line (point (win *application-frame*))))
326
327 (define-named-command com-kill-line ()
328 (kill-line (point (win *application-frame*))))
329
330 (define-named-command com-forward-word ()
331 (forward-word (point (win *application-frame*))))
332
333 (define-named-command com-backward-word ()
334 (backward-word (point (win *application-frame*))))
335
336 (define-named-command com-delete-word ()
337 (delete-word (point (win *application-frame*))))
338
339 (define-named-command com-backward-delete-word ()
340 (backward-delete-word (point (win *application-frame*))))
341
342 (define-named-command com-toggle-layout ()
343 (setf (frame-current-layout *application-frame*)
344 (if (eq (frame-current-layout *application-frame*) 'default)
345 'without-interactor
346 'default)))
347
348 (define-command com-extended-command ()
349 (let ((item (accept 'command :prompt "Extended Command")))
350 (execute-frame-command *application-frame* item)))
351
352 (eval-when (:compile-toplevel :load-toplevel)
353 (define-presentation-type completable-pathname ()
354 :inherit-from 'pathname))
355
356 (defun filename-completer (so-far mode)
357 (flet ((remove-trail (s)
358 (subseq s 0 (let ((pos (position #\/ s :from-end t)))
359 (if pos (1+ pos) 0)))))
360 (let* ((directory-prefix
361 (if (and (plusp (length so-far)) (eql (aref so-far 0) #\/))
362 ""
363 (namestring #+sbcl (car (directory ".")) #+cmu (ext:default-directory))))
364 (full-so-far (concatenate 'string directory-prefix so-far))
365 (pathnames
366 (loop with length = (length full-so-far)
367 for path in (directory (concatenate 'string
368 (remove-trail so-far)
369 "*.*"))
370 when (let ((mismatch (mismatch (namestring path) full-so-far)))
371 (or (null mismatch) (= mismatch length)))
372 collect path))
373 (strings (mapcar #'namestring pathnames))
374 (first-string (car strings))
375 (length-common-prefix nil)
376 (completed-string nil)
377 (full-completed-string nil))
378 (unless (null pathnames)
379 (setf length-common-prefix
380 (loop with length = (length first-string)
381 for string in (cdr strings)
382 do (setf length (min length (or (mismatch string first-string) length)))
383 finally (return length))))
384 (unless (null pathnames)
385 (setf completed-string
386 (subseq first-string (length directory-prefix)
387 (if (null (cdr pathnames)) nil length-common-prefix)))
388 (setf full-completed-string
389 (concatenate 'string directory-prefix completed-string)))
390 (case mode
391 ((:complete-limited :complete-maximal)
392 (cond ((null pathnames)
393 (values so-far nil nil 0 nil))
394 ((null (cdr pathnames))
395 (values completed-string t (car pathnames) 1 nil))
396 (t
397 (values completed-string nil nil (length pathnames) nil))))
398 (:complete
399 (cond ((null pathnames)
400 (values so-far t so-far 1 nil))
401 ((null (cdr pathnames))
402 (values completed-string t (car pathnames) 1 nil))
403 ((find full-completed-string strings :test #'string-equal)
404 (let ((pos (position full-completed-string strings :test #'string-equal)))
405 (values completed-string
406 t (elt pathnames pos) (length pathnames) nil)))
407 (t
408 (values completed-string nil nil (length pathnames) nil))))
409 (:possibilities
410 (values nil nil nil (length pathnames)
411 (loop with length = (length directory-prefix)
412 for name in pathnames
413 collect (list (subseq (namestring name) length nil)
414 name))))))))
415
416 (define-presentation-method accept
417 ((type completable-pathname) stream (view textual-view) &key)
418 (multiple-value-bind (pathname success string)
419 (complete-input stream
420 #'filename-completer
421 :partial-completers '(#\Space)
422 :allow-any-input t)
423 (declare (ignore success))
424 (or pathname string)))
425
426 (defun pathname-filename (pathname)
427 (if (null (pathname-type pathname))
428 (pathname-name pathname)
429 (concatenate 'string (pathname-name pathname)
430 "." (pathname-type pathname))))
431
432 (define-named-command com-find-file ()
433 (let ((filename (accept 'completable-pathname
434 :prompt "Find File")))
435 (with-slots (buffer point syntax) (win *application-frame*)
436 (setf buffer (make-instance 'climacs-buffer)
437 point (make-instance 'standard-right-sticky-mark :buffer buffer)
438 syntax (make-instance 'texinfo-syntax :pane (win *application-frame*)))
439 (with-open-file (stream filename :direction :input :if-does-not-exist :create)
440 (input-from-stream stream buffer 0))
441 (setf (filename buffer) filename
442 (name buffer) (pathname-filename filename)
443 (needs-saving buffer) nil)
444 (beginning-of-buffer point)
445 ;; this one is needed so that the buffer modification protocol
446 ;; resets the low and high marks after redisplay
447 (redisplay-frame-panes *application-frame*))))
448
449 (define-named-command com-save-buffer ()
450 (let* ((buffer (buffer (win *application-frame*)))
451 (filename (or (filename buffer)
452 (accept 'completable-pathname
453 :prompt "Save Buffer to File"))))
454 (if (or (null (filename buffer))
455 (needs-saving buffer))
456 (progn (with-open-file (stream filename :direction :output :if-exists :supersede)
457 (output-to-stream stream buffer 0 (size buffer)))
458 (setf (filename buffer) filename
459 (name buffer) (pathname-filename filename))
460 (display-message "Wrote: ~a" (filename buffer)))
461 (display-message "No changes need to be saved from ~a" (name buffer)))
462 (setf (needs-saving buffer) nil)))
463
464 (define-named-command com-write-buffer ()
465 (let ((filename (accept 'completable-pathname
466 :prompt "Write Buffer to File"))
467 (buffer (buffer (win *application-frame*))))
468 (with-open-file (stream filename :direction :output :if-exists :supersede)
469 (output-to-stream stream buffer 0 (size buffer)))
470 (setf (filename buffer) filename
471 (name buffer) (pathname-filename filename)
472 (needs-saving buffer) nil)
473 (display-message "Wrote: ~a" (filename buffer))))
474
475 (define-named-command com-beginning-of-buffer ()
476 (beginning-of-buffer (point (win *application-frame*))))
477
478 (define-named-command com-page-down ()
479 (let ((pane (win *application-frame*)))
480 (page-down pane (syntax pane))))
481
482 (define-named-command com-page-up ()
483 (let ((pane (win *application-frame*)))
484 (page-up pane (syntax pane))))
485
486 (define-named-command com-end-of-buffer ()
487 (end-of-buffer (point (win *application-frame*))))
488
489 (define-named-command com-back-to-indentation ()
490 (let ((point (point (win *application-frame*))))
491 (beginning-of-line point)
492 (loop until (end-of-line-p point)
493 while (whitespacep (object-after point))
494 do (incf (offset point)))))
495
496 (define-named-command com-goto-position ()
497 (setf (offset (point (win *application-frame*)))
498 (accept 'integer :prompt "Goto Position")))
499
500 (define-named-command com-goto-line ()
501 (loop with mark = (make-instance 'standard-right-sticky-mark
502 :buffer (buffer (win *application-frame*)))
503 do (end-of-line mark)
504 until (end-of-buffer-p mark)
505 repeat (accept 'integer :prompt "Goto Line")
506 do (incf (offset mark))
507 (end-of-line mark)
508 finally (beginning-of-line mark)
509 (setf (offset (point (win *application-frame*)))
510 (offset mark))))
511
512 (define-named-command com-browse-url ()
513 (accept 'url :prompt "Browse URL"))
514
515 (define-named-command com-set-mark ()
516 (with-slots (point mark) (win *application-frame*)
517 (setf mark (clone-mark point))))
518
519 (define-named-command com-exchange-point-and-mark ()
520 (with-slots (point mark) (win *application-frame*)
521 (psetf (offset mark) (offset point)
522 (offset point) (offset mark))))
523
524 (define-named-command com-set-syntax ()
525 (setf (syntax (win *application-frame*))
526 (make-instance (accept 'syntax :prompt "Set Syntax")
527 :pane (win *application-frame*))))
528
529 ;;;;;;;;;;;;;;;;;;;;
530 ;; Kill ring commands
531
532 ;; Copies an element from a kill-ring to a buffer at the given offset
533 (define-named-command com-copy-in ()
534 (insert-sequence (point (win *application-frame*)) (kr-copy *kill-ring*)))
535
536 ;; Cuts an element from a kill-ring out to a buffer at a given offset
537 (define-named-command com-cut-in ()
538 (insert-sequence (point (win *application-frame*)) (kr-pop *kill-ring*)))
539
540 ;; Destructively cut a given buffer region into the kill-ring
541 (define-named-command com-cut-out ()
542 (with-slots (buffer point mark)(win *application-frame*)
543 (if (< (offset point) (offset mark))
544 ((lambda (b o1 o2)
545 (kr-push *kill-ring* (buffer-sequence b o1 o2))
546 (delete-buffer-range b o1 (- o2 o1)))
547 buffer (offset point) (offset mark))
548 ((lambda (b o1 o2)
549 (kr-push *kill-ring* (buffer-sequence b o2 o1))
550 (delete-buffer-range b o1 (- o2 o1)))
551 buffer (offset mark) (offset point)))))
552
553
554 ;; Non destructively copies in buffer region to the kill ring
555 (define-named-command com-copy-out ()
556 (with-slots (buffer point mark)(win *application-frame*)
557 (let ((off1 (offset point))
558 (off2 (offset mark)))
559 (if (< off1 off2)
560 (kr-push *kill-ring* (buffer-sequence buffer off1 off2))
561 (kr-push *kill-ring* (buffer-sequence buffer off2 off1))))))
562
563 ;; Needs adjustment to be like emacs M-y
564 (define-named-command com-kr-rotate ()
565 (kr-rotate *kill-ring* -1))
566
567 ;; Not bound to a key yet
568 (define-named-command com-kr-resize ()
569 (let ((size (accept 'integer :prompt "New kill ring size")))
570 (kr-resize *kill-ring* size)))
571
572 (define-named-command com-search-forward ()
573 (search-forward (point (win *application-frame*))
574 (accept 'string :prompt "Search Forward")
575 :test (lambda (a b)
576 (and (characterp b) (char-equal a b)))))
577
578 (define-named-command com-search-backward ()
579 (search-backward (point (win *application-frame*))
580 (accept 'string :prompt "Search Backward")
581 :test (lambda (a b)
582 (and (characterp b) (char-equal a b)))))
583
584 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
585 ;;;
586 ;;; Global command table
587
588 (make-command-table 'global-climacs-table :errorp nil)
589
590 (defun global-set-key (gesture command)
591 (add-command-to-command-table command 'global-climacs-table
592 :keystroke gesture :errorp nil))
593
594 (loop for code from (char-code #\space) to (char-code #\~)
595 do (global-set-key (code-char code) 'com-self-insert))
596
597 (global-set-key #\newline 'com-self-insert)
598 (global-set-key #\tab 'com-self-insert)
599 (global-set-key '(#\f :control) 'com-forward-object)
600 (global-set-key '(#\b :control) 'com-backward-object)
601 (global-set-key '(#\a :control) 'com-beginning-of-line)
602 (global-set-key '(#\e :control) 'com-end-of-line)
603 (global-set-key '(#\d :control) 'com-delete-object)
604 (global-set-key '(#\p :control) 'com-previous-line)
605 (global-set-key '(#\n :control) 'com-next-line)
606 (global-set-key '(#\o :control) 'com-open-line)
607 (global-set-key '(#\k :control) 'com-kill-line)
608 (global-set-key '(#\t :control) 'com-transpose-objects)
609 (global-set-key '(#\Space :control) 'com-set-mark)
610 (global-set-key '(#\y :control) 'com-copy-in)
611 (global-set-key '(#\w :control) 'com-cut-out)
612 (global-set-key '(#\f :meta) 'com-forward-word)
613 (global-set-key '(#\b :meta) 'com-backward-word)
614 (global-set-key '(#\t :meta) 'com-transpose-words)
615 (global-set-key '(#\x :meta) 'com-extended-command)
616 (global-set-key '(#\y :meta) 'com-kr-rotate) ;currently rotates only
617 (global-set-key '(#\w :meta) 'com-copy-out)
618 (global-set-key '(#\v :control) 'com-page-down)
619 (global-set-key '(#\v :meta) 'com-page-up)
620 (global-set-key '(#\< :shift :meta) 'com-beginning-of-buffer)
621 (global-set-key '(#\> :shift :meta) 'com-end-of-buffer)
622 (global-set-key '(#\u :meta) 'com-browse-url)
623 (global-set-key '(#\m :meta) 'com-back-to-indentation)
624 (global-set-key '(#\d :meta) 'com-delete-word)
625 (global-set-key '(#\Backspace :meta) 'com-backward-delete-word)
626
627 (global-set-key '(:up) 'com-previous-line)
628 (global-set-key '(:down) 'com-next-line)
629 (global-set-key '(:left) 'com-backward-object)
630 (global-set-key '(:right) 'com-forward-object)
631 (global-set-key '(:left :control) 'com-backward-word)
632 (global-set-key '(:right :control) 'com-forward-word)
633 (global-set-key '(:home) 'com-beginning-of-line)
634 (global-set-key '(:end) 'com-end-of-line)
635 (global-set-key '(:home :control) 'com-beginning-of-buffer)
636 (global-set-key '(:end :control) 'com-end-of-buffer)
637 (global-set-key #\Rubout 'com-delete-object)
638 (global-set-key #\Backspace 'com-backward-delete-object)
639
640 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
641 ;;;
642 ;;; C-x command table
643
644 (make-command-table 'c-x-climacs-table :errorp nil)
645
646 (add-menu-item-to-command-table 'global-climacs-table "C-x"
647 :menu 'c-x-climacs-table
648 :keystroke '(#\x :control))
649
650 (defun c-x-set-key (gesture command)
651 (add-command-to-command-table command 'c-x-climacs-table
652 :keystroke gesture :errorp nil))
653
654 (c-x-set-key '(#\c :control) 'com-quit)
655 (c-x-set-key '(#\f :control) 'com-find-file)
656 (c-x-set-key '(#\s :control) 'com-save-buffer)
657 (c-x-set-key '(#\t :control) 'com-transpose-lines)
658 (c-x-set-key '(#\w :control) 'com-write-buffer)
659 (c-x-set-key '(#\x :control) 'com-exchange-point-and-mark)
660
661 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
662 ;;;
663 ;;; Some Unicode stuff
664
665 (define-named-command com-insert-charcode ((code 'integer :prompt "Code point"))
666 (insert-object (point (win *application-frame*)) (code-char code)))
667
668 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
669 ;;;
670 ;;; Dead-acute command table
671
672 (make-command-table 'dead-acute-climacs-table :errorp nil)
673
674 (add-menu-item-to-command-table 'global-climacs-table "dead-acute"
675 :menu 'dead-acute-climacs-table
676 :keystroke '(:dead--acute))
677
678 (defun dead-acute-set-key (gesture command)
679 (add-command-to-command-table command 'dead-acute-climacs-table
680 :keystroke gesture :errorp nil))
681
682 (dead-acute-set-key '(#\A) '(com-insert-charcode 193))
683 (dead-acute-set-key '(#\E) '(com-insert-charcode 201))
684 (dead-acute-set-key '(#\I) '(com-insert-charcode 205))
685 (dead-acute-set-key '(#\O) '(com-insert-charcode 211))
686 (dead-acute-set-key '(#\U) '(com-insert-charcode 218))
687 (dead-acute-set-key '(#\Y) '(com-insert-charcode 221))
688 (dead-acute-set-key '(#\a) '(com-insert-charcode 225))
689 (dead-acute-set-key '(#\e) '(com-insert-charcode 233))
690 (dead-acute-set-key '(#\i) '(com-insert-charcode 237))
691 (dead-acute-set-key '(#\o) '(com-insert-charcode 243))
692 (dead-acute-set-key '(#\u) '(com-insert-charcode 250))
693 (dead-acute-set-key '(#\y) '(com-insert-charcode 253))
694 (dead-acute-set-key '(#\C) '(com-insert-charcode 199))
695 (dead-acute-set-key '(#\c) '(com-insert-charcode 231))
696 (dead-acute-set-key '(#\x) '(com-insert-charcode 215))
697 (dead-acute-set-key '(#\-) '(com-insert-charcode 247))
698 (dead-acute-set-key '(#\T) '(com-insert-charcode 222))
699 (dead-acute-set-key '(#\t) '(com-insert-charcode 254))
700 (dead-acute-set-key '(#\s) '(com-insert-charcode 223))
701 (dead-acute-set-key '(#\Space) '(com-insert-charcode 39))
702
703 (make-command-table 'dead-acute-dead-accute-climacs-table :errorp nil)
704
705 (add-menu-item-to-command-table 'dead-acute-climacs-table "dead-acute-dead-accute"
706 :menu 'dead-acute-dead-accute-climacs-table
707 :keystroke '(:dead--acute))
708
709 (defun dead-acute-dead-accute-set-key (gesture command)
710 (add-command-to-command-table command 'dead-acute-dead-accute-climacs-table
711 :keystroke gesture :errorp nil))
712
713 (dead-acute-dead-accute-set-key '(#\A) '(com-insert-charcode 197))
714 (dead-acute-dead-accute-set-key '(#\a) '(com-insert-charcode 229))
715 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
716 ;;;
717 ;;; Dead-grave command table
718
719 (make-command-table 'dead-grave-climacs-table :errorp nil)
720
721 (add-menu-item-to-command-table 'global-climacs-table "dead-grave"
722 :menu 'dead-grave-climacs-table
723 :keystroke '(:dead--grave))
724
725 (defun dead-grave-set-key (gesture command)
726 (add-command-to-command-table command 'dead-grave-climacs-table
727 :keystroke gesture :errorp nil))
728
729 (dead-grave-set-key '(#\A) '(com-insert-charcode 192))
730 (dead-grave-set-key '(#\E) '(com-insert-charcode 200))
731 (dead-grave-set-key '(#\I) '(com-insert-charcode 204))
732 (dead-grave-set-key '(#\O) '(com-insert-charcode 210))
733 (dead-grave-set-key '(#\U) '(com-insert-charcode 217))
734 (dead-grave-set-key '(#\a) '(com-insert-charcode 224))
735 (dead-grave-set-key '(#\e) '(com-insert-charcode 232))
736 (dead-grave-set-key '(#\i) '(com-insert-charcode 236))
737 (dead-grave-set-key '(#\o) '(com-insert-charcode 242))
738 (dead-grave-set-key '(#\u) '(com-insert-charcode 249))
739 (dead-grave-set-key '(#\Space) '(com-insert-charcode 96))
740
741 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
742 ;;;
743 ;;; Dead-diaeresis command table
744
745 (make-command-table 'dead-diaeresis-climacs-table :errorp nil)
746
747 (add-menu-item-to-command-table 'global-climacs-table "dead-diaeresis"
748 :menu 'dead-diaeresis-climacs-table
749 :keystroke '(:dead--diaeresis :shift))
750
751 (defun dead-diaeresis-set-key (gesture command)
752 (add-command-to-command-table command 'dead-diaeresis-climacs-table
753 :keystroke gesture :errorp nil))
754
755 (dead-diaeresis-set-key '(#\A) '(com-insert-charcode 196))
756 (dead-diaeresis-set-key '(#\E) '(com-insert-charcode 203))
757 (dead-diaeresis-set-key '(#\I) '(com-insert-charcode 207))
758 (dead-diaeresis-set-key '(#\O) '(com-insert-charcode 214))
759 (dead-diaeresis-set-key '(#\U) '(com-insert-charcode 220))
760 (dead-diaeresis-set-key '(#\a) '(com-insert-charcode 228))
761 (dead-diaeresis-set-key '(#\e) '(com-insert-charcode 235))
762 (dead-diaeresis-set-key '(#\i) '(com-insert-charcode 239))
763 (dead-diaeresis-set-key '(#\o) '(com-insert-charcode 246))
764 (dead-diaeresis-set-key '(#\u) '(com-insert-charcode 252))
765 (dead-diaeresis-set-key '(#\y) '(com-insert-charcode 255))
766 (dead-diaeresis-set-key '(#\Space) '(com-insert-charcode 34))
767
768 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
769 ;;;
770 ;;; Dead-tilde command table
771
772 (make-command-table 'dead-tilde-climacs-table :errorp nil)
773
774 (add-menu-item-to-command-table 'global-climacs-table "dead-tilde"
775 :menu 'dead-tilde-climacs-table
776 :keystroke '(:dead--tilde :shift))
777
778 (defun dead-tilde-set-key (gesture command)
779 (add-command-to-command-table command 'dead-tilde-climacs-table
780 :keystroke gesture :errorp nil))
781
782 (dead-tilde-set-key '(#\A) '(com-insert-charcode 195))
783 (dead-tilde-set-key '(#\N) '(com-insert-charcode 209))
784 (dead-tilde-set-key '(#\a) '(com-insert-charcode 227))
785 (dead-tilde-set-key '(#\n) '(com-insert-charcode 241))
786 (dead-tilde-set-key '(#\E) '(com-insert-charcode 198))
787 (dead-tilde-set-key '(#\e) '(com-insert-charcode 230))
788 (dead-tilde-set-key '(#\D) '(com-insert-charcode 208))
789 (dead-tilde-set-key '(#\d) '(com-insert-charcode 240))
790 (dead-tilde-set-key '(#\O) '(com-insert-charcode 216))
791 (dead-tilde-set-key '(#\o) '(com-insert-charcode 248))
792 (dead-tilde-set-key '(#\Space) '(com-insert-charcode 126))
793
794 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
795 ;;;
796 ;;; Dead-circumflex command table
797
798 (make-command-table 'dead-circumflex-climacs-table :errorp nil)
799
800 (add-menu-item-to-command-table 'global-climacs-table "dead-circumflex"
801 :menu 'dead-circumflex-climacs-table
802 :keystroke '(:dead--circumflex :shift))
803
804 (defun dead-circumflex-set-key (gesture command)
805 (add-command-to-command-table command 'dead-circumflex-climacs-table
806 :keystroke gesture :errorp nil))
807
808 (dead-circumflex-set-key '(#\A) '(com-insert-charcode 194))
809 (dead-circumflex-set-key '(#\E) '(com-insert-charcode 202))
810 (dead-circumflex-set-key '(#\I) '(com-insert-charcode 206))
811 (dead-circumflex-set-key '(#\O) '(com-insert-charcode 212))
812 (dead-circumflex-set-key '(#\U) '(com-insert-charcode 219))
813 (dead-circumflex-set-key '(#\a) '(com-insert-charcode 226))
814 (dead-circumflex-set-key '(#\e) '(com-insert-charcode 234))
815 (dead-circumflex-set-key '(#\i) '(com-insert-charcode 238))
816 (dead-circumflex-set-key '(#\o) '(com-insert-charcode 244))
817 (dead-circumflex-set-key '(#\u) '(com-insert-charcode 251))
818 (dead-circumflex-set-key '(#\Space) '(com-insert-charcode 94))

  ViewVC Help
Powered by ViewVC 1.1.5