Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/teraterm/teraterm/clipboar.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3896 - (hide annotations) (download) (as text)
Wed May 19 11:10:50 2010 UTC (13 years, 10 months ago) by doda
File MIME type: text/x-csrc
File size: 16254 byte(s)
変数宣言の間違いを修正

1 maya 3227 /* Tera Term
2     Copyright(C) 1994-1998 T. Teranishi
3     All rights reserved. */
4    
5     /* TERATERM.EXE, Clipboard routines */
6     #include "teraterm.h"
7     #include "tttypes.h"
8     #include "vtdisp.h"
9     #include <string.h>
10     #include <stdlib.h>
11     #include <stdio.h>
12 yutakapon 3635 #include <commctrl.h>
13 maya 3227
14     #include "ttwinman.h"
15     #include "ttcommon.h"
16    
17     #include "clipboar.h"
18     #include "tt_res.h"
19    
20     // for clipboard copy
21     static HGLOBAL CBCopyHandle = NULL;
22     static PCHAR CBCopyPtr = NULL;
23    
24 doda 3872 #define CB_BRACKET_NONE 0
25     #define CB_BRACKET_START 1
26     #define CB_BRACKET_END 2
27 maya 3227 // for clipboard paste
28     static HGLOBAL CBMemHandle = NULL;
29     static PCHAR CBMemPtr = NULL;
30     static LONG CBMemPtr2 = 0;
31     static BOOL CBAddCR = FALSE;
32 doda 3896 static int CBBracketed = CB_BRACKET_NONE;
33 maya 3227 static BYTE CBByte;
34     static BOOL CBRetrySend;
35     static BOOL CBRetryEcho;
36     static BOOL CBSendCR;
37     static BOOL CBDDE;
38    
39     static HFONT DlgClipboardFont;
40    
41     PCHAR CBOpen(LONG MemSize)
42     {
43 maya 3393 if (MemSize==0) {
44     return (NULL);
45     }
46     if (CBCopyHandle!=NULL) {
47     return (NULL);
48     }
49     CBCopyPtr = NULL;
50     CBCopyHandle = GlobalAlloc(GMEM_MOVEABLE, MemSize);
51     if (CBCopyHandle == NULL) {
52     MessageBeep(0);
53     }
54     else {
55     CBCopyPtr = GlobalLock(CBCopyHandle);
56     if (CBCopyPtr == NULL) {
57     GlobalFree(CBCopyHandle);
58     CBCopyHandle = NULL;
59     MessageBeep(0);
60     }
61     }
62     return (CBCopyPtr);
63 maya 3227 }
64    
65     void CBClose()
66     {
67 maya 3393 BOOL Empty;
68     if (CBCopyHandle==NULL) {
69     return;
70     }
71 maya 3227
72 maya 3393 Empty = FALSE;
73     if (CBCopyPtr!=NULL) {
74     Empty = (CBCopyPtr[0]==0);
75     }
76 maya 3227
77 maya 3393 GlobalUnlock(CBCopyHandle);
78     CBCopyPtr = NULL;
79 maya 3227
80 maya 3393 if (OpenClipboard(HVTWin)) {
81     EmptyClipboard();
82     if (! Empty) {
83     SetClipboardData(CF_TEXT, CBCopyHandle);
84     }
85     CloseClipboard();
86     }
87     CBCopyHandle = NULL;
88 maya 3227 }
89    
90 doda 3872 void CBStartPaste(HWND HWin, BOOL AddCR, BOOL Bracketed,
91 maya 3393 int BuffSize, PCHAR DataPtr, int DataSize)
92 maya 3227 //
93     // DataPtr and DataSize are used only for DDE
94     // For clipboard, BuffSize should be 0
95     // DataSize should be <= BuffSize
96     {
97 maya 3393 UINT Cf;
98 maya 3227
99 maya 3393 if (! cv.Ready) {
100     return;
101     }
102     if (TalkStatus!=IdTalkKeyb) {
103     return;
104     }
105 maya 3227
106 maya 3393 CBAddCR = AddCR;
107 doda 3872 if (Bracketed) {
108     CBBracketed = CB_BRACKET_START;
109     }
110 maya 3227
111 maya 3393 if (BuffSize==0) { // for clipboar
112     if (IsClipboardFormatAvailable(CF_TEXT)) {
113     Cf = CF_TEXT;
114     }
115     else if (IsClipboardFormatAvailable(CF_OEMTEXT)) {
116     Cf = CF_OEMTEXT;
117     }
118     else {
119     return;
120     }
121     }
122 maya 3227
123 maya 3393 CBMemHandle = NULL;
124     CBMemPtr = NULL;
125     CBMemPtr2 = 0;
126     CBDDE = FALSE;
127     if (BuffSize==0) { //clipboard
128     if (OpenClipboard(HWin)) {
129     CBMemHandle = GetClipboardData(Cf);
130     }
131     if (CBMemHandle!=NULL) {
132     TalkStatus=IdTalkCB;
133     }
134     }
135     else { // dde
136     CBMemHandle = GlobalAlloc(GHND,BuffSize);
137     if (CBMemHandle != NULL) {
138     CBDDE = TRUE;
139     CBMemPtr = GlobalLock(CBMemHandle);
140     if (CBMemPtr != NULL) {
141     memcpy(CBMemPtr,DataPtr,DataSize);
142     GlobalUnlock(CBMemHandle);
143     CBMemPtr=NULL;
144     TalkStatus=IdTalkCB;
145     }
146     }
147     }
148     CBRetrySend = FALSE;
149     CBRetryEcho = FALSE;
150     CBSendCR = FALSE;
151     if (TalkStatus != IdTalkCB) {
152     CBEndPaste();
153     }
154 maya 3227 }
155    
156     // �����������N���b�v�{�[�h������DDE�f�[�^���[�������������B
157     //
158     // CBMemHandle�n���h�����O���[�o�������������A�����������I�������������A
159     // �����N���b�v�{�[�h������DDE�f�[�^�������������������������i�j�����������\�������j�B
160     // �����A�f�[�^���� null-terminate �����������������O�����������������A�������f�[�^����
161     // �����������B
162     // (2006.11.6 yutaka)
163     void CBSend()
164     {
165 maya 3393 int c;
166     BOOL EndFlag;
167 doda 3688 static DWORD lastcr;
168 doda 3872 static char BracketStart[] = "\033[200~";
169     static char BracketEnd[] = "\033[201~";
170     static int BracketPtr = 0;
171 doda 3688 DWORD now;
172 maya 3227
173 maya 3393 if (CBMemHandle==NULL) {
174     return;
175     }
176 maya 3227
177 doda 3688 now = GetTickCount();
178 doda 3691 if (now - lastcr < (DWORD)ts.PasteDelayPerLine) {
179 doda 3688 return;
180     }
181    
182 maya 3393 if (CBRetrySend) {
183     CBRetryEcho = (ts.LocalEcho>0);
184     c = CommTextOut(&cv,(PCHAR)&CBByte,1);
185     CBRetrySend = (c==0);
186     if (CBRetrySend) {
187     return;
188     }
189     }
190 maya 3227
191 maya 3393 if (CBRetryEcho) {
192     c = CommTextEcho(&cv,(PCHAR)&CBByte,1);
193     CBRetryEcho = (c==0);
194     if (CBRetryEcho) {
195     return;
196     }
197     }
198 maya 3227
199 maya 3393 CBMemPtr = GlobalLock(CBMemHandle);
200     if (CBMemPtr==NULL) {
201     return;
202     }
203 maya 3227
204 maya 3393 do {
205     if (CBSendCR && (CBMemPtr[CBMemPtr2]==0x0a)) {
206     CBMemPtr2++;
207     // added PasteDelayPerLine (2009.4.12 maya)
208 doda 3690 if (ts.PasteDelayPerLine > 0) {
209     lastcr = now;
210     CBSendCR = FALSE;
211     SetTimer(HVTWin, IdPasteDelayTimer, ts.PasteDelayPerLine, NULL);
212     break;
213     }
214 maya 3393 }
215    
216     EndFlag = (CBMemPtr[CBMemPtr2]==0);
217 doda 3872 if (CBBracketed == CB_BRACKET_START) {
218     CBByte = BracketStart[BracketPtr++];
219     if (BracketPtr >= sizeof(BracketStart) - 1) {
220     CBBracketed = CB_BRACKET_END;
221     BracketPtr = 0;
222     }
223     }
224     else if (! EndFlag) {
225 maya 3393 CBByte = CBMemPtr[CBMemPtr2];
226     CBMemPtr2++;
227 maya 3227 // Decoding characters which are encoded by MACRO
228     // to support NUL character sending
229     //
230     // [encoded character] --> [decoded character]
231     // 01 01 --> 00
232     // 01 02 --> 01
233 maya 3393 if (CBByte==0x01) { /* 0x01 from MACRO */
234     CBByte = CBMemPtr[CBMemPtr2];
235     CBMemPtr2++;
236     CBByte = CBByte - 1; // character just after 0x01
237     }
238     }
239     else if (CBAddCR) {
240     EndFlag = FALSE;
241     CBAddCR = FALSE;
242     CBByte = 0x0d;
243     }
244 doda 3872 else if (CBBracketed == CB_BRACKET_END) {
245     EndFlag = FALSE;
246     CBByte = BracketEnd[BracketPtr++];
247     if (BracketPtr >= sizeof(BracketEnd) - 1) {
248     CBBracketed = CB_BRACKET_NONE;
249     BracketPtr = 0;
250     }
251     }
252 maya 3393 else {
253     CBEndPaste();
254     return;
255     }
256 maya 3227
257 maya 3393 if (! EndFlag) {
258     c = CommTextOut(&cv,(PCHAR)&CBByte,1);
259     CBSendCR = (CBByte==0x0D);
260     CBRetrySend = (c==0);
261     if ((! CBRetrySend) &&
262     (ts.LocalEcho>0)) {
263     c = CommTextEcho(&cv,(PCHAR)&CBByte,1);
264     CBRetryEcho = (c==0);
265     }
266     }
267     else {
268     c=0;
269     }
270     }
271     while (c>0);
272 maya 3227
273 maya 3393 if (CBMemPtr!=NULL) {
274     GlobalUnlock(CBMemHandle);
275     CBMemPtr=NULL;
276     }
277 maya 3227 }
278    
279     void CBEndPaste()
280     {
281 maya 3393 TalkStatus = IdTalkKeyb;
282 maya 3227
283 maya 3393 if (CBMemHandle!=NULL) {
284     if (CBMemPtr!=NULL) {
285     GlobalUnlock(CBMemHandle);
286     }
287     if (CBDDE) {
288     GlobalFree(CBMemHandle);
289     }
290     }
291     if (!CBDDE) {
292     CloseClipboard();
293     }
294 maya 3227
295 maya 3393 CBDDE = FALSE;
296     CBMemHandle = NULL;
297     CBMemPtr = NULL;
298     CBMemPtr2 = 0;
299     CBAddCR = FALSE;
300 maya 3227 }
301    
302    
303     static char *ClipboardPtr = NULL;
304     static int PasteCanceled = 0;
305    
306     static LRESULT CALLBACK OnClipboardDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp)
307     {
308     LOGFONT logfont;
309     HFONT font;
310     char uimsg[MAX_UIMSG];
311     //char *p;
312     POINT p;
313     RECT rc_dsk, rc_dlg;
314     int dlg_height, dlg_width;
315     OSVERSIONINFO osvi;
316     static int ok2right, info2bottom, edit2ok, edit2info;
317     RECT rc_edit, rc_ok, rc_cancel, rc_info;
318 yutakapon 3635 // for status bar
319     static HWND hStatus = NULL;
320 maya 3641 static init_width, init_height;
321 maya 3227
322     switch (msg) {
323     case WM_INITDIALOG:
324     #if 0
325     for (p = ClipboardPtr; *p ; p++) {
326     char buf[20];
327     _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%02x ", *p);
328     OutputDebugString(buf);
329     }
330     #endif
331    
332     font = (HFONT)SendMessage(hDlgWnd, WM_GETFONT, 0, 0);
333     GetObject(font, sizeof(LOGFONT), &logfont);
334     if (get_lang_font("DLG_TAHOMA_FONT", hDlgWnd, &logfont, &DlgClipboardFont, ts.UILanguageFile)) {
335     SendDlgItemMessage(hDlgWnd, IDC_EDIT, WM_SETFONT, (WPARAM)DlgClipboardFont, MAKELPARAM(TRUE,0));
336     SendDlgItemMessage(hDlgWnd, IDC_CLIPBOARD_INFO, WM_SETFONT, (WPARAM)DlgClipboardFont, MAKELPARAM(TRUE,0));
337     SendDlgItemMessage(hDlgWnd, IDOK, WM_SETFONT, (WPARAM)DlgClipboardFont, MAKELPARAM(TRUE,0));
338     SendDlgItemMessage(hDlgWnd, IDCANCEL, WM_SETFONT, (WPARAM)DlgClipboardFont, MAKELPARAM(TRUE,0));
339     }
340     else {
341     DlgClipboardFont = NULL;
342     }
343    
344     GetWindowText(hDlgWnd, uimsg, sizeof(uimsg));
345     get_lang_msg("DLG_CLIPBOARD_TITLE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
346     SetWindowText(hDlgWnd, ts.UIMsg);
347     GetDlgItemText(hDlgWnd, IDC_CLIPBOARD_INFO, uimsg, sizeof(uimsg));
348     get_lang_msg("DLG_CLIPBOARD_INFO", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
349     SetDlgItemText(hDlgWnd, IDC_CLIPBOARD_INFO, ts.UIMsg);
350     GetDlgItemText(hDlgWnd, IDCANCEL, uimsg, sizeof(uimsg));
351     get_lang_msg("BTN_CANCEL", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
352     SetDlgItemText(hDlgWnd, IDCANCEL, ts.UIMsg);
353     GetDlgItemText(hDlgWnd, IDOK, uimsg, sizeof(uimsg));
354     get_lang_msg("BTN_OK", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
355     SetDlgItemText(hDlgWnd, IDOK, ts.UIMsg);
356    
357     SendMessage(GetDlgItem(hDlgWnd, IDC_EDIT), WM_SETTEXT, 0, (LPARAM)ClipboardPtr);
358    
359     DispConvScreenToWin(CursorX, CursorY, &p.x, &p.y);
360     ClientToScreen(HVTWin, &p);
361    
362     // �L�����b�g���������������o���������������\���t����������
363     // �m�F�E�C���h�E�����������������\���������������������B
364     // �E�C���h�E���������o������������������ (2008.4.24 maya)
365     osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
366     GetVersionEx(&osvi);
367 maya 3509 if ( (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion == 4) ||
368     (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS && osvi.dwMinorVersion < 10) ) {
369     // NT4.0, 95 ���}���`���j�^API��������
370 maya 3227 SystemParametersInfo(SPI_GETWORKAREA, 0, &rc_dsk, 0);
371     }
372     else {
373     HMONITOR hm;
374     POINT pt;
375     MONITORINFO mi;
376    
377     pt.x = p.x;
378     pt.y = p.y;
379     hm = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST);
380    
381     mi.cbSize = sizeof(MONITORINFO);
382     GetMonitorInfo(hm, &mi);
383     rc_dsk = mi.rcWork;
384     }
385     GetWindowRect(hDlgWnd, &rc_dlg);
386     dlg_height = rc_dlg.bottom-rc_dlg.top;
387     dlg_width = rc_dlg.right-rc_dlg.left;
388     if (p.y < rc_dsk.top) {
389     p.y = rc_dsk.top;
390     }
391     else if (p.y + dlg_height > rc_dsk.bottom) {
392     p.y = rc_dsk.bottom - dlg_height;
393     }
394     if (p.x < rc_dsk.left) {
395     p.x = rc_dsk.left;
396     }
397     else if (p.x + dlg_width > rc_dsk.right) {
398     p.x = rc_dsk.right - dlg_width;
399     }
400    
401     SetWindowPos(hDlgWnd, NULL, p.x, p.y,
402     0, 0, SWP_NOSIZE | SWP_NOZORDER);
403    
404 maya 3641 // �_�C�A���O�������T�C�Y������
405     GetWindowRect(hDlgWnd, &rc_dlg);
406     init_width = rc_dlg.right - rc_dlg.left;
407     init_height = rc_dlg.bottom - rc_dlg.top;
408    
409 maya 3227 // �����T�C�Y�����K�v���l���v�Z
410     GetClientRect(hDlgWnd, &rc_dlg);
411     GetWindowRect(GetDlgItem(hDlgWnd, IDC_EDIT), &rc_edit);
412     GetWindowRect(GetDlgItem(hDlgWnd, IDOK), &rc_ok);
413     GetWindowRect(GetDlgItem(hDlgWnd, IDC_CLIPBOARD_INFO), &rc_info);
414    
415     p.x = rc_dlg.right;
416     p.y = rc_dlg.bottom;
417     ClientToScreen(hDlgWnd, &p);
418     ok2right = p.x - rc_ok.left;
419     info2bottom = p.y - rc_info.top;
420     edit2ok = rc_ok.left - rc_edit.right;
421     edit2info = rc_info.top - rc_edit.bottom;
422    
423     // �T�C�Y������
424     SetWindowPos(hDlgWnd, NULL, 0, 0,
425     ts.PasteDialogSize.cx, ts.PasteDialogSize.cy,
426     SWP_NOZORDER | SWP_NOMOVE);
427    
428 yutakapon 3635 // ���T�C�Y�A�C�R�����E�����\���������������A�X�e�[�^�X�o�[���t�����B
429     InitCommonControls();
430     hStatus = CreateStatusWindow(
431     WS_CHILD | WS_VISIBLE |
432     CCS_BOTTOM | SBARS_SIZEGRIP, NULL, hDlgWnd, 1);
433    
434 maya 3227 return TRUE;
435    
436     case WM_COMMAND:
437     switch (LOWORD(wp)) {
438     case IDOK:
439     {
440     int len = SendMessage(GetDlgItem(hDlgWnd, IDC_EDIT), WM_GETTEXTLENGTH, 0, 0);
441     HGLOBAL hMem;
442     char *buf;
443    
444     hMem = GlobalAlloc(GMEM_MOVEABLE, len + 1);
445     buf = GlobalLock(hMem);
446     SendMessage(GetDlgItem(hDlgWnd, IDC_EDIT), WM_GETTEXT, len + 1, (LPARAM)buf);
447     GlobalUnlock(hMem);
448    
449     EmptyClipboard();
450     SetClipboardData(CF_TEXT, hMem);
451    
452     // hMem���N���b�v�{�[�h�������������������A�j�����������������B
453    
454     if (DlgClipboardFont != NULL) {
455     DeleteObject(DlgClipboardFont);
456     }
457    
458 yutakapon 3635 DestroyWindow(hStatus);
459 maya 3227 EndDialog(hDlgWnd, IDOK);
460     }
461     break;
462    
463     case IDCANCEL:
464     PasteCanceled = 1;
465    
466     if (DlgClipboardFont != NULL) {
467     DeleteObject(DlgClipboardFont);
468     }
469    
470 yutakapon 3635 DestroyWindow(hStatus);
471 maya 3227 EndDialog(hDlgWnd, IDCANCEL);
472     break;
473    
474     default:
475     return FALSE;
476     }
477    
478     #if 0
479     case WM_CLOSE:
480     PasteCanceled = 1;
481     EndDialog(hDlgWnd, 0);
482     return TRUE;
483     #endif
484    
485     case WM_SIZE:
486     {
487     // ���z�u
488     POINT p;
489     int dlg_w, dlg_h;
490    
491     GetClientRect(hDlgWnd, &rc_dlg);
492     dlg_w = rc_dlg.right;
493     dlg_h = rc_dlg.bottom;
494    
495     GetWindowRect(GetDlgItem(hDlgWnd, IDC_EDIT), &rc_edit);
496     GetWindowRect(GetDlgItem(hDlgWnd, IDOK), &rc_ok);
497     GetWindowRect(GetDlgItem(hDlgWnd, IDCANCEL), &rc_cancel);
498     GetWindowRect(GetDlgItem(hDlgWnd, IDC_CLIPBOARD_INFO), &rc_info);
499    
500     // OK
501     p.x = rc_ok.left;
502     p.y = rc_ok.top;
503     ScreenToClient(hDlgWnd, &p);
504     SetWindowPos(GetDlgItem(hDlgWnd, IDOK), 0,
505     dlg_w - ok2right, p.y, 0, 0,
506     SWP_NOSIZE | SWP_NOZORDER);
507    
508     // CANCEL
509     p.x = rc_cancel.left;
510     p.y = rc_cancel.top;
511     ScreenToClient(hDlgWnd, &p);
512     SetWindowPos(GetDlgItem(hDlgWnd, IDCANCEL), 0,
513     dlg_w - ok2right, p.y, 0, 0,
514     SWP_NOSIZE | SWP_NOZORDER);
515    
516     // INFO
517     p.x = rc_info.left;
518     p.y = rc_info.top;
519     ScreenToClient(hDlgWnd, &p);
520     SetWindowPos(GetDlgItem(hDlgWnd, IDC_CLIPBOARD_INFO), 0,
521     p.x, dlg_h - info2bottom, 0, 0,
522     SWP_NOSIZE | SWP_NOZORDER);
523    
524     // EDIT
525     p.x = rc_edit.left;
526     p.y = rc_edit.top;
527     ScreenToClient(hDlgWnd, &p);
528     SetWindowPos(GetDlgItem(hDlgWnd, IDC_EDIT), 0,
529     0, 0, dlg_w - p.x - edit2ok - ok2right, dlg_h - p.y - edit2info - info2bottom,
530     SWP_NOMOVE | SWP_NOZORDER);
531    
532     // �T�C�Y������
533     GetWindowRect(hDlgWnd, &rc_dlg);
534     ts.PasteDialogSize.cx = rc_dlg.right - rc_dlg.left;
535     ts.PasteDialogSize.cy = rc_dlg.bottom - rc_dlg.top;
536 yutakapon 3635
537     // status bar
538     SendMessage(hStatus , msg , wp , lp);
539 maya 3227 }
540     return TRUE;
541    
542 maya 3641 case WM_GETMINMAXINFO:
543     {
544     // �_�C�A���O�������T�C�Y����������������������������
545     LPMINMAXINFO lpmmi;
546     lpmmi = (LPMINMAXINFO)lp;
547     lpmmi->ptMinTrackSize.x = init_width;
548     lpmmi->ptMinTrackSize.y = init_height;
549     }
550     return FALSE;
551    
552 maya 3227 default:
553     return FALSE;
554     }
555     return TRUE;
556     }
557    
558 yutakapon 3535 // �t�@�C�������`���������������Atext���������������������B
559     static int search_clipboard(char *filename, char *text)
560     {
561     int ret = 0; // no hit
562     FILE *fp = NULL;
563     char buf[256];
564     int len;
565    
566     if (filename == NULL || filename[0] == '\0')
567     goto error;
568    
569     fp = fopen(filename, "r");
570     if (fp == NULL)
571     goto error;
572    
573     // TODO: ���s��256byte�������������������l��
574     while (fgets(buf, sizeof(buf), fp) != NULL) {
575     len = strlen(buf);
576     if (buf[len - 1] == '\n')
577     buf[len - 1] = '\0';
578     if (buf[0] == '\0')
579     continue;
580     if (strstr(text, buf)) { // hit
581     ret = 1;
582     break;
583     }
584     }
585    
586     error:
587     if (fp)
588     fclose(fp);
589    
590     return (ret);
591     }
592    
593    
594 maya 3227 //
595     // �N���b�v�{�[�h�����s�R�[�h�����������������A�m�F�_�C�A���O���\�������B
596     // �N���b�v�{�[�h�����X�����\�B
597     //
598     // return 0: Cancel
599     // 1: Paste OK
600     //
601     // (2008.2.3 yutaka)
602     //
603     int CBStartPasteConfirmChange(HWND HWin)
604     {
605     UINT Cf;
606     HANDLE hText;
607     char *pText;
608     int pos;
609     int ret = 0;
610 yutakapon 3535 int confirm = 0;
611 maya 3227
612     if (ts.ConfirmChangePaste == 0)
613     return 1;
614    
615     if (! cv.Ready)
616     goto error;
617     if (TalkStatus!=IdTalkKeyb)
618     goto error;
619    
620     if (IsClipboardFormatAvailable(CF_TEXT))
621     Cf = CF_TEXT;
622     else if (IsClipboardFormatAvailable(CF_OEMTEXT))
623     Cf = CF_OEMTEXT;
624     else
625     goto error;
626    
627     if (!OpenClipboard(HWin))
628     goto error;
629    
630     hText = GetClipboardData(Cf);
631    
632     if (hText != NULL) {
633     pText = (char *)GlobalLock(hText);
634     pos = strcspn(pText, "\r\n"); // ���s����������������
635     if (pText[pos] != '\0') {
636 yutakapon 3535 confirm = 1;
637    
638     } else {
639     // �������T�[�`����
640     if (search_clipboard(ts.ConfirmChangePasteStringFile, pText)) {
641     confirm = 1;
642     }
643    
644     }
645    
646     if (confirm) {
647 maya 3227 ClipboardPtr = pText;
648     PasteCanceled = 0;
649     ret = DialogBox(hInst, MAKEINTRESOURCE(IDD_CLIPBOARD_DIALOG),
650     HVTWin, (DLGPROC)OnClipboardDlgProc);
651     if (ret == 0 || ret == -1) {
652     ret = GetLastError();
653     }
654    
655     if (PasteCanceled) {
656     ret = 0;
657     GlobalUnlock(hText);
658     CloseClipboard();
659     goto error;
660     }
661    
662     }
663    
664     ret = 1;
665    
666     GlobalUnlock(hText);
667     }
668    
669     CloseClipboard();
670    
671     error:
672     return (ret);
673     }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26