Module: wine Branch: master Commit: 65feea4e5aae1e0674743f4816528f27d10efe7d URL: http://source.winehq.org/git/wine.git/?a=commit;h=65feea4e5aae1e0674743f4816...
Author: Huw Davies huw@codeweavers.com Date: Mon Jul 4 08:43:23 2016 +0100
riched20: Pass the correct range to the EN_LINK notification when the link is wrapped.
Signed-off-by: Huw Davies huw@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
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); }