summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-08-15 12:50:26 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-08-15 12:50:26 +0300
commit250ff58cd4dbf7d7fa911b28d92b47515b9bb606 (patch)
tree455f6eaf024bb246cd5559b5031ce794306ebafa /plugins
parent0fc80f4ce48b9d28653703257f94e5f4f402dbb0 (diff)
fixes #3632 (NewStory: менять вид курсора при наведении на ссылку)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/NewStory/src/history_array.cpp36
-rw-r--r--plugins/NewStory/src/history_array.h2
-rw-r--r--plugins/NewStory/src/history_control.cpp7
3 files changed, 26 insertions, 19 deletions
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp
index 0db96c8b51..8dcfb98d7b 100644
--- a/plugins/NewStory/src/history_array.cpp
+++ b/plugins/NewStory/src/history_array.cpp
@@ -106,7 +106,7 @@ void ItemData::checkCreate(HWND hwnd)
}
}
-bool ItemData::isLink(POINT pt, CMStringW &url) const
+bool ItemData::isLink(POINT pt, CMStringW *pwszUrl) const
{
int cp = MTextSendMessage(0, data, EM_CHARFROMPOS, 0, LPARAM(&pt));
if (cp == -1)
@@ -115,25 +115,27 @@ bool ItemData::isLink(POINT pt, CMStringW &url) const
if (!isLinkChar(cp))
return false;
- CHARRANGE sel = { cp, cp };
- for (sel.cpMin = cp; sel.cpMin >= 0; sel.cpMin--)
- if (!isLinkChar(sel.cpMin))
- break;
+ if (pwszUrl) {
+ CHARRANGE sel = { cp, cp };
+ for (sel.cpMin = cp; sel.cpMin >= 0; sel.cpMin--)
+ if (!isLinkChar(sel.cpMin))
+ break;
- for (sel.cpMax = cp + 1; isLinkChar(sel.cpMax); sel.cpMax++)
- ;
+ for (sel.cpMax = cp + 1; isLinkChar(sel.cpMax); sel.cpMax++)
+ ;
- if (sel.cpMax > sel.cpMin) {
- url.Truncate(sel.cpMax - sel.cpMin + 1);
+ if (sel.cpMax > sel.cpMin) {
+ pwszUrl->Truncate(sel.cpMax - sel.cpMin + 1);
- TEXTRANGE tr = { 0 };
- tr.chrg = sel;
- tr.lpstrText = url.GetBuffer();
- int iRes = MTextSendMessage(0, data, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
- if (iRes > 0)
- url.Trim();
- else
- url.Empty();
+ TEXTRANGE tr = { 0 };
+ tr.chrg = sel;
+ tr.lpstrText = pwszUrl->GetBuffer();
+ int iRes = MTextSendMessage(0, data, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
+ if (iRes > 0)
+ pwszUrl->Trim();
+ else
+ pwszUrl->Empty();
+ }
}
return true;
}
diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h
index 263cd8dfdf..0957232be7 100644
--- a/plugins/NewStory/src/history_array.h
+++ b/plugins/NewStory/src/history_array.h
@@ -36,7 +36,7 @@ struct ItemData
void load(bool bFullLoad);
bool isEqual(const ItemData *p) const;
- bool isLink(POINT pt, CMStringW &url) const;
+ bool isLink(POINT pt, CMStringW *url = nullptr) const;
bool isLinkChar(int idx) const;
int getTemplate() const;
diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp
index badcc70562..7172ea0ae7 100644
--- a/plugins/NewStory/src/history_control.cpp
+++ b/plugins/NewStory/src/history_control.cpp
@@ -986,7 +986,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
pt.y -= pItem->savedTop;
CMStringW wszUrl;
- if (pItem->isLink(pt, wszUrl)) {
+ if (pItem->isLink(pt, &wszUrl)) {
Utils_OpenUrlW(wszUrl);
return 0;
}
@@ -1037,6 +1037,11 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
auto *pItem = data->LoadItem(idx);
MTextSendMessage(hwnd, pItem->data, msg, wParam, lParam);
+ HCURSOR hOldCursor = GetCursor();
+ HCURSOR hNewCursor = LoadCursor(0, (pItem->isLink(pt) || pItem->m_bOfflineFile) ? IDC_HAND : IDC_ARROW);
+ if (hOldCursor != hNewCursor)
+ SetCursor(hNewCursor);
+
if (data->selStart != -1) {
data->SetSelection(data->selStart, idx);
InvalidateRect(hwnd, 0, FALSE);