summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/NewStory/src/history_control.cpp44
-rw-r--r--plugins/NewStory/src/history_control.h4
2 files changed, 43 insertions, 5 deletions
diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp
index f78c812209..30c674c451 100644
--- a/plugins/NewStory/src/history_control.cpp
+++ b/plugins/NewStory/src/history_control.cpp
@@ -704,7 +704,7 @@ void NewstoryListData::ToggleSelection(int iFirst, int iLast)
}
/////////////////////////////////////////////////////////////////////////////////////////
-// Navigation
+// Navigation by coordinates
void NewstoryListData::LineUp()
{
@@ -730,6 +730,40 @@ void NewstoryListData::PageDown()
ScrollDown(cachedWindowHeight);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// Navigation by events
+
+void NewstoryListData::EventUp()
+{
+ if (caret > 0)
+ SetPos(caret - 1);
+}
+
+void NewstoryListData::EventDown()
+{
+ if (caret < totalCount-1)
+ SetPos(caret + 1);
+}
+
+void NewstoryListData::EventPageUp()
+{
+ if (caret >= 10)
+ SetPos(caret - 10);
+ else
+ SetPos(0);
+}
+
+void NewstoryListData::EventPageDown()
+{
+ if (caret < totalCount - 10)
+ SetPos(caret + 10);
+ else
+ SetPos(totalCount - 1);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Common navigation functions
+
void NewstoryListData::ScrollBottom()
{
if (!totalCount)
@@ -1008,25 +1042,25 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
switch (wParam) {
case VK_UP:
- data->LineUp();
+ data->EventUp();
break;
case VK_DOWN:
- data->LineDown();
+ data->EventDown();
break;
case VK_PRIOR:
if (isCtrl)
data->ScrollTop();
else
- data->PageUp();
+ data->EventPageUp();
break;
case VK_NEXT:
if (isCtrl)
data->ScrollBottom();
else
- data->PageDown();
+ data->EventPageDown();
break;
case VK_HOME:
diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h
index b773c43c6b..7e0328532d 100644
--- a/plugins/NewStory/src/history_control.h
+++ b/plugins/NewStory/src/history_control.h
@@ -68,6 +68,10 @@ struct NewstoryListData : public MZeroedObject
void Download(int iOptions);
void EndEditItem(bool bAccept);
void EnsureVisible(int item);
+ void EventUp();
+ void EventDown();
+ void EventPageUp();
+ void EventPageDown();
int FindNext(const wchar_t *pwszText);
int FindPrev(const wchar_t *pwszText);
void FixScrollPosition(bool bForce = false);