Module: wine Branch: master Commit: 3d1d65bc2c6e1c1ece15f4021fe289be3ce1775d URL: http://source.winehq.org/git/wine.git/?a=commit;h=3d1d65bc2c6e1c1ece15f4021f...
Author: Huw Davies huw@codeweavers.com Date: Mon Jul 4 08:43:22 2016 +0100
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
---
dlls/riched20/caret.c | 4 ++-- dlls/riched20/editor.c | 10 +++++----- dlls/riched20/editor.h | 4 ++-- dlls/riched20/list.c | 16 ++++++++++------ dlls/riched20/para.c | 2 +- dlls/riched20/writer.c | 2 +- 6 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index 177f303..170363a 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -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) diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index a07dd7f..81ef55d 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -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; }
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index e9d1e47..cc1654a 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -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; diff --git a/dlls/riched20/list.c b/dlls/riched20/list.c index c57e526..ce21c59 100644 --- a/dlls/riched20/list.c +++ b/dlls/riched20/list.c @@ -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) { diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c index 6721698..c762cf0 100644 --- a/dlls/riched20/para.c +++ b/dlls/riched20/para.c @@ -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 */ diff --git a/dlls/riched20/writer.c b/dlls/riched20/writer.c index f76d5a5..5d74a34 100644 --- a/dlls/riched20/writer.c +++ b/dlls/riched20/writer.c @@ -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;