/[emacs]/emacs/src/w32select.c
ViewVC logotype

Diff of /emacs/src/w32select.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.27 by lektu, Fri Sep 6 09:04:56 2002 UTC revision 1.28 by lektu, Mon Oct 14 11:01:49 2002 UTC
# Line 1  Line 1 
1  /* Selection processing for Emacs on the Microsoft W32 API.  /* Selection processing for Emacs on the Microsoft W32 API.
2     Copyright (C) 1993, 1994 Free Software Foundation.     Copyright (C) 1993, 1994 Free Software Foundation.
3      
4  This file is part of GNU Emacs.  This file is part of GNU Emacs.
5    
6  GNU Emacs is free software; you can redistribute it and/or modify  GNU Emacs is free software; you can redistribute it and/or modify
# Line 57  DEFUN ("w32-open-clipboard", Fw32_open_c Line 57  DEFUN ("w32-open-clipboard", Fw32_open_c
57       Lisp_Object frame;       Lisp_Object frame;
58  {  {
59    BOOL ok = FALSE;    BOOL ok = FALSE;
60      
61    if (!NILP (frame))    if (!NILP (frame))
62      CHECK_LIVE_FRAME (frame);      CHECK_LIVE_FRAME (frame);
63      
64    BLOCK_INPUT;    BLOCK_INPUT;
65      
66    ok = OpenClipboard ((!NILP (frame) && FRAME_W32_P (XFRAME (frame))) ? FRAME_W32_WINDOW (XFRAME (frame)) : NULL);    ok = OpenClipboard ((!NILP (frame) && FRAME_W32_P (XFRAME (frame))) ? FRAME_W32_WINDOW (XFRAME (frame)) : NULL);
67      
68    UNBLOCK_INPUT;    UNBLOCK_INPUT;
69      
70    return (ok ? frame : Qnil);    return (ok ? frame : Qnil);
71  }  }
72    
# Line 77  Assigns ownership of the clipboard to th Line 77  Assigns ownership of the clipboard to th
77       ()       ()
78  {  {
79    BOOL ok = FALSE;    BOOL ok = FALSE;
80      
81    BLOCK_INPUT;    BLOCK_INPUT;
82      
83    ok = EmptyClipboard ();    ok = EmptyClipboard ();
84      
85    UNBLOCK_INPUT;    UNBLOCK_INPUT;
86      
87    return (ok ? Qt : Qnil);    return (ok ? Qt : Qnil);
88  }  }
89    
# Line 93  DEFUN ("w32-close-clipboard", Fw32_close Line 93  DEFUN ("w32-close-clipboard", Fw32_close
93       ()       ()
94  {  {
95    BOOL ok = FALSE;    BOOL ok = FALSE;
96      
97    BLOCK_INPUT;    BLOCK_INPUT;
98      
99    ok = CloseClipboard ();    ok = CloseClipboard ();
100      
101    UNBLOCK_INPUT;    UNBLOCK_INPUT;
102      
103    return (ok ? Qt : Qnil);    return (ok ? Qt : Qnil);
104  }  }
105    
# Line 119  DEFUN ("w32-set-clipboard-data", Fw32_se Line 119  DEFUN ("w32-set-clipboard-data", Fw32_se
119    unsigned char *dst;    unsigned char *dst;
120    
121    CHECK_STRING (string);    CHECK_STRING (string);
122      
123    if (!NILP (frame))    if (!NILP (frame))
124      CHECK_LIVE_FRAME (frame);      CHECK_LIVE_FRAME (frame);
125      
126    BLOCK_INPUT;    BLOCK_INPUT;
127    
128    nbytes = SBYTES (string) + 1;    nbytes = SBYTES (string) + 1;
# Line 159  DEFUN ("w32-set-clipboard-data", Fw32_se Line 159  DEFUN ("w32-set-clipboard-data", Fw32_se
159    
160          if ((dst = (unsigned char *) GlobalLock (htext)) == NULL)          if ((dst = (unsigned char *) GlobalLock (htext)) == NULL)
161            goto error;            goto error;
162        
163          /* convert to CRLF line endings expected by clipboard */          /* convert to CRLF line endings expected by clipboard */
164          while (1)          while (1)
165            {            {
# Line 176  DEFUN ("w32-set-clipboard-data", Fw32_se Line 176  DEFUN ("w32-set-clipboard-data", Fw32_se
176                  next[-1] = '\r';                  next[-1] = '\r';
177                  next[0] = '\n';                  next[0] = '\n';
178                  dst = next + 1;                  dst = next + 1;
179                }                    }
180              else              else
181                /* copied remaining partial line -> now finished */                /* copied remaining partial line -> now finished */
182                break;                break;
183            }            }
184        
185          GlobalUnlock (htext);          GlobalUnlock (htext);
186    
187          Vlast_coding_system_used = Qraw_text;          Vlast_coding_system_used = Qraw_text;
# Line 237  DEFUN ("w32-set-clipboard-data", Fw32_se Line 237  DEFUN ("w32-set-clipboard-data", Fw32_se
237          if (htext2 != NULL) htext = htext2;          if (htext2 != NULL) htext = htext2;
238        }        }
239    }    }
240      
241    if (!OpenClipboard ((!NILP (frame) && FRAME_W32_P (XFRAME (frame))) ? FRAME_W32_WINDOW (XFRAME (frame)) : NULL))    if (!OpenClipboard ((!NILP (frame) && FRAME_W32_P (XFRAME (frame))) ? FRAME_W32_WINDOW (XFRAME (frame)) : NULL))
242      goto error;      goto error;
243    
244    ok = EmptyClipboard () && SetClipboardData (CF_TEXT, htext);    ok = EmptyClipboard () && SetClipboardData (CF_TEXT, htext);
245      
246    CloseClipboard ();    CloseClipboard ();
247      
248    if (ok) goto done;    if (ok) goto done;
249    
250   error:   error:
251      
252    ok = FALSE;    ok = FALSE;
253    if (htext) GlobalFree (htext);    if (htext) GlobalFree (htext);
254    if (last_clipboard_text)    if (last_clipboard_text)
# Line 256  DEFUN ("w32-set-clipboard-data", Fw32_se Line 256  DEFUN ("w32-set-clipboard-data", Fw32_se
256    
257   done:   done:
258    UNBLOCK_INPUT;    UNBLOCK_INPUT;
259      
260    return (ok ? string : Qnil);    return (ok ? string : Qnil);
261  }  }
262    
# Line 268  DEFUN ("w32-get-clipboard-data", Fw32_ge Line 268  DEFUN ("w32-get-clipboard-data", Fw32_ge
268  {  {
269    HANDLE htext;    HANDLE htext;
270    Lisp_Object ret = Qnil;    Lisp_Object ret = Qnil;
271      
272    if (!NILP (frame))    if (!NILP (frame))
273      CHECK_LIVE_FRAME (frame);      CHECK_LIVE_FRAME (frame);
274      
275    BLOCK_INPUT;    BLOCK_INPUT;
276      
277    if (!OpenClipboard ((!NILP (frame) && FRAME_W32_P (XFRAME (frame))) ? FRAME_W32_WINDOW (XFRAME (frame)) : NULL))    if (!OpenClipboard ((!NILP (frame) && FRAME_W32_P (XFRAME (frame))) ? FRAME_W32_WINDOW (XFRAME (frame)) : NULL))
278      goto done;      goto done;
279      
280    if ((htext = GetClipboardData (CF_TEXT)) == NULL)    if ((htext = GetClipboardData (CF_TEXT)) == NULL)
281      goto closeclip;      goto closeclip;
282    
# Line 286  DEFUN ("w32-get-clipboard-data", Fw32_ge Line 286  DEFUN ("w32-get-clipboard-data", Fw32_ge
286      int nbytes;      int nbytes;
287      int truelen;      int truelen;
288      int require_decoding = 0;      int require_decoding = 0;
289        
290      if ((src = (unsigned char *) GlobalLock (htext)) == NULL)      if ((src = (unsigned char *) GlobalLock (htext)) == NULL)
291        goto closeclip;        goto closeclip;
292        
293      nbytes = strlen (src);      nbytes = strlen (src);
294    
295      /* If the text in clipboard is identical to what we put there      /* If the text in clipboard is identical to what we put there
# Line 397  DEFUN ("w32-get-clipboard-data", Fw32_ge Line 397  DEFUN ("w32-get-clipboard-data", Fw32_ge
397    
398   closeclip:   closeclip:
399    CloseClipboard ();    CloseClipboard ();
400      
401   done:   done:
402    UNBLOCK_INPUT;    UNBLOCK_INPUT;
403      
404    return (ret);    return (ret);
405  }  }
406    
# Line 442  and t is the same as `SECONDARY'.  */) Line 442  and t is the same as `SECONDARY'.  */)
442    return Qnil;    return Qnil;
443  }  }
444    
445  void  void
446  syms_of_w32select ()  syms_of_w32select ()
447  {  {
448  #if 0  #if 0
# Line 457  syms_of_w32select () Line 457  syms_of_w32select ()
457    DEFVAR_LISP ("selection-coding-system", &Vselection_coding_system,    DEFVAR_LISP ("selection-coding-system", &Vselection_coding_system,
458                 doc: /* Coding system for communicating with other programs.                 doc: /* Coding system for communicating with other programs.
459  When sending or receiving text via cut_buffer, selection, and clipboard,  When sending or receiving text via cut_buffer, selection, and clipboard,
460  the text is encoded or decoded by this coding system.  */);  the text is encoded or decoded by this coding system.
461    Vselection_coding_system=intern ("iso-latin-1-dos");  The default value is `iso-latin-1-dos'.  */);
462      Vselection_coding_system = intern ("iso-latin-1-dos");
463    
464    DEFVAR_LISP ("next-selection-coding-system", &Vnext_selection_coding_system,    DEFVAR_LISP ("next-selection-coding-system", &Vnext_selection_coding_system,
465                 doc: /* Coding system for the next communication with other programs.                 doc: /* Coding system for the next communication with other programs.

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26