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); } 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); ["STR_ACE_OptionsMenu_settingsExported"] call EFUNC(common,displayTextStructured);

View File

@ -17,44 +17,68 @@ extern "C" {
__declspec (dllexport) void __stdcall RVExtension(char *output, int outputSize, const char *function); __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) { void __stdcall RVExtension(char *output, int outputSize, const char *function) {
std::string input(function); std::string cur_input(function);
std::string result; std::string result;
if (input.length() < 1) if (cur_input.length() < 1)
return; return;
if (!strcmp(function, "version")) { if (!strcmp(function, "version")) {
strncpy(output, ACE_FULL_VERSION_STR, outputSize); strncpy(output, ACE_FULL_VERSION_STR, outputSize);
return; 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);
memcpy(glob, input.c_str(), input.length()); if (!hClipboardData) {
((char *)glob)[input.length() + 1] = 0x00; result = "GlobalAlloc() failed, GetLastError=" + GetLastError();
gClipboardData = "";
if (!OpenClipboard(NULL)) { return;
result = "OpenClipboard() failed, GetLastError=" + GetLastError(); }
} else {
if (!EmptyClipboard()) { 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;
GlobalUnlock(hClipboardData);
if (!OpenClipboard(NULL)) {
result = "OpenClipboard() failed, GetLastError=" + GetLastError(); result = "OpenClipboard() failed, GetLastError=" + GetLastError();
} else { }
if (!SetClipboardData(CF_TEXT, glob)) { else {
result = "SetClipboardData() failed, GetLastError=" + GetLastError(); if (!EmptyClipboard()) {
} else { result = "OpenClipboard() failed, GetLastError=" + GetLastError();
if (!CloseClipboard()) { }
result = "CloseClipboard() 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: end:
if(result.length() > 1) if(result.length() > 1)
memcpy(output, result.c_str(), result.length()+1); memcpy(output, result.c_str(), result.length()+1);
#endif #endif