Data chunking. Feature complete.

This commit is contained in:
jaynus 2015-05-02 15:28:40 -07:00
parent 8d92d9cc7d
commit 717d7c874f
3 changed files with 64 additions and 24 deletions

Binary file not shown.

View File

@ -59,6 +59,22 @@ class %1 {
};
} forEach EGVAR(common,settings);
"ace_clipboard" callExtension format["%1",_compiledConfig];
FUNC(clipboardExport) = {
private["_chunks"];
_chunks = [];
_chunks = [_this select 0, ";"] call CBA_fnc_split;
{
private["_chunk"];
_chunk = _x + ";";
"ace_clipboard" callExtension format["%1", _chunk];
} forEach _chunks;
"ace_clipboard" callExtension "--COMPLETE--";
};
[_compiledConfig] call FUNC(clipboardExport);
["STR_ACE_OptionsMenu_settingsExported"] call EFUNC(common,displayTextStructured);

View File

@ -17,11 +17,13 @@ extern "C" {
__declspec (dllexport) void __stdcall RVExtension(char *output, int outputSize, const char *function);
};
std::string gClipboardData;
void __stdcall RVExtension(char *output, int outputSize, const char *function) {
std::string input(function);
std::string cur_input(function);
std::string result;
if (input.length() < 1)
if (cur_input.length() < 1)
return;
if (!strcmp(function, "version")) {
@ -29,32 +31,54 @@ void __stdcall RVExtension(char *output, int outputSize, const char *function) {
return;
}
#ifdef _WIN32
#ifdef _WIN32
HGLOBAL glob = GlobalAlloc(GMEM_FIXED, input.length()+1);
if (!strcmp(function, "--COMPLETE--")) {
HGLOBAL hClipboardData = GlobalAlloc(GMEM_FIXED, gClipboardData.length() + 1);
if (!hClipboardData) {
result = "GlobalAlloc() failed, GetLastError=" + GetLastError();
gClipboardData = "";
return;
}
memcpy(glob, input.c_str(), input.length());
((char *)glob)[input.length() + 1] = 0x00;
char *pClipboardData = (char *)GlobalLock(hClipboardData);
if (!pClipboardData) {
result = "GlobalLock() failed, GetLastError=" + GetLastError();
gClipboardData = "";
return;
}
memcpy(pClipboardData, gClipboardData.c_str(), gClipboardData.length());
pClipboardData[gClipboardData.length() + 1] = 0x00;
if (!OpenClipboard(NULL)) {
result = "OpenClipboard() failed, GetLastError=" + GetLastError();
} else {
if (!EmptyClipboard()) {
GlobalUnlock(hClipboardData);
if (!OpenClipboard(NULL)) {
result = "OpenClipboard() failed, GetLastError=" + GetLastError();
} else {
if (!SetClipboardData(CF_TEXT, glob)) {
result = "SetClipboardData() failed, GetLastError=" + GetLastError();
} else {
if (!CloseClipboard()) {
result = "CloseClipboard() failed, GetLastError=" + GetLastError();
}
else {
if (!EmptyClipboard()) {
result = "OpenClipboard() failed, GetLastError=" + GetLastError();
}
else {
if (!SetClipboardData(CF_TEXT, hClipboardData)) {
result = "SetClipboardData() failed, GetLastError=" + GetLastError();
}
else {
if (!CloseClipboard()) {
result = "CloseClipboard() failed, GetLastError=" + GetLastError();
}
}
}
}
gClipboardData = "";
} else {
gClipboardData = gClipboardData + cur_input;
}
end:
if(result.length() > 1)
memcpy(output, result.c_str(), result.length()+1);
end:
if(result.length() > 1)
memcpy(output, result.c_str(), result.length()+1);
#endif