From 250ff58cd4dbf7d7fa911b28d92b47515b9bb606 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 15 Aug 2023 12:50:26 +0300 Subject: =?UTF-8?q?fixes=20#3632=20(NewStory:=20=D0=BC=D0=B5=D0=BD=D1=8F?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B2=D0=B8=D0=B4=20=D0=BA=D1=83=D1=80=D1=81?= =?UTF-8?q?=D0=BE=D1=80=D0=B0=20=D0=BF=D1=80=D0=B8=20=D0=BD=D0=B0=D0=B2?= =?UTF-8?q?=D0=B5=D0=B4=D0=B5=D0=BD=D0=B8=D0=B8=20=D0=BD=D0=B0=20=D1=81?= =?UTF-8?q?=D1=81=D1=8B=D0=BB=D0=BA=D1=83)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/NewStory/src/history_array.cpp | 36 +++++++++++++++++--------------- plugins/NewStory/src/history_array.h | 2 +- plugins/NewStory/src/history_control.cpp | 7 ++++++- 3 files changed, 26 insertions(+), 19 deletions(-) (limited to 'plugins/NewStory') 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); -- cgit v1.2.3