riched20: Add helper function to mark paragraphs for rewrapping.
Signed-off-by: Sergio Gómez Del Real <sdelreal@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
70a2fe5886
commit
ad58875642
|
@ -380,7 +380,7 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start,
|
|||
|
||||
c.nOffset -= nCharsToDelete;
|
||||
|
||||
ME_FindItemBack(c.pRun, diParagraph)->member.para.nFlags |= MEPF_REWRAP;
|
||||
mark_para_rewrap(editor, ME_FindItemBack(c.pRun, diParagraph));
|
||||
|
||||
cursor = c;
|
||||
/* nChars is the number of characters that should be deleted from the
|
||||
|
|
|
@ -2564,7 +2564,8 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
|
|||
editor->pCursors[0].pRun->member.run.style);
|
||||
para = editor->pBuffer->pFirst->member.para.next_para;
|
||||
ME_SetDefaultParaFormat(editor, ¶->member.para.fmt);
|
||||
para->member.para.nFlags = MEPF_REWRAP;
|
||||
para->member.para.nFlags = 0;
|
||||
mark_para_rewrap(editor, para);
|
||||
editor->pCursors[0].pPara = para;
|
||||
editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun);
|
||||
editor->pCursors[1] = editor->pCursors[0];
|
||||
|
|
|
@ -203,6 +203,8 @@ void ME_SetDefaultParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt) DECLSPEC_
|
|||
void para_num_init( ME_Context *c, ME_Paragraph *para ) DECLSPEC_HIDDEN;
|
||||
void para_num_clear( struct para_num *pn ) DECLSPEC_HIDDEN;
|
||||
int get_total_width(ME_TextEditor *editor) DECLSPEC_HIDDEN;
|
||||
void mark_para_rewrap(ME_TextEditor *editor, ME_DisplayItem *para) DECLSPEC_HIDDEN;
|
||||
ME_DisplayItem *get_di_from_para(ME_Paragraph *para) DECLSPEC_HIDDEN;
|
||||
|
||||
/* paint.c */
|
||||
void ME_PaintContent(ME_TextEditor *editor, HDC hDC, const RECT *rcUpdate) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -23,6 +23,16 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(richedit);
|
||||
|
||||
void mark_para_rewrap(ME_TextEditor *editor, ME_DisplayItem *para)
|
||||
{
|
||||
para->member.para.nFlags |= MEPF_REWRAP;
|
||||
}
|
||||
|
||||
ME_DisplayItem *get_di_from_para(ME_Paragraph *para)
|
||||
{
|
||||
return (ME_DisplayItem *)((ptrdiff_t)para - offsetof(ME_DisplayItem, member));
|
||||
}
|
||||
|
||||
static ME_DisplayItem *make_para(ME_TextEditor *editor)
|
||||
{
|
||||
ME_DisplayItem *item = ME_MakeDI(diParagraph);
|
||||
|
@ -143,7 +153,7 @@ static void ME_MarkForWrapping(ME_TextEditor *editor, ME_DisplayItem *first, con
|
|||
{
|
||||
while(first != last)
|
||||
{
|
||||
first->member.para.nFlags |= MEPF_REWRAP;
|
||||
mark_para_rewrap(editor, first);
|
||||
first = first->member.para.next_para;
|
||||
}
|
||||
}
|
||||
|
@ -366,11 +376,11 @@ void para_num_clear( struct para_num *pn )
|
|||
pn->text = NULL;
|
||||
}
|
||||
|
||||
static void para_num_clear_list( ME_Paragraph *para, const PARAFORMAT2 *orig_fmt )
|
||||
static void para_num_clear_list( ME_TextEditor *editor, ME_Paragraph *para, const PARAFORMAT2 *orig_fmt )
|
||||
{
|
||||
do
|
||||
{
|
||||
para->nFlags |= MEPF_REWRAP;
|
||||
mark_para_rewrap(editor, get_di_from_para(para));
|
||||
para_num_clear( ¶->para_num );
|
||||
if (para->next_para->type != diParagraph) break;
|
||||
para = ¶->next_para->member.para;
|
||||
|
@ -445,12 +455,12 @@ static BOOL ME_SetParaFormat(ME_TextEditor *editor, ME_Paragraph *para, const PA
|
|||
|
||||
if (memcmp(©, ¶->fmt, sizeof(PARAFORMAT2)))
|
||||
{
|
||||
para->nFlags |= MEPF_REWRAP;
|
||||
mark_para_rewrap(editor, get_di_from_para(para));
|
||||
if (((dwMask & PFM_NUMBERING) && (copy.wNumbering != para->fmt.wNumbering)) ||
|
||||
((dwMask & PFM_NUMBERINGSTART) && (copy.wNumberingStart != para->fmt.wNumberingStart)) ||
|
||||
((dwMask & PFM_NUMBERINGSTYLE) && (copy.wNumberingStyle != para->fmt.wNumberingStyle)))
|
||||
{
|
||||
para_num_clear_list( para, © );
|
||||
para_num_clear_list( editor, para, © );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -487,7 +497,7 @@ ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *run,
|
|||
|
||||
/* Clear any cached para numbering following this paragraph */
|
||||
if (run_para->member.para.fmt.wNumbering)
|
||||
para_num_clear_list( &run_para->member.para, &run_para->member.para.fmt );
|
||||
para_num_clear_list( editor, &run_para->member.para, &run_para->member.para.fmt );
|
||||
|
||||
new_para->member.para.text = ME_VSplitString( run_para->member.para.text, run->member.run.nCharOfs );
|
||||
|
||||
|
@ -519,7 +529,8 @@ ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *run,
|
|||
}
|
||||
new_para->member.para.nCharOfs = run_para->member.para.nCharOfs + ofs;
|
||||
new_para->member.para.nCharOfs += eol_len;
|
||||
new_para->member.para.nFlags = MEPF_REWRAP;
|
||||
new_para->member.para.nFlags = 0;
|
||||
mark_para_rewrap(editor, new_para);
|
||||
|
||||
/* FIXME initialize format style and call ME_SetParaFormat blah blah */
|
||||
new_para->member.para.fmt = run_para->member.para.fmt;
|
||||
|
@ -585,8 +596,8 @@ ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *run,
|
|||
}
|
||||
|
||||
/* force rewrap of the */
|
||||
run_para->member.para.prev_para->member.para.nFlags |= MEPF_REWRAP;
|
||||
new_para->member.para.prev_para->member.para.nFlags |= MEPF_REWRAP;
|
||||
mark_para_rewrap(editor, run_para->member.para.prev_para);
|
||||
mark_para_rewrap(editor, new_para->member.para.prev_para);
|
||||
|
||||
/* we've added the end run, so we need to modify nCharOfs in the next paragraphs */
|
||||
ME_PropagateCharOffset(next_para, eol_len);
|
||||
|
@ -613,7 +624,7 @@ ME_DisplayItem *ME_JoinParagraphs(ME_TextEditor *editor, ME_DisplayItem *tp,
|
|||
|
||||
/* Clear any cached para numbering following this paragraph */
|
||||
if (tp->member.para.fmt.wNumbering)
|
||||
para_num_clear_list( &tp->member.para, &tp->member.para.fmt );
|
||||
para_num_clear_list( editor, &tp->member.para, &tp->member.para.fmt );
|
||||
|
||||
pNext = tp->member.para.next_para;
|
||||
|
||||
|
@ -721,7 +732,7 @@ ME_DisplayItem *ME_JoinParagraphs(ME_TextEditor *editor, ME_DisplayItem *tp,
|
|||
ME_CheckCharOffsets(editor);
|
||||
|
||||
editor->nParagraphs--;
|
||||
tp->member.para.nFlags |= MEPF_REWRAP;
|
||||
mark_para_rewrap(editor, tp);
|
||||
return tp;
|
||||
}
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ void ME_JoinRuns(ME_TextEditor *editor, ME_DisplayItem *p)
|
|||
int i;
|
||||
assert(p->type == diRun && pNext->type == diRun);
|
||||
assert(p->member.run.nCharOfs != -1);
|
||||
ME_GetParagraph(p)->member.para.nFlags |= MEPF_REWRAP;
|
||||
mark_para_rewrap(editor, ME_GetParagraph(p));
|
||||
|
||||
/* Update all cursors so that they don't contain the soon deleted run */
|
||||
for (i=0; i<editor->nCursors; i++) {
|
||||
|
@ -277,7 +277,7 @@ ME_DisplayItem *ME_SplitRunSimple(ME_TextEditor *editor, ME_Cursor *cursor)
|
|||
editor->pCursors[i].nOffset -= nOffset;
|
||||
}
|
||||
}
|
||||
cursor->pPara->member.para.nFlags |= MEPF_REWRAP;
|
||||
mark_para_rewrap(editor, cursor->pPara);
|
||||
return run;
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,7 @@ ME_InsertRunAtCursor(ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style,
|
|||
ME_InsertBefore( insert_before, pDI );
|
||||
TRACE("Shift length:%d\n", len);
|
||||
ME_PropagateCharOffset( insert_before, len );
|
||||
insert_before->member.run.para->nFlags |= MEPF_REWRAP;
|
||||
mark_para_rewrap(editor, get_di_from_para(insert_before->member.run.para));
|
||||
|
||||
/* Move any cursors that were at the end of the previous run to the end of the inserted run */
|
||||
prev = ME_FindItemBack( pDI, diRun );
|
||||
|
@ -766,7 +766,7 @@ void ME_SetCharFormat(ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, C
|
|||
ME_ReleaseStyle(para->para_num.style);
|
||||
para->para_num.style = NULL;
|
||||
}
|
||||
para->nFlags |= MEPF_REWRAP;
|
||||
mark_para_rewrap(editor, get_di_from_para(para));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -341,7 +341,7 @@ static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo)
|
|||
add_undo_set_para_fmt( editor, ¶->member.para );
|
||||
para->member.para.fmt = undo->u.set_para_fmt.fmt;
|
||||
para->member.para.border = undo->u.set_para_fmt.border;
|
||||
para->member.para.nFlags |= MEPF_REWRAP;
|
||||
mark_para_rewrap(editor, para);
|
||||
break;
|
||||
}
|
||||
case undo_set_char_fmt:
|
||||
|
|
Loading…
Reference in New Issue