Commit fb30d61c authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

riched20: Use helper function rather than goto to return found position.

parent 1a537406
...@@ -889,6 +889,23 @@ static ME_DisplayItem* ME_FindPixelPosInTableRow(int x, int y, ...@@ -889,6 +889,23 @@ static ME_DisplayItem* ME_FindPixelPosInTableRow(int x, int y,
return para; return para;
} }
static BOOL ME_ReturnFoundPos(ME_TextEditor *editor, ME_DisplayItem *found,
ME_Cursor *result, int rx, BOOL isExact)
{
assert(found);
assert(found->type == diRun);
if ((found->member.run.nFlags & MERF_ENDPARA) || rx < 0)
rx = 0;
result->pRun = found;
result->nOffset = ME_CharFromPointCursor(editor, rx, &found->member.run);
if (editor->pCursors[0].nOffset == found->member.run.strText->nLen && rx)
{
result->pRun = ME_FindItemFwd(editor->pCursors[0].pRun, diRun);
result->nOffset = 0;
}
return isExact;
}
/* Finds the run and offset from the pixel position. /* Finds the run and offset from the pixel position.
* *
* x & y are pixel positions in virtual coordinates into the rich edit control, * x & y are pixel positions in virtual coordinates into the rich edit control,
...@@ -963,34 +980,21 @@ static BOOL ME_FindPixelPos(ME_TextEditor *editor, int x, int y, ...@@ -963,34 +980,21 @@ static BOOL ME_FindPixelPos(ME_TextEditor *editor, int x, int y,
case diRun: case diRun:
rx = x - p->member.run.pt.x; rx = x - p->member.run.pt.x;
if (rx < p->member.run.nWidth) if (rx < p->member.run.nWidth)
{ return ME_ReturnFoundPos(editor, p, result, rx, isExact);
found_here:
assert(p->type == diRun);
if ((p->member.run.nFlags & MERF_ENDPARA) || rx < 0)
rx = 0;
result->pRun = p;
result->nOffset = ME_CharFromPointCursor(editor, rx, &p->member.run);
if (editor->pCursors[0].nOffset == p->member.run.strText->nLen && rx)
{
result->pRun = ME_FindItemFwd(editor->pCursors[0].pRun, diRun);
result->nOffset = 0;
}
return isExact;
}
break; break;
case diStartRow: case diStartRow:
isExact = FALSE; isExact = FALSE;
p = ME_FindItemFwd(p, diRun); p = ME_FindItemFwd(p, diRun);
if (is_eol) *is_eol = 1; if (is_eol) *is_eol = 1;
rx = 0; /* FIXME not sure */ rx = 0; /* FIXME not sure */
goto found_here; return ME_ReturnFoundPos(editor, p, result, rx, isExact);
case diCell: case diCell:
case diParagraph: case diParagraph:
case diTextEnd: case diTextEnd:
isExact = FALSE; isExact = FALSE;
rx = 0; /* FIXME not sure */ rx = 0; /* FIXME not sure */
p = last; p = last;
goto found_here; return ME_ReturnFoundPos(editor, p, result, rx, isExact);
default: assert(0); default: assert(0);
} }
last = p; last = p;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment