comparison lisp/msw-select.el @ 280:7df0dd720c89 r21-0b38

Import from CVS: tag r21-0b38
author cvs
date Mon, 13 Aug 2007 10:32:22 +0200
parents 83b3d10dcba9
children 558f606b08ae
comparison
equal deleted inserted replaced
279:c20b2fb5bb0a 280:7df0dd720c89
80 (delete-region s e)) 80 (delete-region s e))
81 ;; mswindows apps normally leave the selection active but that feels weird here 81 ;; mswindows apps normally leave the selection active but that feels weird here
82 ;; (setq zmacs-region-stays t) 82 ;; (setq zmacs-region-stays t)
83 )) 83 ))
84 (error "there is no selection to cut or copy")))) 84 (error "there is no selection to cut or copy"))))
85
86 (defvar mswindows-selection-owned-p nil
87 "Whether we have a selection or not.
88 MS-Windows has no concept of ownership; don't use this.")
89
90 (defun mswindows-own-selection (data &optional type)
91 "Make an MS Windows selection of type TYPE and value DATA.
92 The argument TYPE is ignored, and DATA specifies the contents.
93 DATA may be a string,
94 a symbol, an integer (or a cons of two integers or list of two integers).
95
96 The selection may also be a cons of two markers pointing to the same buffer,
97 or an overlay. In these cases, the selection is considered to be the text
98 between the markers *at whatever time the selection is examined*.
99 Thus, editing done in the buffer after you specify the selection
100 can alter the effective value of the selection.
101
102 The data may also be a vector of valid non-vector selection values.
103
104 Interactively, the text of the region is used as the selection value."
105 (interactive (if (not current-prefix-arg)
106 (list (read-string "Store text for pasting: "))
107 (list (substring (region-beginning) (region-end)))))
108 (or (valid-simple-selection-p data)
109 (and (vectorp data)
110 (let ((valid t)
111 (i (1- (length data))))
112 (while (>= i 0)
113 (or (valid-simple-selection-p (aref data i))
114 (setq valid nil))
115 (setq i (1- i)))
116 valid))
117 (signal 'error (list "invalid selection" data)))
118 (if data
119 (setq mswindows-selection-owned-p data)
120 (setq mswindows-selection-owned-p nil))
121 (setq primary-selection-extent
122 (select-make-extent-for-selection
123 data primary-selection-extent))
124 (setq zmacs-region-stays t)
125 data)
126
127 (defun mswindows-disown-selection (&optional secondary-p)
128 "Assuming we own the selection, disown it. With an argument, discard the
129 secondary selection instead of the primary selection."
130 (setq mswindows-selection-owned-p nil))
131
132 (defun mswindows-selection-owner-p (&optional selection)
133 "Return t if current emacs process owns the given Selection.
134 The arg is ignored."
135 (not (eq mswindows-selection-owned-p nil)))
136