richedit: Directly get start and end of text on Ctrl-Home or Ctrl-End.

Previously it found the start or end by traversing the linked lists of
run, rows, paragraphs, and cells from the current position of the
cursors.  Clearly it is better to get the start or end directly to make
it a constant time operation.
This commit is contained in:
Dylan Smith 2009-02-07 13:20:31 -05:00 committed by Alexandre Julliard
parent c2c2c1117e
commit 71d797c55c
1 changed files with 9 additions and 19 deletions

View File

@ -1436,14 +1436,9 @@ static void ME_ArrowHome(ME_TextEditor *editor, ME_Cursor *pCursor)
static void ME_ArrowCtrlHome(ME_TextEditor *editor, ME_Cursor *pCursor)
{
ME_DisplayItem *pRow = ME_FindItemBack(pCursor->pRun, diTextStart);
if (pRow) {
ME_DisplayItem *pRun = ME_FindItemFwd(pRow, diRun);
if (pRun) {
pCursor->pRun = pRun;
pCursor->pRun = ME_FindItemFwd(editor->pBuffer->pFirst, diRun);
pCursor->nOffset = 0;
}
}
editor->bCaretAtEnd = FALSE;
}
static void ME_ArrowEnd(ME_TextEditor *editor, ME_Cursor *pCursor)
@ -1456,12 +1451,11 @@ static void ME_ArrowEnd(ME_TextEditor *editor, ME_Cursor *pCursor)
pRow = ME_FindItemFwd(pCursor->pRun, diStartRowOrParagraphOrEnd);
assert(pRow);
if (pRow->type == diStartRow) {
/* FIXME WTF was I thinking about here ? */
ME_DisplayItem *pRun = ME_FindItemFwd(pRow, diRun);
assert(pRun);
pCursor->pRun = pRun;
pCursor->nOffset = 0;
editor->bCaretAtEnd = 1;
editor->bCaretAtEnd = TRUE;
return;
}
pCursor->pRun = ME_FindItemBack(pRow, diRun);
@ -1472,12 +1466,8 @@ static void ME_ArrowEnd(ME_TextEditor *editor, ME_Cursor *pCursor)
static void ME_ArrowCtrlEnd(ME_TextEditor *editor, ME_Cursor *pCursor)
{
ME_DisplayItem *p = ME_FindItemFwd(pCursor->pRun, diTextEnd);
assert(p);
p = ME_FindItemBack(p, diRun);
assert(p);
assert(p->member.run.nFlags & MERF_ENDPARA);
pCursor->pRun = p;
pCursor->pRun = ME_FindItemBack(editor->pBuffer->pLast, diRun);
assert(pCursor->pRun->member.run.nFlags & MERF_ENDPARA);
pCursor->nOffset = 0;
editor->bCaretAtEnd = FALSE;
}