#include <Windows.h>#include <Windowsx.h>#include "wcommon.h"#include "stack-c.h"Include dependency graph for clipboard.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Functions | |
| BOOL | IsWindowInterface (void) |
| void | Callback_EMPTYCLIPBOARD (void) |
| void | Callback_MCOPY (void) |
| void | Callback_PASTE (void) |
| void | CreateThreadPaste (char *Text) |
| BOOL | IsReadyForAnewLign (void) |
| void | SetReadyOrNotForAnewLign (BOOL Ready) |
| DWORD WINAPI | SendInputText (LPVOID lpParam) |
| void | PasteFunction (LPTW lptw, BOOL special) |
| BOOL | IsEmptyClipboard (LPTW lptw) |
| void | TextCopyClip (LPTW lptw) |
| void | CleanClipboard (LPTW lptw) |
| char * | GetTextFromClipboard (LPTW lptw) |
| void | PutTextInClipboard (LPTW lptw, char *Text) |
| HANDLE | GetHandleThreadPaste (void) |
| BOOL | GetThreadPasteRunning (void) |
| void | SetThreadPasteRunning (BOOL Running) |
| void Callback_EMPTYCLIPBOARD | ( | void | ) |
Definition at line 620 of file wmenu.c.
Referenced by InterfaceWindowsClipboard(), and SendMacro().
00621 { 00622 LPTW lptw=GetTextWinScilab(); 00623 CleanClipboard(lptw); 00624 00625 }
Here is the caller graph for this function:

| void Callback_MCOPY | ( | void | ) |
Definition at line 315 of file wmenu.c.
Referenced by InterfaceWindowsClipboard(), and SendMacro().
00316 { 00317 LPTW lptw=GetTextWinScilab(); 00318 00319 if ( HasAZoneTextSelected(lptw) == TRUE )TextCopyClip (lptw); 00320 else 00321 { 00322 if (lptw->lpmw->CodeLanguage == 0) 00323 { 00324 MessageBox(lptw->hWndParent,MSG_SCIMSG40,MSG_SCIMSG42,MB_ICONINFORMATION); 00325 } 00326 else 00327 { 00328 MessageBox(lptw->hWndParent,MSG_SCIMSG41,MSG_SCIMSG42,MB_ICONINFORMATION); 00329 } 00330 } 00331 }
Here is the caller graph for this function:

| void Callback_PASTE | ( | void | ) |
Definition at line 333 of file wmenu.c.
Referenced by InterfaceWindowsClipboard(), and SendMacro().
00334 { 00335 LPTW lptw=GetTextWinScilab(); 00336 00337 if ( !IsEmptyClipboard(lptw) ) PasteFunction(lptw,FALSE); 00338 else 00339 { 00340 if (lptw->lpmw->CodeLanguage == 0) 00341 { 00342 MessageBox(lptw->hWndParent,MSG_SCIMSG43,MSG_SCIMSG42,MB_ICONINFORMATION); 00343 } 00344 else 00345 { 00346 MessageBox(lptw->hWndParent,MSG_SCIMSG44,MSG_SCIMSG42,MB_ICONINFORMATION); 00347 } 00348 } 00349 }
Here is the caller graph for this function:

| void CleanClipboard | ( | LPTW | lptw | ) |
Definition at line 276 of file clipboard.c.
00277 { 00278 if (ThreadPasteRunning) 00279 { 00280 SuspendThread(hThreadPaste); 00281 TerminateThread(hThreadPaste,1); 00282 ThreadPasteRunning=FALSE; 00283 CloseHandle( hThreadPaste ); 00284 } 00285 00286 OpenClipboard(lptw->hWndParent); 00287 EmptyClipboard(); 00288 CloseClipboard(); 00289 }
| void CreateThreadPaste | ( | char * | Text | ) |
Definition at line 28 of file clipboard.c.
00029 { 00030 DWORD IdThreadPaste; 00031 PasteForThread=(char*)MALLOC( (strlen(Text)+1)*sizeof(char)); 00032 strcpy(PasteForThread,Text); 00033 PasteForThread[strlen(PasteForThread)]='\0'; 00034 /* PasteForThread défini en global car passage via CreateThread plante sous Win98 */ 00035 hThreadPaste=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)SendInputText,NULL,0,(LPDWORD)&IdThreadPaste); 00036 00037 }
| HANDLE GetHandleThreadPaste | ( | void | ) |
| char* GetTextFromClipboard | ( | LPTW | lptw | ) |
Definition at line 847 of file clipboard.c.
References hdc, tagTW::hfont, tagTW::hWndText, MALLOC, NULL, TEXTMETRIC, TryToGetDC(), type, and UINT.
Referenced by InterfaceWindowsClipboard().
00848 { 00849 char *Text=NULL; 00850 00851 HDC hdc; 00852 HGLOBAL hGMem; 00853 TEXTMETRIC tm; 00854 UINT type; 00855 LPSTR lpMem; /* Pointeur sur la chaine du clipboard */ 00856 00857 00858 /* find out what type to get from clipboard */ 00859 hdc = (HDC)TryToGetDC (lptw->hWndText); 00860 SelectObject(hdc, lptw->hfont); 00861 GetTextMetrics(hdc,(TEXTMETRIC FAR *)&tm); 00862 if (tm.tmCharSet == OEM_CHARSET) type = CF_OEMTEXT; 00863 else type = CF_TEXT; 00864 ReleaseDC (lptw->hWndText, hdc); 00865 00866 /* now get it from clipboard */ 00867 OpenClipboard (lptw->hWndText); 00868 hGMem = GetClipboardData (type); 00869 00870 if (hGMem) 00871 { 00872 lpMem = GlobalLock( hGMem ); 00873 Text= (char*) MALLOC (sizeof(char)*(strlen(lpMem)+1)); 00874 strcpy(Text,lpMem); 00875 GlobalUnlock (hGMem); 00876 } 00877 CloseClipboard (); 00878 00879 return Text; 00880 }
Here is the call graph for this function:

Here is the caller graph for this function:

| BOOL GetThreadPasteRunning | ( | void | ) |
| BOOL IsEmptyClipboard | ( | LPTW | lptw | ) |
Definition at line 167 of file clipboard.c.
00169 { 00170 BOOL Retour=TRUE; 00171 HDC hdc; 00172 HGLOBAL hGMem; 00173 TEXTMETRIC tm; 00174 UINT type; 00175 LPSTR lpMem=NULL; /* Pointeur sur la chaine du clipboard */ 00176 00177 00178 /* find out what type to get from clipboard */ 00179 hdc = (HDC)TryToGetDC (lptw->hWndText); 00180 SelectObject(hdc, lptw->hfont); 00181 GetTextMetrics(hdc,(TEXTMETRIC FAR *)&tm); 00182 if (tm.tmCharSet == OEM_CHARSET) type = CF_OEMTEXT; 00183 else type = CF_TEXT; 00184 ReleaseDC (lptw->hWndText, hdc); 00185 00186 /* now get it from clipboard */ 00187 OpenClipboard (lptw->hWndText); 00188 hGMem = GetClipboardData (type); 00189 00190 if (hGMem) 00191 { 00192 lpMem = GlobalLock( hGMem ); 00193 if (lpMem==NULL) Retour=TRUE; 00194 else Retour=FALSE; 00195 GlobalUnlock (hGMem); 00196 } 00197 CloseClipboard (); 00198 00199 return Retour; 00200 }
| BOOL IsReadyForAnewLign | ( | void | ) |
| BOOL IsWindowInterface | ( | void | ) |
| void PasteFunction | ( | LPTW | lptw, | |
| BOOL | special | |||
| ) |
Definition at line 132 of file clipboard.c.
00138 { 00139 HDC hdc; 00140 HGLOBAL hGMem; 00141 TEXTMETRIC tm; 00142 UINT type; 00143 LPSTR lpMem; /* Pointeur sur la chaine du clipboard */ 00144 00145 SpecialPaste=special; 00146 /* find out what type to get from clipboard */ 00147 hdc = (HDC)TryToGetDC (lptw->hWndText); 00148 SelectObject(hdc, lptw->hfont); 00149 GetTextMetrics(hdc,(TEXTMETRIC FAR *)&tm); 00150 if (tm.tmCharSet == OEM_CHARSET) type = CF_OEMTEXT; 00151 else type = CF_TEXT; 00152 ReleaseDC (lptw->hWndText, hdc); 00153 00154 /* now get it from clipboard */ 00155 OpenClipboard (lptw->hWndText); 00156 hGMem = GetClipboardData (type); 00157 00158 if (hGMem) 00159 { 00160 lpMem = GlobalLock( hGMem ); 00161 if (!ThreadPasteRunning) SendMessage(lptw->hWndText, WM_SETTEXT, 0,(LPARAM) lpMem); 00162 GlobalUnlock (hGMem); 00163 } 00164 CloseClipboard (); 00165 }
| void PutTextInClipboard | ( | LPTW | lptw, | |
| char * | Text | |||
| ) |
Definition at line 882 of file clipboard.c.
References hdc, tagTW::hfont, tagTW::hWndParent, tagTW::hWndText, NULL, size, TEXTMETRIC, TryToGetDC(), type, and UINT.
Referenced by InterfaceWindowsClipboard().
00883 { 00884 int size; 00885 HGLOBAL hGMem; 00886 LPSTR cbuf; 00887 00888 TEXTMETRIC tm; 00889 UINT type; 00890 HDC hdc; 00891 00892 size=strlen(Text)+1; 00893 00894 hGMem = GlobalAlloc(GMEM_MOVEABLE, (DWORD)size); 00895 cbuf = (LPSTR)GlobalLock(hGMem); 00896 if (cbuf == (LPSTR)NULL) return; 00897 strcpy(cbuf,Text); 00898 00899 /* find out what type to put into clipboard */ 00900 hdc = (HDC)TryToGetDC(lptw->hWndText); 00901 SelectObject(hdc, lptw->hfont); 00902 GetTextMetrics(hdc,(TEXTMETRIC FAR *)&tm); 00903 if (tm.tmCharSet == OEM_CHARSET) 00904 type = CF_OEMTEXT; 00905 else 00906 type = CF_TEXT; 00907 ReleaseDC(lptw->hWndText, hdc); 00908 00909 /* give buffer to clipboard */ 00910 OpenClipboard(lptw->hWndParent); 00911 EmptyClipboard(); 00912 SetClipboardData(type, hGMem); 00913 CloseClipboard(); 00914 }
Here is the call graph for this function:

Here is the caller graph for this function:

| DWORD WINAPI SendInputText | ( | LPVOID | lpParam | ) |
Definition at line 49 of file clipboard.c.
00051 { 00052 #define TEMPOTOUCHE 1 00053 int lg=0; 00054 int i=0; 00055 00056 char *TextToSend=NULL; 00057 00058 LPTW lptw=GetTextWinScilab(); 00059 00060 ThreadPasteRunning=TRUE; 00061 00062 lg=strlen((char*)PasteForThread)+1; 00063 TextToSend=(char*)MALLOC(lg*sizeof(char)); 00064 strcpy(TextToSend,(char*)PasteForThread); 00065 TextToSend[strlen(TextToSend)]='\0'; 00066 00067 FREE(PasteForThread); 00068 PasteForThread=NULL; 00069 00070 //if (SpecialPaste==TRUE)CleanPromptFromText(TextToSend); /* Desactiver pour le moment */ 00071 00072 while ( C2F (ismenu) () == 1 ) {Sleep(TEMPOTOUCHE);} 00073 /* Il n'y a plus rien dans la queue des commandes */ 00074 while ( lptw->bGetCh == FALSE ) {Sleep(TEMPOTOUCHE);} 00075 /* Nous sommes au prompt */ 00076 00077 00078 lg=strlen(TextToSend); 00079 i=0; 00080 while(i<lg) 00081 { 00082 long count; 00083 00084 00085 count = lptw->KeyBufIn - lptw->KeyBufOut; 00086 00087 if (count < 0) count = count+lptw->KeyBufSize; 00088 if (count < (long) (lptw->KeyBufSize-1)) 00089 { 00090 if (TextToSend[i] == '\t') *lptw->KeyBufIn++ = ' '; 00091 else *lptw->KeyBufIn++ = TextToSend[i]; 00092 if (lptw->KeyBufIn - lptw->KeyBuf >= (signed)lptw->KeyBufSize) 00093 lptw->KeyBufIn = lptw->KeyBuf; /* wrap around */ 00094 } 00095 00096 if (TextToSend[i]==10) 00097 { 00098 /* LF not preceded by a CR */ 00099 /* fool it: turn LF into CR */ 00100 /* Bug 1960 corrected - Francois VOGEL June 2006 */ 00101 *lptw->KeyBufIn = 13; 00102 SetReadyOrNotForAnewLign(FALSE); 00103 while ( IsReadyForAnewLign() == FALSE ) {Sleep(TEMPOTOUCHE);} 00104 while ( C2F (ismenu) () == 1 ) {Sleep(TEMPOTOUCHE);} 00105 while ( lptw->bGetCh == FALSE ) {Sleep(TEMPOTOUCHE);} 00106 } 00107 if (TextToSend[i]==13) 00108 { 00109 SetReadyOrNotForAnewLign(FALSE); 00110 while ( IsReadyForAnewLign() == FALSE ) {Sleep(TEMPOTOUCHE);} 00111 while ( C2F (ismenu) () == 1 ) {Sleep(TEMPOTOUCHE);} 00112 while ( lptw->bGetCh == FALSE ) {Sleep(TEMPOTOUCHE);} 00113 if (i<lg-1) 00114 { 00115 /* skip LF that follows CR*/ 00116 if (TextToSend[i+1]==10) i++; 00117 } 00118 } 00119 i++; 00120 00121 } 00122 00123 00124 FREE(TextToSend); 00125 TextToSend=NULL; 00126 ThreadPasteRunning=FALSE; 00127 CloseHandle( hThreadPaste ); 00128 00129 return 0; 00130 }
| void SetReadyOrNotForAnewLign | ( | BOOL | Ready | ) |
| void SetThreadPasteRunning | ( | BOOL | Running | ) |
| void TextCopyClip | ( | LPTW | lptw | ) |
Definition at line 206 of file clipboard.c.
00207 { 00208 int size, count; 00209 HGLOBAL hGMem; 00210 LPSTR cbuf, cp; 00211 POINT pt, end; 00212 TEXTMETRIC tm; 00213 UINT type; 00214 HDC hdc; 00215 00216 if ((lptw->MarkBegin.x == lptw->MarkEnd.x) && 00217 (lptw->MarkBegin.y == lptw->MarkEnd.y) ) { 00218 /* copy user text */ 00219 return; 00220 } 00221 00222 size = (lptw->MarkEnd.y - lptw->MarkBegin.y + 1) 00223 * (lptw->ScreenSize.x + 2) + 1; 00224 hGMem = GlobalAlloc(GMEM_MOVEABLE, (DWORD)size); 00225 cbuf = cp = (LPSTR)GlobalLock(hGMem); 00226 if (cp == (LPSTR)NULL) 00227 return; 00228 00229 pt.x = lptw->MarkBegin.x; 00230 pt.y = lptw->MarkBegin.y; 00231 end.x = lptw->MarkEnd.x; 00232 end.y = lptw->MarkEnd.y; 00233 00234 while (pt.y < end.y) { 00235 /* copy to global buffer */ 00236 count = lptw->ScreenSize.x - pt.x; 00237 _fmemcpy(cp, lptw->ScreenBuffer + lptw->ScreenSize.x*pt.y+pt.x, count); 00238 /* remove trailing spaces */ 00239 for (count=count-1; count>=0; count--) { 00240 if (cp[count]!=' ') 00241 break; 00242 cp[count] = '\0'; 00243 } 00244 cp[++count] = '\r'; 00245 cp[++count] = '\n'; 00246 cp[++count] = '\0'; 00247 cp += count; 00248 pt.y++; 00249 pt.x=0; 00250 } 00251 /* partial line */ 00252 count = end.x - pt.x; 00253 if (end.y != lptw->ScreenSize.y) { 00254 _fmemcpy(cp, lptw->ScreenBuffer + lptw->ScreenSize.x*pt.y+pt.x, count); 00255 cp[count] = '\0'; 00256 } 00257 size = _fstrlen(cbuf) + 1; 00258 GlobalUnlock(hGMem); 00259 hGMem = GlobalReAlloc(hGMem, (DWORD)size, GMEM_MOVEABLE); 00260 /* find out what type to put into clipboard */ 00261 hdc = (HDC)TryToGetDC(lptw->hWndText); 00262 SelectObject(hdc, lptw->hfont); 00263 GetTextMetrics(hdc,(TEXTMETRIC FAR *)&tm); 00264 if (tm.tmCharSet == OEM_CHARSET) 00265 type = CF_OEMTEXT; 00266 else 00267 type = CF_TEXT; 00268 ReleaseDC(lptw->hWndText, hdc); 00269 /* give buffer to clipboard */ 00270 OpenClipboard(lptw->hWndParent); 00271 EmptyClipboard(); 00272 SetClipboardData(type, hGMem); 00273 CloseClipboard(); 00274 }
1.5.1