diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index 077affa2a75..98655816de2 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -434,34 +434,37 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor, static BOOL ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs) { - ME_DisplayItem *pRun; + ME_DisplayItem *pRun = pCursor->pRun; if (nRelOfs == -1) { if (!pCursor->nOffset) { - pRun = ME_FindItemBack(pCursor->pRun, diRunOrParagraph); - assert(pRun); - switch (pRun->type) - { - case diRun: - pCursor->pRun = pRun; - pCursor->nOffset = pRun->member.run.strText->nLen; - break; - case diParagraph: - if (pRun->member.para.prev_para->type == diTextStart) + do { + pRun = ME_FindItemBack(pRun, diRunOrParagraph); + assert(pRun); + switch (pRun->type) + { + case diRun: + break; + case diParagraph: + if (pRun->member.para.prev_para->type == diTextStart) + return FALSE; + pRun = ME_FindItemBack(pRun, diRunOrParagraph); + /* every paragraph ought to have at least one run */ + assert(pRun && pRun->type == diRun); + assert(pRun->member.run.nFlags & MERF_ENDPARA); + break; + default: + assert(pRun->type != diRun && pRun->type != diParagraph); return FALSE; - pRun = ME_FindItemBack(pRun, diRunOrParagraph); - /* every paragraph ought to have at least one run */ - assert(pRun && pRun->type == diRun); - assert(pRun->member.run.nFlags & MERF_ENDPARA); - pCursor->pRun = pRun; - pCursor->nOffset = 0; - break; - default: - assert(pRun->type != diRun && pRun->type != diParagraph); - return FALSE; - } + } + } while (RUN_IS_HIDDEN(&pRun->member.run)); + pCursor->pRun = pRun; + if (pRun->member.run.nFlags & MERF_ENDPARA) + pCursor->nOffset = 0; + else + pCursor->nOffset = pRun->member.run.strText->nLen; } if (pCursor->nOffset) @@ -470,17 +473,19 @@ ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs) } else { - if (!(pCursor->pRun->member.run.nFlags & MERF_ENDPARA)) + if (!(pRun->member.run.nFlags & MERF_ENDPARA)) { - int new_ofs = ME_StrRelPos2(pCursor->pRun->member.run.strText, pCursor->nOffset, nRelOfs); + int new_ofs = ME_StrRelPos2(pRun->member.run.strText, pCursor->nOffset, nRelOfs); - if (new_ofs < pCursor->pRun->member.run.strText->nLen) + if (new_ofs < pRun->member.run.strText->nLen) { pCursor->nOffset = new_ofs; return TRUE; } } - pRun = ME_FindItemFwd(pCursor->pRun, diRun); + do { + pRun = ME_FindItemFwd(pRun, diRun); + } while (pRun && RUN_IS_HIDDEN(&pRun->member.run)); if (pRun) { pCursor->pRun = pRun; diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 135fe8e1233..da5e996efaf 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -350,6 +350,10 @@ static void ME_RTFCharAttrHook(RTF_Info *info) if (info->rtfMinor == rtfSuperScrShrink) fmt.dwEffects = CFE_SUPERSCRIPT; if (info->rtfMinor == rtfNoSuperSub) fmt.dwEffects = 0; break; + case rtfInvisible: + fmt.dwMask = CFM_HIDDEN; + fmt.dwEffects = info->rtfParam ? fmt.dwMask : 0; + break; case rtfBackColor: fmt.dwMask = CFM_BACKCOLOR; fmt.dwEffects = 0; diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index 95b0a5eae94..f3d9b07c7da 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -24,6 +24,9 @@ #define ALLOC_N_OBJ(type, count) HeapAlloc(me_heap, 0, (count)*sizeof(type)) #define FREE_OBJ(ptr) HeapFree(me_heap, 0, ptr) +#define RUN_IS_HIDDEN(run) ((run)->style->fmt.dwMask & CFM_HIDDEN \ + && (run)->style->fmt.dwEffects & CFE_HIDDEN) + /* style.c */ ME_Style *ME_MakeStyle(CHARFORMAT2W *style); void ME_AddRefStyle(ME_Style *item); diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h index 37af096f4f4..919dd029dc0 100644 --- a/dlls/riched20/editstr.h +++ b/dlls/riched20/editstr.h @@ -103,6 +103,8 @@ typedef enum { #define MERF_CALCBYWRAP 0x0F0000 /* the "end of paragraph" run, contains 1 character */ #define MERF_ENDPARA 0x100000 +/* run is hidden */ +#define MERF_HIDDEN 0x200000 /* runs with any of these flags set cannot be joined */ #define MERF_NOJOIN (MERF_GRAPHICS|MERF_TAB|MERF_ENDPARA) diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c index ad4733fde4a..d35c539e8f9 100644 --- a/dlls/riched20/paint.c +++ b/dlls/riched20/paint.c @@ -226,6 +226,9 @@ static void ME_DrawRun(ME_Context *c, int x, int y, ME_DisplayItem *rundi, ME_Pa int nSelFrom, nSelTo; const WCHAR wszSpace[] = {' ', 0}; + if (run->nFlags & MERF_HIDDEN) + return; + ME_GetSelection(c->editor, &nSelFrom, &nSelTo); /* Draw selected end-of-paragraph mark */ diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c index 5c97941aa5f..b9c33a5f61c 100644 --- a/dlls/riched20/run.c +++ b/dlls/riched20/run.c @@ -340,6 +340,12 @@ ME_InsertRunAtCursor(ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style, void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run) { assert(run->nCharOfs != -1); + + if (RUN_IS_HIDDEN(run)) + run->nFlags |= MERF_HIDDEN; + else + run->nFlags &= ~MERF_HIDDEN; + if (ME_IsSplitable(run->strText)) run->nFlags |= MERF_SPLITTABLE; else @@ -539,11 +545,16 @@ SIZE ME_GetRunSize(ME_Context *c, ME_Paragraph *para, ME_Run *run, int nLen) void ME_CalcRunExtent(ME_Context *c, ME_Paragraph *para, ME_Run *run) { - int nEnd = ME_StrVLen(run->strText); - SIZE size = ME_GetRunSizeCommon(c, para, run, nEnd, &run->nAscent, &run->nDescent); - run->nWidth = size.cx; - if (!size.cx) - WARN("size.cx == 0\n"); + if (run->nFlags & MERF_HIDDEN) + run->nWidth = 0; + else + { + int nEnd = ME_StrVLen(run->strText); + SIZE size = ME_GetRunSizeCommon(c, para, run, nEnd, &run->nAscent, &run->nDescent); + run->nWidth = size.cx; + if (!size.cx) + WARN("size.cx == 0\n"); + } } void ME_MustBeWrapped(ME_Context *c, ME_DisplayItem *para) diff --git a/dlls/riched20/style.c b/dlls/riched20/style.c index 11fd56b02c8..56f9842bb6c 100644 --- a/dlls/riched20/style.c +++ b/dlls/riched20/style.c @@ -237,6 +237,7 @@ void ME_DumpStyleToBuf(CHARFORMAT2W *pFmt, char buf[2048]) ME_DumpStyleEffect(&p, "Font italic:", pFmt, CFM_ITALIC); ME_DumpStyleEffect(&p, "Font underline:", pFmt, CFM_UNDERLINE); ME_DumpStyleEffect(&p, "Font strikeout:", pFmt, CFM_STRIKEOUT); + ME_DumpStyleEffect(&p, "Hidden text:", pFmt, CFM_HIDDEN); p += sprintf(p, "Text color: "); if (pFmt->dwMask & CFM_COLOR) {