]> code.delx.au - gnu-emacs/blobdiff - src/w16select.c
Merge latest Org fixes (commit 7524ef2).
[gnu-emacs] / src / w16select.c
index 994ad9e543fca8fd03a09176b7c241b04dda95aa..c92276b1d291400baefd8d6a4b20448bd1c76be0 100644 (file)
@@ -1,7 +1,6 @@
 /* 16-bit Windows Selection processing for emacs on MS-Windows
 
-Copyright (C) 1996, 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
- 2008, 2009, 2010  Free Software Foundation, Inc.
+Copyright (C) 1996-1997, 2001-2013 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -32,13 +31,12 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <dpmi.h>
 #include <go32.h>
 #include <sys/farptr.h>
-#include <setjmp.h>
 #include "lisp.h"
 #include "dispextern.h"        /* frame.h seems to want this */
 #include "frame.h"     /* Need this to get the X window of selected_frame */
 #include "blockinput.h"
-#include "buffer.h"
 #include "character.h"
+#include "buffer.h"
 #include "coding.h"
 #include "composite.h"
 
@@ -69,13 +67,6 @@ unsigned clipboard_compact (unsigned);
 
 Lisp_Object QCLIPBOARD, QPRIMARY;
 
-/* Coding system for communicating with other Windows programs via the
-   clipboard.  */
-static Lisp_Object Vselection_coding_system;
-
-/* Coding system for the next communicating with other Windows programs.  */
-static Lisp_Object Vnext_selection_coding_system;
-
 /* The segment address and the size of the buffer in low
    memory used to move data between us and WinOldAp module.  */
 static struct {
@@ -118,11 +109,11 @@ identify_winoldap_version (void)
                         <> 1700H: AL = Major version number
                                  AH = Minor version number */
   regs.x.ax = 0x1700;
-  __dpmi_int(0x2f, &regs);
+  __dpmi_int (0x2f, &regs);
   return regs.x.ax;
 }
 
-/* Open the clipboard, return non-zero if successfull.  */
+/* Open the clipboard, return non-zero if successful.  */
 unsigned
 open_clipboard (void)
 {
@@ -141,11 +132,11 @@ open_clipboard (void)
      Return Values   AX == 0: Clipboard already open
                        <> 0: Clipboard opened */
   regs.x.ax = 0x1701;
-  __dpmi_int(0x2f, &regs);
+  __dpmi_int (0x2f, &regs);
   return regs.x.ax;
 }
 
-/* Empty clipboard, return non-zero if successfull.  */
+/* Empty clipboard, return non-zero if successful.  */
 unsigned
 empty_clipboard (void)
 {
@@ -155,7 +146,7 @@ empty_clipboard (void)
      Return Values   AX == 0: Error occurred
                        <> 0: OK, Clipboard emptied */
   regs.x.ax = 0x1702;
-  __dpmi_int(0x2f, &regs);
+  __dpmi_int (0x2f, &regs);
   return regs.x.ax;
 }
 
@@ -215,7 +206,7 @@ free_xfer_buf (void)
     }
 }
 
-/* Copy data into the clipboard, return zero if successfull.  */
+/* Copy data into the clipboard, return zero if successful.  */
 unsigned
 set_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw)
 {
@@ -302,7 +293,7 @@ set_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw)
   regs.x.cx = truelen & 0xffff;
   regs.x.es = xbuf_addr >> 4;
   regs.x.bx = xbuf_addr & 15;
-  __dpmi_int(0x2f, &regs);
+  __dpmi_int (0x2f, &regs);
 
   free_xfer_buf ();
 
@@ -328,7 +319,7 @@ get_clipboard_data_size (unsigned Format)
                           the clipboard.  */
   regs.x.ax = 0x1704;
   regs.x.dx = Format;
-  __dpmi_int(0x2f, &regs);
+  __dpmi_int (0x2f, &regs);
   return ( (((unsigned)regs.x.dx) << 16) | regs.x.ax);
 }
 
@@ -361,7 +352,7 @@ get_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw)
   regs.x.dx = Format;
   regs.x.es = xbuf_addr >> 4;
   regs.x.bx = xbuf_addr & 15;
-  __dpmi_int(0x2f, &regs);
+  __dpmi_int (0x2f, &regs);
   if (regs.x.ax != 0)
     {
       unsigned char null_char = '\0';
@@ -413,7 +404,7 @@ get_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw)
   return (unsigned) (dp - (unsigned char *)Data - 1);
 }
 
-/* Close clipboard, return non-zero if successfull.  */
+/* Close clipboard, return non-zero if successful.  */
 unsigned
 close_clipboard (void)
 {
@@ -423,7 +414,7 @@ close_clipboard (void)
      Return Values   AX == 0: Error occurred
                         <> 0: OK */
   regs.x.ax = 0x1708;
-  __dpmi_int(0x2f, &regs);
+  __dpmi_int (0x2f, &regs);
   return regs.x.ax;
 }
 
@@ -440,7 +431,7 @@ clipboard_compact (unsigned Size)
   regs.x.ax = 0x1709;
   regs.x.si = Size >> 16;
   regs.x.cx = Size & 0xffff;
-  __dpmi_int(0x2f, &regs);
+  __dpmi_int (0x2f, &regs);
   return ((unsigned)regs.x.dx << 16) | regs.x.ax;
 }
 \f
@@ -468,7 +459,7 @@ DEFUN ("w16-set-clipboard-data", Fw16_set_clipboard_data, Sw16_set_clipboard_dat
   if ( !FRAME_MSDOS_P (XFRAME (frame)))
     goto done;
 
-  BLOCK_INPUT;
+  block_input ();
 
   if (!open_clipboard ())
     goto error;
@@ -501,7 +492,7 @@ DEFUN ("w16-set-clipboard-data", Fw16_set_clipboard_data, Sw16_set_clipboard_dat
 
       setup_coding_system (Fcheck_coding_system (coding_system), &coding);
       coding.dst_bytes = nbytes * 4;
-      coding.destination = (unsigned char *) xmalloc (coding.dst_bytes);
+      coding.destination = xmalloc (coding.dst_bytes);
       Vnext_selection_coding_system = Qnil;
       coding.mode |= CODING_MODE_LAST_BLOCK;
       dst = coding.destination;
@@ -529,7 +520,7 @@ DEFUN ("w16-set-clipboard-data", Fw16_set_clipboard_data, Sw16_set_clipboard_dat
 
  unblock:
   xfree (dst);
-  UNBLOCK_INPUT;
+  unblock_input ();
 
   /* Notify user if the text is too large to fit into DOS memory.
      (This will happen somewhere after 600K bytes (470K in DJGPP v1.x),
@@ -574,13 +565,13 @@ DEFUN ("w16-get-clipboard-data", Fw16_get_clipboard_data, Sw16_get_clipboard_dat
   if ( !FRAME_MSDOS_P (XFRAME (frame)))
     goto done;
 
-  BLOCK_INPUT;
+  block_input ();
 
   if (!open_clipboard ())
     goto unblock;
 
   if ((data_size = get_clipboard_data_size (CF_OEMTEXT)) == 0 ||
-      (htext = (unsigned char *)xmalloc (data_size)) == 0)
+      (htext = xmalloc (data_size)) == 0)
     goto closeclip;
 
   /* need to know final size after '\r' chars are removed because
@@ -635,7 +626,7 @@ DEFUN ("w16-get-clipboard-data", Fw16_get_clipboard_data, Sw16_get_clipboard_dat
   close_clipboard ();
 
  unblock:
-  UNBLOCK_INPUT;
+  unblock_input ();
 
  done:
 
@@ -645,14 +636,17 @@ DEFUN ("w16-get-clipboard-data", Fw16_get_clipboard_data, Sw16_get_clipboard_dat
 /* Support checking for a clipboard selection. */
 
 DEFUN ("x-selection-exists-p", Fx_selection_exists_p, Sx_selection_exists_p,
-       0, 1, 0,
-       doc: /* Whether there is an owner for the given X 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, since that's what X expects.)
-For convenience, the symbol nil is the same as `PRIMARY',
-and t is the same as `SECONDARY'.  */)
-  (Lisp_Object selection)
+       0, 2, 0,
+       doc: /* Whether there is an owner for the given X selection.
+SELECTION should be the name of the selection in question, typically
+one of the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.  (X expects
+these literal upper-case names.)  The symbol nil is the same as
+`PRIMARY', and t is the same as `SECONDARY'.
+
+TERMINAL should be a terminal object or a frame specifying the X
+server to query.  If omitted or nil, that stands for the selected
+frame's display, or the first available X display.  */)
+  (Lisp_Object selection, Lisp_Object terminal)
 {
   CHECK_SYMBOL (selection);
 
@@ -693,7 +687,7 @@ syms_of_win16select (void)
   defsubr (&Sw16_get_clipboard_data);
   defsubr (&Sx_selection_exists_p);
 
-  DEFVAR_LISP ("selection-coding-system", &Vselection_coding_system,
+  DEFVAR_LISP ("selection-coding-system", Vselection_coding_system,
               doc: /* Coding system for communicating with other programs.
 
 For MS-Windows and MS-DOS:
@@ -725,7 +719,7 @@ to control which data-type to request for receiving text.
 The default value is nil.  */);
   Vselection_coding_system = intern ("iso-latin-1-dos");
 
-  DEFVAR_LISP ("next-selection-coding-system", &Vnext_selection_coding_system,
+  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 (X Windows clients or MS Windows programs).  But, if this
@@ -738,4 +732,3 @@ After the communication, this variable is set to nil.  */);
 }
 
 #endif /* MSDOS */
-