;;; ns-win.el --- lisp side of interface with NeXT/Open/GNUstep/MacOS X window system -*- lexical-binding: t -*-
-;; Copyright (C) 1993-1994, 2005-2014 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 2005-2015 Free Software Foundation, Inc.
;; Authors: Carl Edman
;; Christian Limpach
;;;; Pasteboard support.
(declare-function ns-get-selection-internal "nsselect.m" (buffer))
-(declare-function ns-store-selection-internal "nsselect.m" (buffer string))
(define-obsolete-function-alias 'ns-get-cut-buffer-internal
'ns-get-selection-internal "24.1")
(define-obsolete-function-alias 'ns-store-cut-buffer-internal
- 'ns-store-selection-internal "24.1")
-
-
-(defun ns-get-pasteboard ()
- "Returns the value of the pasteboard."
- (ns-get-selection-internal 'CLIPBOARD))
-
-(defun ns-set-pasteboard (string)
- "Store STRING into the pasteboard of the Nextstep display server."
- ;; Check the data type of STRING.
- (if (not (stringp string)) (error "Nonstring given to pasteboard"))
- (ns-store-selection-internal 'CLIPBOARD string))
-
-;; We keep track of the last text selected here, so we can check the
-;; current selection against it, and avoid passing back our own text
-;; from x-selection-value.
-(defvar ns-last-selected-text nil)
-
-;; Return the value of the current Nextstep selection. For
-;; compatibility with older Nextstep applications, this checks cut
-;; buffer 0 before retrieving the value of the primary selection.
-(defun x-selection-value ()
- (let (text)
- ;; Consult the selection. Treat empty strings as if they were unset.
- (or text (setq text (ns-get-pasteboard)))
- (if (string= text "") (setq text nil))
- (cond
- ((not text) nil)
- ((eq text ns-last-selected-text) nil)
- ((string= text ns-last-selected-text)
- ;; Record the newer string, so subsequent calls can use the `eq' test.
- (setq ns-last-selected-text text)
- nil)
- (t
- (setq ns-last-selected-text text)))))
+ 'gui-set-selection "24.1")
+
(defun ns-copy-including-secondary ()
(interactive)
(call-interactively 'kill-ring-save)
- (ns-store-selection-internal 'SECONDARY
- (buffer-substring (point) (mark t))))
+ (gui-set-selection 'SECONDARY (buffer-substring (point) (mark t))))
+
(defun ns-paste-secondary ()
(interactive)
(insert (ns-get-selection-internal 'SECONDARY)))
;; Any display name is OK.
(add-to-list 'display-format-alist '(".*" . ns))
-(add-to-list 'handle-args-function-alist '(ns . x-handle-args))
-(add-to-list 'frame-creation-function-alist '(ns . x-create-frame-with-faces))
-(add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
-
+(gui-method-define handle-args-function ns #'x-handle-args)
+(gui-method-define frame-creation-function ns #'x-create-frame-with-faces)
+(gui-method-define window-system-initialization ns
+ #'ns-initialize-window-system)
+
+(gui-method-define gui-set-selection ns
+ (lambda (selection value)
+ (if value (ns-own-selection-internal selection value)
+ (ns-disown-selection-internal selection))))
+(gui-method-define gui-selection-owner-p ns #'ns-selection-owner-p)
+(gui-method-define gui-selection-exists-p ns #'ns-selection-exists-p)
+(gui-method-define gui-get-selection ns #'ns-get-selection)
(provide 'ns-win)