richedit: Respect manually added links when autourldetect is disabled.

EM_SETCHARFORMAT can be used to make text links.  Automatic URL
detection being enable would cause these links to be removed if the text
is not a URL, so this must be prevented.

Previously checks were made for AutoURLDetect_bEnable before calling
ME_UpdateSelectionLinkAttribute, or ME_UpdateLinkAttribute.  This is
more error prone than checking for this within the function, so one call
was missing this check.

ME_SetCursor also didn't respect this behaviour, since it wouldn't set
the cursor to the hand when hovering over a link without automatic URL
detection disabled.
This commit is contained in:
Dylan Smith 2009-03-09 03:01:00 -04:00 committed by Alexandre Julliard
parent 728a738a82
commit fdb3749138
1 changed files with 22 additions and 28 deletions

View File

@ -2040,6 +2040,8 @@ static void ME_UpdateSelectionLinkAttribute(ME_TextEditor *editor)
ME_DisplayItem *prev_para; ME_DisplayItem *prev_para;
int from, to; int from, to;
if (!editor->AutoURLDetect_bEnable) return;
ME_GetSelection(editor, &from, &to); ME_GetSelection(editor, &from, &to);
/* Find paragraph previous to the one that contains start cursor */ /* Find paragraph previous to the one that contains start cursor */
@ -2235,9 +2237,7 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
ME_CommitCoalescingUndo(editor); ME_CommitCoalescingUndo(editor);
SetCursor(NULL); SetCursor(NULL);
if (editor->AutoURLDetect_bEnable)
ME_UpdateSelectionLinkAttribute(editor); ME_UpdateSelectionLinkAttribute(editor);
ME_UpdateRepaint(editor); ME_UpdateRepaint(editor);
} }
return TRUE; return TRUE;
@ -2396,8 +2396,7 @@ static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode,
ITextHost_TxSetCursor(editor->texthost, NULL, FALSE); ITextHost_TxSetCursor(editor->texthost, NULL, FALSE);
} }
if (editor->AutoURLDetect_bEnable) ME_UpdateSelectionLinkAttribute(editor); ME_UpdateSelectionLinkAttribute(editor);
ME_UpdateRepaint(editor); ME_UpdateRepaint(editor);
} }
return 0; return 0;
@ -2517,15 +2516,13 @@ static BOOL ME_SetCursor(ME_TextEditor *editor)
} }
offset = ME_CharFromPos(editor, pt.x, pt.y, &isExact); offset = ME_CharFromPos(editor, pt.x, pt.y, &isExact);
if (isExact) if (isExact)
{
if (editor->AutoURLDetect_bEnable)
{ {
ME_Cursor cursor; ME_Cursor cursor;
ME_Run *run; ME_Run *run;
ME_CursorFromCharOfs(editor, offset, &cursor); ME_CursorFromCharOfs(editor, offset, &cursor);
run = &cursor.pRun->member.run; run = &cursor.pRun->member.run;
if (editor->AutoURLDetect_bEnable && if (run->style->fmt.dwMask & CFM_LINK &&
run->style->fmt.dwMask & CFM_LINK &&
run->style->fmt.dwEffects & CFE_LINK) run->style->fmt.dwEffects & CFE_LINK)
{ {
ITextHost_TxSetCursor(editor->texthost, ITextHost_TxSetCursor(editor->texthost,
@ -2533,7 +2530,7 @@ static BOOL ME_SetCursor(ME_TextEditor *editor)
FALSE); FALSE);
return TRUE; return TRUE;
} }
}
if (ME_IsSelection(editor)) if (ME_IsSelection(editor))
{ {
int selStart, selEnd; int selStart, selEnd;
@ -3234,11 +3231,9 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
if (bSelection) { if (bSelection) {
ME_ReleaseStyle(style); ME_ReleaseStyle(style);
if (editor->AutoURLDetect_bEnable)
ME_UpdateSelectionLinkAttribute(editor); ME_UpdateSelectionLinkAttribute(editor);
} else { } else {
len = 1; len = 1;
if (editor->AutoURLDetect_bEnable)
ME_UpdateLinkAttribute(editor, 0, -1); ME_UpdateLinkAttribute(editor, 0, -1);
} }
ME_CommitUndo(editor); ME_CommitUndo(editor);
@ -3433,7 +3428,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
ME_ClearTempStyle(editor); ME_ClearTempStyle(editor);
ME_EndToUnicode(unicode, wszText); ME_EndToUnicode(unicode, wszText);
ME_CommitUndo(editor); ME_CommitUndo(editor);
if (editor->AutoURLDetect_bEnable) ME_UpdateSelectionLinkAttribute(editor); ME_UpdateSelectionLinkAttribute(editor);
if (!wParam) if (!wParam)
ME_EmptyUndoStack(editor); ME_EmptyUndoStack(editor);
ME_UpdateRepaint(editor); ME_UpdateRepaint(editor);
@ -3501,10 +3496,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
} }
else else
TRACE("WM_SETTEXT - NULL\n"); TRACE("WM_SETTEXT - NULL\n");
if (editor->AutoURLDetect_bEnable)
{
ME_UpdateLinkAttribute(editor, 0, -1); ME_UpdateLinkAttribute(editor, 0, -1);
}
ME_SetSelection(editor, 0, 0); ME_SetSelection(editor, 0, 0);
editor->nModifyStep = 0; editor->nModifyStep = 0;
ME_CommitUndo(editor); ME_CommitUndo(editor);
@ -4850,6 +4842,8 @@ static BOOL ME_UpdateLinkAttribute(ME_TextEditor *editor, int sel_min, int sel_m
BOOL modified = FALSE; BOOL modified = FALSE;
int cMin, cMax; int cMin, cMax;
if (!editor->AutoURLDetect_bEnable) return FALSE;
if (sel_max == -1) sel_max = ME_GetTextLength(editor); if (sel_max == -1) sel_max = ME_GetTextLength(editor);
do do
{ {