[ENHANCE] Improve clipboard History feature.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@752 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2011-04-23 16:49:37 +00:00
parent d43b0a6ea0
commit 1de5e37a07
2 changed files with 38 additions and 1 deletions

View File

@ -122,10 +122,46 @@ StringArray::StringArray(ClipboardData cd, size_t maxLen)
}
}
int ClipboardHistoryPanel::getClipboardDataIndex(ClipboardData cbd)
{
int iFound = -1;
bool found = false;
for (size_t i = 0 ; i < _clipboardDataVector.size() ; i++)
{
if (cbd.size() == _clipboardDataVector[i].size())
{
for (size_t j = 0 ; j < cbd.size() ; j++)
{
if (cbd[j] == _clipboardDataVector[i][j])
found = true;
else
{
found = false;
break;
}
}
if (found)
{
iFound = i;
break;
}
}
}
return iFound;
}
void ClipboardHistoryPanel::addToClipboadHistory(ClipboardData cbd)
{
int i = getClipboardDataIndex(cbd);
if (i == 0) return;
if (i != -1)
{
_clipboardDataVector.erase(_clipboardDataVector.begin() + i);
::SendDlgItemMessage(_hSelf, IDC_LIST_CLIPBOARD, LB_DELETESTRING, i, 0);
}
_clipboardDataVector.insert(_clipboardDataVector.begin(), cbd);
//wstring s = clipboardDataToDisplayString(cbd);
StringArray sa(cbd, 64);
TCHAR *displayStr = (TCHAR *)sa.getPointer();
::SendDlgItemMessage(_hSelf, IDC_LIST_CLIPBOARD, LB_INSERTSTRING, 0, (LPARAM)displayStr);

View File

@ -75,6 +75,7 @@ public:
void switchEncoding();
ClipboardData getClipboadData();
void addToClipboadHistory(ClipboardData cbd);
int getClipboardDataIndex(ClipboardData cbd);
protected:
virtual BOOL CALLBACK ClipboardHistoryPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);