summaryrefslogtreecommitdiff
path: root/plugins/NewStory
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/NewStory')
-rw-r--r--plugins/NewStory/src/history_array.h2
-rw-r--r--plugins/NewStory/src/history_control.cpp57
-rw-r--r--plugins/NewStory/src/history_control.h10
-rw-r--r--plugins/NewStory/src/history_dlg.cpp22
-rw-r--r--plugins/NewStory/src/stdafx.h5
5 files changed, 61 insertions, 35 deletions
diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h
index 0957232be7..d3f523886b 100644
--- a/plugins/NewStory/src/history_array.h
+++ b/plugins/NewStory/src/history_array.h
@@ -68,7 +68,7 @@ public:
EVENTONLY = 0x100,
};
- __forceinline Filter(uint16_t aFlags, wchar_t *wText) :
+ __forceinline Filter(uint16_t aFlags, const wchar_t *wText) :
flags(aFlags),
text(mir_wstrdup(wText))
{
diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp
index b440f822ea..f2c2754a36 100644
--- a/plugins/NewStory/src/history_control.cpp
+++ b/plugins/NewStory/src/history_control.cpp
@@ -18,6 +18,12 @@ void InitHotkeys()
hkd.lParam = HOTKEY_BOOKMARK;
g_plugin.addHotkey(&hkd);
+ hkd.szDescription.a = LPGEN("Search");
+ hkd.pszName = "ns_search";
+ hkd.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL, 'S') | HKF_MIRANDA_LOCAL;
+ hkd.lParam = HOTKEY_SEARCH;
+ g_plugin.addHotkey(&hkd);
+
hkd.szDescription.a = LPGEN("Search forward");
hkd.pszName = "ns_seek_forward";
hkd.DefHotKey = HOTKEYCODE(0, VK_F3) | HKF_MIRANDA_LOCAL;
@@ -310,6 +316,32 @@ void NewstoryListData::EnsureVisible(int item)
FixScrollPosition();
}
+int NewstoryListData::FindNext(const wchar_t *pwszText)
+{
+ int idx = items.FindNext(caret, Filter(Filter::EVENTONLY, pwszText));
+ if (idx == -1 && caret > 0)
+ idx = items.FindNext(-1, Filter(Filter::EVENTONLY, pwszText));
+
+ if (idx >= 0) {
+ SetSelection(idx, idx);
+ SetCaret(idx);
+ }
+ return idx;
+}
+
+int NewstoryListData::FindPrev(const wchar_t *pwszText)
+{
+ int idx = items.FindPrev(caret, Filter(Filter::EVENTONLY, pwszText));
+ if (idx == -1 && caret != totalCount - 1)
+ idx = items.FindPrev(totalCount, Filter(Filter::EVENTONLY, pwszText));
+
+ if (idx >= 0) {
+ SetSelection(idx, idx);
+ SetCaret(idx);
+ }
+ return idx;
+}
+
void NewstoryListData::FixScrollPosition(bool bForce)
{
EndEditItem(false);
@@ -681,6 +713,9 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
case HOTKEY_SEEK_BACK:
PostMessage(GetParent(hwnd), WM_COMMAND, MAKELONG(IDC_FINDPREV, BN_CLICKED), 1);
break;
+ case HOTKEY_SEARCH:
+ PostMessage(GetParent(hwnd), WM_COMMAND, MAKELONG(IDC_SEARCH, BN_CLICKED), 1);
+ break;
case HOTKEY_BOOKMARK:
data->ToggleBookmark();
return 0;
@@ -708,28 +743,6 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
case NSM_GETCARET:
return data->caret;
- case NSM_FINDNEXT:
- idx = data->items.FindNext(data->caret, Filter(Filter::EVENTONLY, (wchar_t *)wParam));
- if (idx == -1 && data->caret > 0)
- idx = data->items.FindNext(-1, Filter(Filter::EVENTONLY, (wchar_t *)wParam));
-
- if (idx >= 0) {
- data->SetSelection(idx, idx);
- data->SetCaret(idx);
- }
- return idx;
-
- case NSM_FINDPREV:
- idx = data->items.FindPrev(data->caret, Filter(Filter::EVENTONLY, (wchar_t *)wParam));
- if (idx == -1 && data->caret != data->totalCount - 1)
- idx = data->items.FindPrev(data->totalCount, Filter(Filter::EVENTONLY, (wchar_t *)wParam));
-
- if (idx >= 0) {
- data->SetSelection(idx, idx);
- data->SetCaret(idx);
- }
- return idx;
-
case NSM_SEEKTIME:
{
int eventCount = data->totalCount;
diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h
index f98beed419..9081dfdd4c 100644
--- a/plugins/NewStory/src/history_control.h
+++ b/plugins/NewStory/src/history_control.h
@@ -15,14 +15,6 @@ enum
// result = id
NSM_GETCARET,
- // wParam = text
- NSM_FINDNEXT,
- NSM_FINDPREV,
-
- // wParam = wtext
- NSM_FINDNEXTW,
- NSM_FINDPREVW,
-
//
NSM_COPY,
NSM_EXPORT,
@@ -85,6 +77,8 @@ struct NewstoryListData : public MZeroedObject
void DeleteItems(void);
void EndEditItem(bool bAccept);
void EnsureVisible(int item);
+ int FindNext(const wchar_t *pwszText);
+ int FindPrev(const wchar_t *pwszText);
void FixScrollPosition(bool bForce = false);
ItemData* GetItem(int idx);
int GetItemFromPixel(int yPos);
diff --git a/plugins/NewStory/src/history_dlg.cpp b/plugins/NewStory/src/history_dlg.cpp
index db0e55c4dc..b06f408865 100644
--- a/plugins/NewStory/src/history_dlg.cpp
+++ b/plugins/NewStory/src/history_dlg.cpp
@@ -541,7 +541,15 @@ public:
DoGlobalSearch();
}
- m_histWindow.SendMsg(NSM_FINDNEXT, ptrW(edtSearchText.GetText()), 0);
+ int iOldCaret = m_histCtrl->caret;
+ int res = m_histCtrl->FindNext(ptrW(edtSearchText.GetText()));
+ if (res == -1)
+ SetWindowTextW(m_hwndStatus, TranslateT("No more occuurences found"));
+ else if (res < iOldCaret)
+ SetWindowTextW(m_hwndStatus, TranslateT("Passed the end of history"));
+ else
+ SetWindowTextW(m_hwndStatus, L"");
+
return false;
}
@@ -849,7 +857,14 @@ public:
void onClick_FindPrev(CCtrlButton *)
{
- m_histWindow.SendMsg(NSM_FINDPREV, ptrW(edtSearchText.GetText()), 0);
+ int iOldCaret = m_histCtrl->caret;
+ int res = m_histCtrl->FindPrev(ptrW(edtSearchText.GetText()));
+ if (res == -1)
+ SetWindowTextW(m_hwndStatus, TranslateT("No more occuurences found"));
+ else if (res > iOldCaret)
+ SetWindowTextW(m_hwndStatus, TranslateT("Passed the beginning of history"));
+ else
+ SetWindowTextW(m_hwndStatus, L"");
}
void onClick_Message(CCtrlButton *)
@@ -930,6 +945,9 @@ public:
case HOTKEY_SEEK_BACK:
btnFindPrev.Click();
break;
+ case HOTKEY_SEARCH:
+ btnSearch.Click();
+ break;
}
switch (msg) {
diff --git a/plugins/NewStory/src/stdafx.h b/plugins/NewStory/src/stdafx.h
index bcabaf8883..d9d8afab8d 100644
--- a/plugins/NewStory/src/stdafx.h
+++ b/plugins/NewStory/src/stdafx.h
@@ -84,8 +84,9 @@ int OptionsInitialize(WPARAM, LPARAM);
enum
{
HOTKEY_BOOKMARK = 1,
- HOTKEY_SEEK_FORWARD = 2,
- HOTKEY_SEEK_BACK = 3,
+ HOTKEY_SEARCH = 2,
+ HOTKEY_SEEK_FORWARD = 3,
+ HOTKEY_SEEK_BACK = 4,
};
struct CMPlugin : public PLUGIN<CMPlugin>