Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/riched20/editor.c | 2 +- dlls/riched20/editor.h | 5 ++- dlls/riched20/list.c | 45 ------------------------ dlls/riched20/run.c | 78 +++++++++++++++++++++++++++++++++++------- dlls/riched20/writer.c | 2 +- 5 files changed, 70 insertions(+), 62 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index b27bab48738..36918c9dd79 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -5423,7 +5423,7 @@ static BOOL ME_FindNextURLCandidate(ME_TextEditor *editor, }
cursor.nOffset = 0; - if (!ME_NextRun(&cursor.pPara, &cursor.pRun, TRUE)) + if (!cursor_next_run( &cursor, TRUE )) goto done; }
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index df8e9d2b829..d06fcef332f 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -67,8 +67,6 @@ 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, 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; @@ -126,7 +124,8 @@ static inline ME_DisplayItem *row_get_di( ME_Row *row )
/* run.c */ void cursor_from_char_ofs( ME_TextEditor *editor, int char_ofs, ME_Cursor *cursor ) DECLSPEC_HIDDEN; - +BOOL cursor_next_run( ME_Cursor *cursor, BOOL all_para ) DECLSPEC_HIDDEN; +BOOL cursor_prev_run( ME_Cursor *cursor, BOOL all_para ) DECLSPEC_HIDDEN; int run_char_ofs( ME_Run *run, int ofs ) DECLSPEC_HIDDEN; ME_Run *run_create( ME_Style *s, int nFlags ) DECLSPEC_HIDDEN; ME_Run *run_insert( ME_TextEditor *editor, ME_Cursor *cursor, diff --git a/dlls/riched20/list.c b/dlls/riched20/list.c index 23d1a38991d..891a52e605f 100644 --- a/dlls/riched20/list.c +++ b/dlls/riched20/list.c @@ -63,51 +63,6 @@ static BOOL ME_DITypesEqual(ME_DIType type, ME_DIType nTypeOrClass) } }
-/* 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 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; - return TRUE; - } - p = p->next; - } - return FALSE; -} - -/* 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 all_para) -{ - ME_DisplayItem *p = (*run)->prev; - while (p->type != diTextStart) - { - if (p->type == diParagraph) { - if (!all_para) return FALSE; - if (para && p->member.para.prev_para->type == diParagraph) - *para = p->member.para.prev_para; - } else if (p->type == diRun) { - *run = p; - return TRUE; - } - p = p->prev; - } - return FALSE; -} - ME_DisplayItem *ME_FindItemBack(ME_DisplayItem *di, ME_DIType nTypeOrClass) { if (!di) diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c index b1436ad5060..978f6691356 100644 --- a/dlls/riched20/run.c +++ b/dlls/riched20/run.c @@ -27,42 +27,96 @@ WINE_DEFAULT_DEBUG_CHANNEL(richedit); WINE_DECLARE_DEBUG_CHANNEL(richedit_check); WINE_DECLARE_DEBUG_CHANNEL(richedit_lists);
+BOOL cursor_next_run( ME_Cursor *cursor, BOOL all_para ) +{ + ME_DisplayItem *p = cursor->pRun->next; + + while (p->type != diTextEnd) + { + if (p->type == diParagraph && !all_para) return FALSE; + else if (p->type == diRun) + { + cursor->pRun = p; + cursor->pPara = para_get_di( cursor->pRun->member.run.para ); + cursor->nOffset = 0; + return TRUE; + } + p = p->next; + } + return FALSE; +} + +BOOL cursor_prev_run( ME_Cursor *cursor, BOOL all_para ) +{ + ME_DisplayItem *p = cursor->pRun->prev; + + while (p->type != diTextStart) + { + if (p->type == diParagraph && !all_para) return FALSE; + else if (p->type == diRun) + { + cursor->pRun = p; + cursor->pPara = para_get_di( cursor->pRun->member.run.para ); + cursor->nOffset = 0; + return TRUE; + } + p = p->prev; + } + return FALSE; +} + ME_Run *run_next( ME_Run *run ) { - ME_DisplayItem *item = run_get_di( run ); + ME_Cursor cursor; + + cursor.pRun = run_get_di( run ); + cursor.pPara = para_get_di( run->para ); + cursor.nOffset = 0;
- if (ME_NextRun( NULL, &item, FALSE )) - return &item->member.run; + if (cursor_next_run( &cursor, FALSE )) + return &cursor.pRun->member.run;
return NULL; }
ME_Run *run_prev( ME_Run *run ) { - ME_DisplayItem *item = run_get_di( run ); + ME_Cursor cursor; + + cursor.pRun = run_get_di( run ); + cursor.pPara = para_get_di( run->para ); + cursor.nOffset = 0;
- if (ME_PrevRun( NULL, &item, FALSE )) - return &item->member.run; + if (cursor_prev_run( &cursor, FALSE )) + return &cursor.pRun->member.run;
return NULL; }
ME_Run *run_next_all_paras( ME_Run *run ) { - ME_DisplayItem *item = run_get_di( run ), *dummy = para_get_di( run->para ); + ME_Cursor cursor;
- if (ME_NextRun( &dummy, &item, TRUE )) - return &item->member.run; + cursor.pRun = run_get_di( run ); + cursor.pPara = para_get_di( run->para ); + cursor.nOffset = 0; + + if (cursor_next_run( &cursor, TRUE )) + return &cursor.pRun->member.run;
return NULL; }
ME_Run *run_prev_all_paras( ME_Run *run ) { - ME_DisplayItem *item = run_get_di( run ), *dummy = para_get_di( run->para ); + ME_Cursor cursor; + + cursor.pRun = run_get_di( run ); + cursor.pPara = para_get_di( run->para ); + cursor.nOffset = 0;
- if (ME_PrevRun( &dummy, &item, TRUE )) - return &item->member.run; + if (cursor_prev_run( &cursor, TRUE )) + return &cursor.pRun->member.run;
return NULL; } diff --git a/dlls/riched20/writer.c b/dlls/riched20/writer.c index 72242194127..1fc2bfad51e 100644 --- a/dlls/riched20/writer.c +++ b/dlls/riched20/writer.c @@ -1107,7 +1107,7 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream, return FALSE; cursor.nOffset = 0; } - } while (cursor.pRun != endCur.pRun && ME_NextRun(&cursor.pPara, &cursor.pRun, TRUE)); + } while (cursor.pRun != endCur.pRun && cursor_next_run( &cursor, TRUE ));
if (!ME_StreamOutMove(pStream, "}\0", 2)) return FALSE;