[PATCH 2/2] riched20: Pass the correct range to the EN_LINK notification when the link is wrapped.
Huw Davies
huw at codeweavers.com
Mon Jul 4 02:43:23 CDT 2016
Signed-off-by: Huw Davies <huw at codeweavers.com>
---
dlls/riched20/editor.c | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 81ef55d..13a2857 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -2627,6 +2627,11 @@ static int ME_CalculateClickCount(ME_TextEditor *editor, UINT msg, WPARAM wParam
return clickNum;
}
+static BOOL is_link( ME_Run *run )
+{
+ return (run->style->fmt.dwMask & CFM_LINK) && (run->style->fmt.dwEffects & CFE_LINK);
+}
+
static BOOL ME_SetCursor(ME_TextEditor *editor)
{
ME_Cursor cursor;
@@ -2692,8 +2697,7 @@ static BOOL ME_SetCursor(ME_TextEditor *editor)
ME_Run *run;
run = &cursor.pRun->member.run;
- if (run->style->fmt.dwMask & CFM_LINK &&
- run->style->fmt.dwEffects & CFE_LINK)
+ if (is_link( run ))
{
ITextHost_TxSetCursor(editor->texthost,
LoadCursorW(NULL, (WCHAR*)IDC_HAND),
@@ -3128,8 +3132,7 @@ static void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM
ME_CharFromPos(editor, x, y, &cursor, &isExact);
if (!isExact) return;
- if (cursor.pRun->member.run.style->fmt.dwMask & CFM_LINK &&
- cursor.pRun->member.run.style->fmt.dwEffects & CFE_LINK)
+ if (is_link( &cursor.pRun->member.run ))
{ /* The clicked run has CFE_LINK set */
ME_DisplayItem *di;
@@ -3143,21 +3146,15 @@ static void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM
/* find the first contiguous run with CFE_LINK set */
info.chrg.cpMin = ME_GetCursorOfs(&cursor);
- for (di = cursor.pRun->prev;
- di && di->type == diRun && (di->member.run.style->fmt.dwMask & CFM_LINK) && (di->member.run.style->fmt.dwEffects & CFE_LINK);
- di = di->prev)
- {
- info.chrg.cpMin -= di->member.run.len;
- }
+ di = cursor.pRun;
+ while (ME_PrevRun( NULL, &di, FALSE ) && is_link( &di->member.run ))
+ info.chrg.cpMin -= di->member.run.len;
/* find the last contiguous run with CFE_LINK set */
info.chrg.cpMax = ME_GetCursorOfs(&cursor) + cursor.pRun->member.run.len;
- for (di = cursor.pRun->next;
- di && di->type == diRun && (di->member.run.style->fmt.dwMask & CFM_LINK) && (di->member.run.style->fmt.dwEffects & CFE_LINK);
- di = di->next)
- {
- info.chrg.cpMax += di->member.run.len;
- }
+ di = cursor.pRun;
+ while (ME_NextRun( NULL, &di, FALSE ) && is_link( &di->member.run ))
+ info.chrg.cpMax += di->member.run.len;
ITextHost_TxNotify(editor->texthost, info.nmhdr.code, &info);
}
--
2.7.4
More information about the wine-patches
mailing list