Making dflat32 a dll. Its a little broken ATM.
[reactos.git] / rosapps / lib / dflat32 / clipbord.c
1 /* ----------- clipbord.c ------------
2 * Clipbord funcations.
3 *
4 * sedwards
5 */
6 #include <dflat32\dflat.h>
7
8 char *Clipboard;
9 unsigned ClipboardLength;
10
11 void CopyTextToClipboard(char *text)
12 {
13 ClipboardLength = strlen(text);
14 Clipboard = DFrealloc(Clipboard, ClipboardLength);
15 memmove(Clipboard, text, ClipboardLength);
16 }
17
18 void CopyToClipboard(DFWINDOW wnd)
19 {
20 if (TextBlockMarked(wnd)) {
21 char *bbl=TextLine(wnd,wnd->BlkBegLine)+wnd->BlkBegCol;
22 char *bel=TextLine(wnd,wnd->BlkEndLine)+wnd->BlkEndCol;
23 ClipboardLength = (int) (bel - bbl);
24 Clipboard = DFrealloc(Clipboard, ClipboardLength);
25 memmove(Clipboard, bbl, ClipboardLength);
26 }
27 }
28
29 void ClearClipboard(void)
30 {
31 if (Clipboard != NULL) {
32 free(Clipboard);
33 Clipboard = NULL;
34 }
35 }
36
37
38 BOOL PasteText(DFWINDOW wnd, char *SaveTo, unsigned len)
39 {
40 if (SaveTo != NULL && len > 0) {
41 unsigned plen = strlen(wnd->text) + len;
42
43 if (plen <= wnd->MaxTextLength) {
44 if (plen+1 > wnd->textlen) {
45 wnd->text = DFrealloc(wnd->text, plen+3);
46 wnd->textlen = plen+1;
47 }
48 memmove(CurrChar+len, CurrChar, strlen(CurrChar)+1);
49 memmove(CurrChar, SaveTo, len);
50 BuildTextPointers(wnd);
51 wnd->TextChanged = TRUE;
52 return TRUE;
53 }
54 }
55 return FALSE;
56 }
57
58 /* EOF */