Commit 3d1d65bc authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

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

parent b05aa34f
...@@ -331,7 +331,7 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start, ...@@ -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 /* We aren't deleting anything in this run, so we will go back to the
* last run we are deleting text in. */ * 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; c.nOffset = c.pRun->member.run.len;
} }
run = &c.pRun->member.run; run = &c.pRun->member.run;
...@@ -1245,7 +1245,7 @@ ME_MoveCursorLines(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs) ...@@ -1245,7 +1245,7 @@ ME_MoveCursorLines(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs)
int x = ME_GetXForArrow(editor, pCursor); int x = ME_GetXForArrow(editor, pCursor);
if (editor->bCaretAtEnd && !pCursor->nOffset) if (editor->bCaretAtEnd && !pCursor->nOffset)
if (!ME_PrevRun(&pOldPara, &pRun)) if (!ME_PrevRun(&pOldPara, &pRun, TRUE))
return; return;
if (nRelOfs == -1) if (nRelOfs == -1)
......
...@@ -1863,7 +1863,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH ...@@ -1863,7 +1863,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
cursor.nOffset++; cursor.nOffset++;
if (cursor.nOffset == cursor.pRun->member.run.len) if (cursor.nOffset == cursor.pRun->member.run.len)
{ {
ME_NextRun(&cursor.pPara, &cursor.pRun); ME_NextRun(&cursor.pPara, &cursor.pRun, TRUE);
cursor.nOffset = 0; cursor.nOffset = 0;
} }
} }
...@@ -1889,7 +1889,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH ...@@ -1889,7 +1889,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
if (nCurEnd == 0) if (nCurEnd == 0)
{ {
ME_PrevRun(&pCurPara, &pCurItem); ME_PrevRun(&pCurPara, &pCurItem, TRUE);
nCurEnd = pCurItem->member.run.len; nCurEnd = pCurItem->member.run.len;
} }
...@@ -1938,7 +1938,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH ...@@ -1938,7 +1938,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
} }
if (nCurEnd - nMatched == 0) 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 /* Don't care about pCurItem becoming NULL here; it's already taken
* care of in the exterior loop condition */ * care of in the exterior loop condition */
nCurEnd = pCurItem->member.run.len + nMatched; nCurEnd = pCurItem->member.run.len + nMatched;
...@@ -1952,7 +1952,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH ...@@ -1952,7 +1952,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
cursor.nOffset--; cursor.nOffset--;
if (cursor.nOffset < 0) if (cursor.nOffset < 0)
{ {
ME_PrevRun(&cursor.pPara, &cursor.pRun); ME_PrevRun(&cursor.pPara, &cursor.pRun, TRUE);
cursor.nOffset = cursor.pRun->member.run.len; cursor.nOffset = cursor.pRun->member.run.len;
} }
} }
...@@ -5109,7 +5109,7 @@ static BOOL ME_FindNextURLCandidate(ME_TextEditor *editor, ...@@ -5109,7 +5109,7 @@ static BOOL ME_FindNextURLCandidate(ME_TextEditor *editor,
} }
cursor.nOffset = 0; cursor.nOffset = 0;
if (!ME_NextRun(&cursor.pPara, &cursor.pRun)) if (!ME_NextRun(&cursor.pPara, &cursor.pRun, TRUE))
goto done; goto done;
} }
......
...@@ -88,8 +88,8 @@ void ME_CharFormatFromLogFont(HDC hDC, const LOGFONTW *lf, CHARFORMAT2W *fmt) DE ...@@ -88,8 +88,8 @@ void ME_CharFormatFromLogFont(HDC hDC, const LOGFONTW *lf, CHARFORMAT2W *fmt) DE
/* list.c */ /* list.c */
void ME_InsertBefore(ME_DisplayItem *diWhere, ME_DisplayItem *diWhat) DECLSPEC_HIDDEN; void ME_InsertBefore(ME_DisplayItem *diWhere, ME_DisplayItem *diWhat) DECLSPEC_HIDDEN;
void ME_Remove(ME_DisplayItem *diWhere) DECLSPEC_HIDDEN; void ME_Remove(ME_DisplayItem *diWhere) DECLSPEC_HIDDEN;
BOOL ME_NextRun(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) 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_FindItemBack(ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN;
ME_DisplayItem *ME_FindItemFwd(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; ME_DisplayItem *ME_FindItemBackOrHere(ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN;
......
...@@ -63,16 +63,18 @@ static BOOL ME_DITypesEqual(ME_DIType type, ME_DIType nTypeOrClass) ...@@ -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 /* Modifies run pointer to point to the next run.
* paragraph pointer if moving into the next paragraph. * 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. */ * 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; ME_DisplayItem *p = (*run)->next;
while (p->type != diTextEnd) while (p->type != diTextEnd)
{ {
if (p->type == diParagraph) { if (p->type == diParagraph) {
if (!all_para) return FALSE;
*para = p; *para = p;
} else if (p->type == diRun) { } else if (p->type == diRun) {
*run = p; *run = p;
...@@ -83,16 +85,18 @@ BOOL ME_NextRun(ME_DisplayItem **para, ME_DisplayItem **run) ...@@ -83,16 +85,18 @@ BOOL ME_NextRun(ME_DisplayItem **para, ME_DisplayItem **run)
return FALSE; return FALSE;
} }
/* Modifies run pointer to point to the previous run, and modify the /* Modifies run pointer to point to the previous run.
* paragraph pointer if moving into the previous paragraph. * 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. */ * 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; ME_DisplayItem *p = (*run)->prev;
while (p->type != diTextStart) while (p->type != diTextStart)
{ {
if (p->type == diParagraph) { if (p->type == diParagraph) {
if (!all_para) return FALSE;
if (p->member.para.prev_para->type == diParagraph) if (p->member.para.prev_para->type == diParagraph)
*para = p->member.para.prev_para; *para = p->member.para.prev_para;
} else if (p->type == diRun) { } else if (p->type == diRun) {
......
...@@ -364,7 +364,7 @@ ME_DisplayItem *ME_JoinParagraphs(ME_TextEditor *editor, ME_DisplayItem *tp, ...@@ -364,7 +364,7 @@ ME_DisplayItem *ME_JoinParagraphs(ME_TextEditor *editor, ME_DisplayItem *tp,
endCur.pRun = ME_FindItemFwd(pNext, diRun); endCur.pRun = ME_FindItemFwd(pNext, diRun);
endCur.nOffset = 0; endCur.nOffset = 0;
startCur = endCur; startCur = endCur;
ME_PrevRun(&startCur.pPara, &startCur.pRun); ME_PrevRun(&startCur.pPara, &startCur.pRun, TRUE);
ME_SetCharFormat(editor, &startCur, &endCur, &fmt); ME_SetCharFormat(editor, &startCur, &endCur, &fmt);
if (!editor->bEmulateVersion10) { /* v4.1 */ if (!editor->bEmulateVersion10) { /* v4.1 */
......
...@@ -981,7 +981,7 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream, ...@@ -981,7 +981,7 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
if (!ME_StreamOutPrint(pStream, "}")) if (!ME_StreamOutPrint(pStream, "}"))
return FALSE; 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)) if (!ME_StreamOutMove(pStream, "}\0", 2))
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