- new icons for all control panel applets.
[reactos.git] / rosapps / dflat32 / clipbord.c
1 /* ----------- clipbord.c ------------ */
2 #include "dflat.h"
3
4 char *DfClipboard;
5 unsigned DfClipboardLength;
6
7 void DfCopyTextToClipboard(char *text)
8 {
9 DfClipboardLength = strlen(text);
10 DfClipboard = DfRealloc(DfClipboard, DfClipboardLength);
11 memmove(DfClipboard, text, DfClipboardLength);
12 }
13
14 void DfCopyToClipboard(DFWINDOW wnd)
15 {
16 if (DfTextBlockMarked(wnd)) {
17 char *bbl=DfTextLine(wnd,wnd->BlkBegLine)+wnd->BlkBegCol;
18 char *bel=DfTextLine(wnd,wnd->BlkEndLine)+wnd->BlkEndCol;
19 DfClipboardLength = (int) (bel - bbl);
20 DfClipboard = DfRealloc(DfClipboard, DfClipboardLength);
21 memmove(DfClipboard, bbl, DfClipboardLength);
22 }
23 }
24
25 void DfClearClipboard(void)
26 {
27 if (DfClipboard != NULL) {
28 free(DfClipboard);
29 DfClipboard = NULL;
30 }
31 }
32
33
34 BOOL DfPasteText(DFWINDOW wnd, char *SaveTo, unsigned len)
35 {
36 if (SaveTo != NULL && len > 0) {
37 unsigned plen = strlen(wnd->text) + len;
38
39 if (plen <= wnd->MaxTextLength) {
40 if (plen+1 > wnd->textlen) {
41 wnd->text = DfRealloc(wnd->text, plen+3);
42 wnd->textlen = plen+1;
43 }
44 memmove(DfCurrChar+len, DfCurrChar, strlen(DfCurrChar)+1);
45 memmove(DfCurrChar, SaveTo, len);
46 DfBuildTextPointers(wnd);
47 wnd->TextChanged = TRUE;
48 return TRUE;
49 }
50 }
51 return FALSE;
52 }
53
54 /* EOF */