annotate lisp/msw-select.el @ 249:83b3d10dcba9 r20-5b23

Import from CVS: tag r20-5b23
author cvs
date Mon, 13 Aug 2007 10:19:09 +0200
parents 6c0ae1f9357f
children 7df0dd720c89
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
221
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
1 ;;; msw-select.el --- Lisp interface to mswindows selections.
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
2
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
3 ;; Copyright (C) 1990, 1997 Free Software Foundation, Inc.
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Sun Microsystems.
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
5
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
6 ;; Maintainer: XEmacs Development Team
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
7 ;; Keywords: extensions, dumped
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
8
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
10
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
14 ;; any later version.
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
15
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
19 ;; General Public License for more details.
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
20
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
25
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
26 ;;; Synched up with: Not in FSF
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
27
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
28 ;;; Commentary:
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
29
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
30 ;; This file is dumped with XEmacs (when mswindows support is compiled in).
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
31 ;; #### Only copes with copying/pasting text
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
32
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
33 ;;; Code:
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
34
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
35 (defun mswindows-paste-clipboard ()
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
36 "Insert the current contents of the mswindows clipboard at point,
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
37 replacing the active selection if there is one."
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
38 (interactive "*")
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
39 (setq last-command nil)
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
40 (setq this-command 'yank) ; so that yank-pop works.
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
41 (let ((clip (mswindows-get-clipboard)) (s (mark-marker)) (e (point-marker)))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
42 (or clip (error "there is no text on the clipboard"))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
43 (if s
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
44 (if mouse-track-rectangle-p
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
45 (delete-rectangle s e)
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
46 (delete-region s e)))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
47 (push-mark)
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
48 (if mouse-track-rectangle-p
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
49 (insert-rectangle clip)
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
50 (insert clip))))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
51
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
52 (defun mswindows-copy-clipboard ()
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
53 "Copy the selection to the mswindows clipboard and to the kill ring."
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
54 (interactive)
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
55 (mswindows-cut-copy-clipboard 'copy))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
56
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
57 (defun mswindows-cut-clipboard ()
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
58 "Copy the selection to the mswindows clipboard and to the kill ring,
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
59 then delete it."
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
60 (interactive "*")
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
61 (mswindows-cut-copy-clipboard 'cut))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
62
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
63 (defun mswindows-cut-copy-clipboard (mode)
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
64 "Don't use this function.
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
65 Use mswindows-cut-clipboard or mswindows-copy-clipboard instead."
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
66 (or (memq mode '(cut copy)) (error "unkown mode %S" mode))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
67 (setq last-command nil)
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
68 (let ((s (mark-marker)) (e (point-marker)))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
69 (if s
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
70 (progn
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
71 (if mouse-track-rectangle-p
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
72 (progn
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
73 (setq killed-rectangle (extract-rectangle s e))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
74 (kill-new (mapconcat 'identity killed-rectangle "\n")))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
75 (copy-region-as-kill s e))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
76 (mswindows-set-clipboard (car kill-ring))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
77 (if (eq mode 'cut)
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
78 (if mouse-track-rectangle-p
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
79 (delete-rectangle s e)
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
80 (delete-region s e))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
81 ;; mswindows apps normally leave the selection active but that feels weird here
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
82 ;; (setq zmacs-region-stays t)
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
83 ))
6c0ae1f9357f Import from CVS: tag r20-4b9
cvs
parents:
diff changeset
84 (error "there is no selection to cut or copy"))))