Commit 5dc422d4 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Simplify FindPixelPos().

parent eb9556bd
...@@ -1011,6 +1011,7 @@ static BOOL ME_FindPixelPos(ME_TextEditor *editor, int x, int y, ...@@ -1011,6 +1011,7 @@ static BOOL ME_FindPixelPos(ME_TextEditor *editor, int x, int y,
ME_Cursor *result, BOOL *is_eol, BOOL final_eop) ME_Cursor *result, BOOL *is_eol, BOOL final_eop)
{ {
ME_DisplayItem *p = editor->pBuffer->pFirst->member.para.next_para; ME_DisplayItem *p = editor->pBuffer->pFirst->member.para.next_para;
ME_DisplayItem *row = NULL;
BOOL isExact = TRUE; BOOL isExact = TRUE;
x -= editor->rcFormat.left; x -= editor->rcFormat.left;
...@@ -1022,42 +1023,40 @@ static BOOL ME_FindPixelPos(ME_TextEditor *editor, int x, int y, ...@@ -1022,42 +1023,40 @@ static BOOL ME_FindPixelPos(ME_TextEditor *editor, int x, int y,
/* find paragraph */ /* find paragraph */
for (; p != editor->pBuffer->pLast; p = p->member.para.next_para) for (; p != editor->pBuffer->pLast; p = p->member.para.next_para)
{ {
assert(p->type == diParagraph);
if (y < p->member.para.pt.y + p->member.para.nHeight) if (y < p->member.para.pt.y + p->member.para.nHeight)
{ {
if (p->member.para.nFlags & MEPF_ROWSTART) if (p->member.para.nFlags & MEPF_ROWSTART)
p = ME_FindPixelPosInTableRow(x, y, p); p = ME_FindPixelPosInTableRow(x, y, p);
y -= p->member.para.pt.y; y -= p->member.para.pt.y;
p = ME_FindItemFwd(p, diStartRow); row = ME_FindItemFwd(p, diStartRow);
break; break;
} else if (p->member.para.nFlags & MEPF_ROWSTART) { }
else if (p->member.para.nFlags & MEPF_ROWSTART)
{
p = ME_GetTableRowEnd(p); p = ME_GetTableRowEnd(p);
} }
} }
/* find row */ /* find row */
for (; p != editor->pBuffer->pLast; ) while (row)
{ {
ME_DisplayItem *pp; ME_DisplayItem *next_row;
assert(p->type == diStartRow);
if (y < p->member.row.pt.y + p->member.row.nHeight) break; if (y < row->member.row.pt.y + row->member.row.nHeight) break;
pp = ME_FindItemFwd(p, diStartRow); next_row = ME_FindItemFwd(row, diStartRow);
if (!pp) break; if (!next_row) break;
p = pp; row = next_row;
} }
if (p == editor->pBuffer->pLast && !final_eop)
if (!row && !final_eop)
{ {
/* The position is below the last paragraph, so the last row will be used /* The position is below the last paragraph, so the last row will be used
* rather than the end of the text, so the x position will be used to * rather than the end of the text, so the x position will be used to
* determine the offset closest to the pixel position. */ * determine the offset closest to the pixel position. */
isExact = FALSE; isExact = FALSE;
p = ME_FindItemBack(p, diStartRow); row = ME_FindItemBack(p, diStartRow);
if (!p) p = editor->pBuffer->pLast;
} }
assert( p->type == diStartRow || p == editor->pBuffer->pLast ); if (row) return ME_FindRunInRow( editor, row, x, result, is_eol ) && isExact;
if( p->type == diStartRow )
return ME_FindRunInRow( editor, p, x, result, is_eol ) && isExact;
ME_SetCursorToEnd(editor, result, TRUE); ME_SetCursorToEnd(editor, result, TRUE);
return FALSE; return FALSE;
......
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