riched20: Add an option to constrain the run search to the current para.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2016-07-04 08:43:22 +01:00 committed by Alexandre Julliard
parent b05aa34f63
commit 3d1d65bc2c
6 changed files with 21 additions and 17 deletions

View File

@ -331,7 +331,7 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start,
{
/* We aren't deleting anything in this run, so we will go back to the
* last run we are deleting text in. */
ME_PrevRun(&c.pPara, &c.pRun);
ME_PrevRun(&c.pPara, &c.pRun, TRUE);
c.nOffset = c.pRun->member.run.len;
}
run = &c.pRun->member.run;
@ -1245,7 +1245,7 @@ ME_MoveCursorLines(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs)
int x = ME_GetXForArrow(editor, pCursor);
if (editor->bCaretAtEnd && !pCursor->nOffset)
if (!ME_PrevRun(&pOldPara, &pRun))
if (!ME_PrevRun(&pOldPara, &pRun, TRUE))
return;
if (nRelOfs == -1)

View File

@ -1863,7 +1863,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
cursor.nOffset++;
if (cursor.nOffset == cursor.pRun->member.run.len)
{
ME_NextRun(&cursor.pPara, &cursor.pRun);
ME_NextRun(&cursor.pPara, &cursor.pRun, TRUE);
cursor.nOffset = 0;
}
}
@ -1889,7 +1889,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
if (nCurEnd == 0)
{
ME_PrevRun(&pCurPara, &pCurItem);
ME_PrevRun(&pCurPara, &pCurItem, TRUE);
nCurEnd = pCurItem->member.run.len;
}
@ -1938,7 +1938,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
}
if (nCurEnd - nMatched == 0)
{
ME_PrevRun(&pCurPara, &pCurItem);
ME_PrevRun(&pCurPara, &pCurItem, TRUE);
/* Don't care about pCurItem becoming NULL here; it's already taken
* care of in the exterior loop condition */
nCurEnd = pCurItem->member.run.len + nMatched;
@ -1952,7 +1952,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
cursor.nOffset--;
if (cursor.nOffset < 0)
{
ME_PrevRun(&cursor.pPara, &cursor.pRun);
ME_PrevRun(&cursor.pPara, &cursor.pRun, TRUE);
cursor.nOffset = cursor.pRun->member.run.len;
}
}
@ -5109,7 +5109,7 @@ static BOOL ME_FindNextURLCandidate(ME_TextEditor *editor,
}
cursor.nOffset = 0;
if (!ME_NextRun(&cursor.pPara, &cursor.pRun))
if (!ME_NextRun(&cursor.pPara, &cursor.pRun, TRUE))
goto done;
}

View File

@ -88,8 +88,8 @@ void ME_CharFormatFromLogFont(HDC hDC, const LOGFONTW *lf, CHARFORMAT2W *fmt) DE
/* list.c */
void ME_InsertBefore(ME_DisplayItem *diWhere, ME_DisplayItem *diWhat) DECLSPEC_HIDDEN;
void ME_Remove(ME_DisplayItem *diWhere) DECLSPEC_HIDDEN;
BOOL ME_NextRun(ME_DisplayItem **para, ME_DisplayItem **run) DECLSPEC_HIDDEN;
BOOL ME_PrevRun(ME_DisplayItem **para, ME_DisplayItem **run) DECLSPEC_HIDDEN;
BOOL ME_NextRun(ME_DisplayItem **para, ME_DisplayItem **run, BOOL all_para) DECLSPEC_HIDDEN;
BOOL ME_PrevRun(ME_DisplayItem **para, ME_DisplayItem **run, BOOL all_para) DECLSPEC_HIDDEN;
ME_DisplayItem *ME_FindItemBack(ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN;
ME_DisplayItem *ME_FindItemFwd(ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN;
ME_DisplayItem *ME_FindItemBackOrHere(ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN;

View File

@ -63,16 +63,18 @@ static BOOL ME_DITypesEqual(ME_DIType type, ME_DIType nTypeOrClass)
}
}
/* Modifies run pointer to point to the next run, and modify the
* paragraph pointer if moving into the next paragraph.
/* Modifies run pointer to point to the next run.
* If all_para is FALSE constrain the search to the current para,
* otherwise modify the paragraph pointer if moving into the next paragraph.
*
* Returns TRUE if next run is found, otherwise returns FALSE. */
BOOL ME_NextRun(ME_DisplayItem **para, ME_DisplayItem **run)
BOOL ME_NextRun(ME_DisplayItem **para, ME_DisplayItem **run, BOOL all_para)
{
ME_DisplayItem *p = (*run)->next;
while (p->type != diTextEnd)
{
if (p->type == diParagraph) {
if (!all_para) return FALSE;
*para = p;
} else if (p->type == diRun) {
*run = p;
@ -83,16 +85,18 @@ BOOL ME_NextRun(ME_DisplayItem **para, ME_DisplayItem **run)
return FALSE;
}
/* Modifies run pointer to point to the previous run, and modify the
* paragraph pointer if moving into the previous paragraph.
/* Modifies run pointer to point to the previous run.
* If all_para is FALSE constrain the search to the current para,
* otherwise modify the paragraph pointer if moving into the previous paragraph.
*
* Returns TRUE if previous run is found, otherwise returns FALSE. */
BOOL ME_PrevRun(ME_DisplayItem **para, ME_DisplayItem **run)
BOOL ME_PrevRun(ME_DisplayItem **para, ME_DisplayItem **run, BOOL all_para)
{
ME_DisplayItem *p = (*run)->prev;
while (p->type != diTextStart)
{
if (p->type == diParagraph) {
if (!all_para) return FALSE;
if (p->member.para.prev_para->type == diParagraph)
*para = p->member.para.prev_para;
} else if (p->type == diRun) {

View File

@ -364,7 +364,7 @@ ME_DisplayItem *ME_JoinParagraphs(ME_TextEditor *editor, ME_DisplayItem *tp,
endCur.pRun = ME_FindItemFwd(pNext, diRun);
endCur.nOffset = 0;
startCur = endCur;
ME_PrevRun(&startCur.pPara, &startCur.pRun);
ME_PrevRun(&startCur.pPara, &startCur.pRun, TRUE);
ME_SetCharFormat(editor, &startCur, &endCur, &fmt);
if (!editor->bEmulateVersion10) { /* v4.1 */

View File

@ -981,7 +981,7 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
if (!ME_StreamOutPrint(pStream, "}"))
return FALSE;
}
} while (cursor.pRun != endCur.pRun && ME_NextRun(&cursor.pPara, &cursor.pRun));
} while (cursor.pRun != endCur.pRun && ME_NextRun(&cursor.pPara, &cursor.pRun, TRUE));
if (!ME_StreamOutMove(pStream, "}\0", 2))
return FALSE;