2000-03-05 19:58:08 +00:00
|
|
|
/* ----------- clipbord.c ------------ */
|
|
|
|
#include "dflat.h"
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
char *DfClipboard;
|
|
|
|
unsigned DfClipboardLength;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
void DfCopyTextToClipboard(char *text)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DfClipboardLength = strlen(text);
|
|
|
|
DfClipboard = DfRealloc(DfClipboard, DfClipboardLength);
|
|
|
|
memmove(DfClipboard, text, DfClipboardLength);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
void DfCopyToClipboard(DFWINDOW wnd)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfTextBlockMarked(wnd)) {
|
|
|
|
char *bbl=DfTextLine(wnd,wnd->BlkBegLine)+wnd->BlkBegCol;
|
|
|
|
char *bel=DfTextLine(wnd,wnd->BlkEndLine)+wnd->BlkEndCol;
|
|
|
|
DfClipboardLength = (int) (bel - bbl);
|
|
|
|
DfClipboard = DfRealloc(DfClipboard, DfClipboardLength);
|
|
|
|
memmove(DfClipboard, bbl, DfClipboardLength);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
void DfClearClipboard(void)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfClipboard != NULL) {
|
|
|
|
free(DfClipboard);
|
|
|
|
DfClipboard = NULL;
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
BOOL DfPasteText(DFWINDOW wnd, char *SaveTo, unsigned len)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
if (SaveTo != NULL && len > 0) {
|
|
|
|
unsigned plen = strlen(wnd->text) + len;
|
|
|
|
|
|
|
|
if (plen <= wnd->MaxTextLength) {
|
|
|
|
if (plen+1 > wnd->textlen) {
|
2003-06-19 02:48:13 +00:00
|
|
|
wnd->text = DfRealloc(wnd->text, plen+3);
|
2000-03-05 19:58:08 +00:00
|
|
|
wnd->textlen = plen+1;
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
memmove(DfCurrChar+len, DfCurrChar, strlen(DfCurrChar)+1);
|
|
|
|
memmove(DfCurrChar, SaveTo, len);
|
|
|
|
DfBuildTextPointers(wnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
wnd->TextChanged = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|