/* NeXT/Open/GNUstep / MacOSX Cocoa selection processing for emacs.
- Copyright (C) 1993, 1994, 2005, 2006, 2008,
- Free Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 2005, 2006, 2008
+ Free Software Foundation, Inc.
This file is part of GNU Emacs.
-GNU Emacs is free software; you can redistribute it and/or modify
+GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.
+along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
+/*
Originally by Carl Edman
Updated by Christian Limpach (chris@nice.ch)
OpenStep/Rhapsody port by Scott Bender (sbender@harmony-ds.com)
MacOSX/Aqua port by Christophe de Dinechin (descubes@earthlink.net)
GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
-
*/
+/* This should be the first include, as it may set up #defines affecting
+ interpretation of even the system includes. */
#include "config.h"
+
#include "lisp.h"
#include "nsterm.h"
#include "termhooks.h"
static Lisp_Object Vselection_converter_alist;
/* 23: new */
-/* Coding system for communicating with other programs. */
-static Lisp_Object Vselection_coding_system;
-/* Coding system for the next communicating with other programs. */
-static Lisp_Object Vnext_selection_coding_system;
static Lisp_Object Qforeign_selection;
NSString *NXSecondaryPboard;
if (VECTORP (obj))
{
int i;
- int size = XVECTOR (obj)->size;
+ int size = ASIZE (obj);
Lisp_Object copy;
if (size == 1)
- return clean_local_selection_data (XVECTOR (obj)->contents [0]);
- copy = Fmake_vector (size, Qnil);
+ return clean_local_selection_data (AREF (obj, 0));
+ copy = Fmake_vector (make_number (size), Qnil);
for (i = 0; i < size; i++)
- XVECTOR (copy)->contents [i]
- = clean_local_selection_data (XVECTOR (obj)->contents [i]);
+ AREF (copy, i) = clean_local_selection_data (AREF (obj, i));
return copy;
}
CHECK_SYMBOL (target_type);
handler_fn = Fcdr (Fassq (target_type, Vselection_converter_alist));
if (!NILP (handler_fn))
- value =call3 (handler_fn, selection_name, target_type,
+ value = call3 (handler_fn, selection_name, target_type,
XCAR (XCDR (local_value)));
else
- value =Qnil;
+ value = Qnil;
unbind_to (count, Qnil);
- check =value;
+ check = value;
if (CONSP (value) && SYMBOLP (XCAR (value)))
{
type = XCAR (value);
&& NILP (XCDR (XCDR (check))))))
return value;
+ // FIXME: Why `quit' rather than `error'?
Fsignal (Qquit, Fcons (build_string (
"invalid data returned by selection-conversion function"),
Fcons (handler_fn, Fcons (value, Qnil))));
+ // FIXME: Beware, `quit' can return!!
+ return Qnil;
}
static void
ns_handle_selection_request (struct input_event *event)
{
- id pb =(id)event->x;
- NSString *type =(NSString *)event->y;
+ // FIXME: BIG UGLY HACK!!!
+ id pb = (id)*(EMACS_INT*)&(event->x);
+ NSString *type = (NSString *)*(EMACS_INT*)&(event->y);
Lisp_Object selection_name, selection_data, target_symbol, data;
Lisp_Object successful_p, rest;
- selection_name =ns_string_to_symbol ([(NSPasteboard *)pb name]);
- target_symbol =ns_string_to_symbol (type);
+ selection_name = ns_string_to_symbol ([(NSPasteboard *)pb name]);
+ target_symbol = ns_string_to_symbol (type);
selection_data = assq_no_quit (selection_name, Vselection_alist);
- successful_p =Qnil;
+ successful_p = Qnil;
if (!NILP (selection_data))
{
{
if (STRINGP (data))
ns_string_to_pasteboard_internal (pb, data, type);
- successful_p =Qt;
+ successful_p = Qt;
}
}
if (!EQ (Vns_sent_selection_hooks, Qunbound))
{
- for (rest =Vns_sent_selection_hooks;CONSP (rest); rest =Fcdr (rest))
+ for (rest = Vns_sent_selection_hooks; CONSP (rest); rest = Fcdr (rest))
call3 (Fcar (rest), selection_name, target_symbol, successful_p);
}
}
static void
ns_handle_selection_clear (struct input_event *event)
{
- id pb = (id)event->x;
+ id pb = (id)*(EMACS_INT*)&(event->x);
Lisp_Object selection_name, selection_data, rest;
- selection_name =ns_string_to_symbol ([(NSPasteboard *)pb name]);
- selection_data =assq_no_quit (selection_name, Vselection_alist);
+ selection_name = ns_string_to_symbol ([(NSPasteboard *)pb name]);
+ selection_data = assq_no_quit (selection_name, Vselection_alist);
if (NILP (selection_data)) return;
if (EQ (selection_data, Fcar (Vselection_alist)))
if (!EQ (Vns_lost_selection_hooks, Qunbound))
{
- for (rest =Vns_lost_selection_hooks;CONSP (rest); rest =Fcdr (rest))
+ for (rest = Vns_lost_selection_hooks;CONSP (rest); rest = Fcdr (rest))
call1 (Fcar (rest), selection_name);
}
}
DEFUN ("ns-own-selection-internal", Fns_own_selection_internal,
- Sns_own_selection_internal, 2, 2, 0, "Assert a selection.")
+ Sns_own_selection_internal, 2, 2, 0,
+ doc: /* Assert a selection.
+SELECTION-NAME is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.
+VALUE is typically a string, or a cons of two markers, but may be
+anything that the functions on `selection-converter-alist' know about. */)
(selection_name, selection_value)
Lisp_Object selection_name, selection_value;
{
error ("selection-value may not be nil.");
pb =[NSPasteboard pasteboardWithName: symbol_to_nsstring (selection_name)];
ns_declare_pasteboard (pb);
- old_value =assq_no_quit (selection_name, Vselection_alist);
+ old_value = assq_no_quit (selection_name, Vselection_alist);
new_value = Fcons (selection_name, Fcons (selection_value, Qnil));
if (NILP (old_value))
- Vselection_alist =Fcons (new_value, Vselection_alist);
+ Vselection_alist = Fcons (new_value, Vselection_alist);
else
Fsetcdr (old_value, Fcdr (new_value));
/* XXX An evil hack, but a necessary one I fear XXX */
ev.kind = SELECTION_REQUEST_EVENT;
ev.modifiers = 0;
ev.code = 0;
- ev.x = (int)pb;
- ev.y = (int)NSStringPboardType;
+ *(EMACS_INT*)(&(ev.x)) = (EMACS_INT)pb; // FIXME: BIG UGLY HACK!!
+ *(EMACS_INT*)(&(ev.y)) = (EMACS_INT)NSStringPboardType;
ns_handle_selection_request (&ev);
}
return selection_value;
}
-DEFUN ("ns-disown-selection-internal", Fns_disown_selection_internal,
- Sns_disown_selection_internal, 1, 2, 0,
- "If we own the selection SELECTION, disown it.")
+DEFUN ("x-disown-selection-internal", Fx_disown_selection_internal,
+ Sx_disown_selection_internal, 1, 2, 0,
+ doc: /* If we own the selection SELECTION, disown it. */)
(selection_name, time)
Lisp_Object selection_name, time;
{
DEFUN ("ns-selection-exists-p", Fns_selection_exists_p, Sns_selection_exists_p,
- 0, 1, 0, "Whether there is an owner for the given selection.\n\
-The arg should be the name of the selection in question, typically one of\n\
-the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.\n\
-\(Those are literal upper-case symbol names.)\n\
-For convenience, the symbol nil is the same as `PRIMARY',\n\
-and t is the same as `SECONDARY'.)")
+ 0, 1, 0, doc: /* Whether there is an owner for the given selection.
+The arg should be the name of the selection in question, typically one of
+the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.
+\(Those are literal upper-case symbol names.)
+For convenience, the symbol nil is the same as `PRIMARY',
+and t is the same as `SECONDARY'.) */)
(selection)
Lisp_Object selection;
{
DEFUN ("ns-selection-owner-p", Fns_selection_owner_p, Sns_selection_owner_p,
0, 1, 0,
- "Whether the current Emacs process owns the given selection.\n\
-The arg should be the name of the selection in question, typically one of\n\
-the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.\n\
-\(Those are literal upper-case symbol names.)\n\
-For convenience, the symbol nil is the same as `PRIMARY',\n\
-and t is the same as `SECONDARY'.)")
+ doc: /* Whether the current Emacs process owns the given selection.
+The arg should be the name of the selection in question, typically one of
+the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.
+\(Those are literal upper-case symbol names.)
+For convenience, the symbol nil is the same as `PRIMARY',
+and t is the same as `SECONDARY'.) */)
(selection)
Lisp_Object selection;
{
}
-DEFUN ("ns-get-selection-internal", Fns_get_selection_internal,
- Sns_get_selection_internal, 2, 2, 0,
- "Return text selected from some pasteboard.\n\
-SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.\n\
-\(Those are literal upper-case symbol names.)\n\
-TYPE is the type of data desired, typically `STRING'.")
+DEFUN ("x-get-selection-internal", Fx_get_selection_internal,
+ Sx_get_selection_internal, 2, 2, 0,
+ doc: /* Return text selected from some pasteboard.
+SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.
+\(Those are literal upper-case symbol names.)
+TYPE is the type of data desired, typically `STRING'. */)
(selection_name, target_type)
Lisp_Object selection_name, target_type;
{
#ifdef CUT_BUFFER_SUPPORT
DEFUN ("ns-get-cut-buffer-internal", Fns_get_cut_buffer_internal,
Sns_get_cut_buffer_internal, 1, 1, 0,
- "Returns the value of the named cut buffer.")
+ doc: /* Returns the value of the named cut buffer. */)
(buffer)
Lisp_Object buffer;
{
DEFUN ("ns-rotate-cut-buffers-internal", Fns_rotate_cut_buffers_internal,
Sns_rotate_cut_buffers_internal, 1, 1, 0,
- "Rotate the values of the cut buffers by the given number of steps;\n\
- positive means move values forward, negative means backward. CURRENTLY NOT IMPLEMENTED UNDER NeXTstep.")
+ doc: /* Rotate the values of the cut buffers by N steps.
+Positive N means move values forward, negative means
+backward. CURRENTLY NOT IMPLEMENTED UNDER NEXTSTEP. */ )
(n)
Lisp_Object n;
{
DEFUN ("ns-store-cut-buffer-internal", Fns_store_cut_buffer_internal,
Sns_store_cut_buffer_internal, 2, 2, 0,
- "Sets the value of the named cut buffer (typically CUT_BUFFER0).")
+ doc: /* Sets the value of the named cut buffer (typically CUT_BUFFER0). */)
(buffer, string)
Lisp_Object buffer, string;
{
QTEXT = intern ("TEXT"); staticpro (&QTEXT);
QFILE_NAME = intern ("FILE_NAME"); staticpro (&QFILE_NAME);
- defsubr (&Sns_disown_selection_internal);
- defsubr (&Sns_get_selection_internal);
+ defsubr (&Sx_disown_selection_internal);
+ defsubr (&Sx_get_selection_internal);
defsubr (&Sns_own_selection_internal);
defsubr (&Sns_selection_exists_p);
defsubr (&Sns_selection_owner_p);
Vns_lost_selection_hooks = Qnil;
/* 23: { */
- DEFVAR_LISP ("selection-coding-system", &Vselection_coding_system,
- doc: /* Coding system for communicating with other programs.
-When sending or receiving text via cut_buffer, selection, and clipboard,
-the text is encoded or decoded by this coding system.
-The default value is determined by the system script code. */);
- Vselection_coding_system = Qnil;
-
- DEFVAR_LISP ("next-selection-coding-system", &Vnext_selection_coding_system,
- doc: /* Coding system for the next communication with other programs.
-Usually, `selection-coding-system' is used for communicating with
-other programs. But, if this variable is set, it is used for the
-next communication only. After the communication, this variable is
-set to nil. */);
- Vnext_selection_coding_system = Qnil;
-
Qforeign_selection = intern ("foreign-selection");
staticpro (&Qforeign_selection);
/* } */
}
-/* arch-tag: 39d1dde7-06a6-49ff-95a7-0e7af12d2218
- (do not change this comment) */
+// arch-tag: 39d1dde7-06a6-49ff-95a7-0e7af12d2218