richedit: Simplified ME_UpdateSelectionLinkAttribute.
This commit is contained in:
parent
71d797c55c
commit
1ceb903f9d
@ -2034,39 +2034,23 @@ ME_FilterEvent(ME_TextEditor *editor, UINT msg, WPARAM* wParam, LPARAM* lParam)
|
|||||||
static void ME_UpdateSelectionLinkAttribute(ME_TextEditor *editor)
|
static void ME_UpdateSelectionLinkAttribute(ME_TextEditor *editor)
|
||||||
{
|
{
|
||||||
ME_DisplayItem *startPara, *endPara;
|
ME_DisplayItem *startPara, *endPara;
|
||||||
ME_DisplayItem * item;
|
ME_DisplayItem *prev_para;
|
||||||
ME_Cursor cursor;
|
|
||||||
int from, to;
|
int from, to;
|
||||||
|
|
||||||
ME_GetSelection(editor, &from, &to);
|
ME_GetSelection(editor, &from, &to);
|
||||||
if (from > to) from ^= to, to ^=from, from ^= to;
|
|
||||||
startPara = NULL; endPara = NULL;
|
|
||||||
|
|
||||||
/* Find paragraph previous to the one that contains start cursor */
|
/* Find paragraph previous to the one that contains start cursor */
|
||||||
ME_CursorFromCharOfs(editor, from, &cursor);
|
ME_RunOfsFromCharOfs(editor, from, &startPara, NULL, NULL);
|
||||||
item = cursor.pRun;
|
prev_para = startPara->member.para.prev_para;
|
||||||
if (item) {
|
if (prev_para->type == diParagraph) startPara = prev_para;
|
||||||
startPara = ME_FindItemBack(item, diParagraph);
|
|
||||||
item = startPara->member.para.prev_para;
|
|
||||||
if (item && item->type == diParagraph) startPara = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find paragraph that contains end cursor */
|
/* Find paragraph that contains end cursor */
|
||||||
ME_CursorFromCharOfs(editor, to, &cursor);
|
ME_RunOfsFromCharOfs(editor, to, &endPara, NULL, NULL);
|
||||||
item = cursor.pRun;
|
endPara = endPara->member.para.next_para;
|
||||||
if (item) {
|
|
||||||
endPara = ME_FindItemFwd(item, diParagraph);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (startPara && endPara) {
|
|
||||||
ME_UpdateLinkAttribute(editor,
|
ME_UpdateLinkAttribute(editor,
|
||||||
startPara->member.para.nCharOfs,
|
startPara->member.para.nCharOfs,
|
||||||
endPara->member.para.nCharOfs);
|
endPara->member.para.nCharOfs);
|
||||||
} else if (startPara) {
|
|
||||||
ME_UpdateLinkAttribute(editor,
|
|
||||||
startPara->member.para.nCharOfs,
|
|
||||||
-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user