Skip to content

Commit

Permalink
[ENHANCE] Improve clipboard History feature.
Browse files Browse the repository at this point in the history
- Notepad-plus svn trunk @ 752
  • Loading branch information
donho committed Apr 23, 2011
1 parent 1431283 commit af12eaf
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class ClipboardHistoryPanel : public DockingDlgInterface {
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);
Expand Down

0 comments on commit af12eaf

Please sign in to comment.