mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
riched20: Pass a para or run ptr to the char ofs propagation function.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
da46adac99
commit
47228b7db4
4 changed files with 29 additions and 58 deletions
|
@ -413,10 +413,8 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start,
|
|||
|
||||
/* c = updated data now */
|
||||
|
||||
if (c.run == cursor.run)
|
||||
ME_SkipAndPropagateCharOffset( run_get_di( c.run ), shift );
|
||||
else
|
||||
ME_PropagateCharOffset( run_get_di( c.run ), shift );
|
||||
if (c.run == cursor.run) c.run->nCharOfs -= shift;
|
||||
editor_propagate_char_ofs( NULL, c.run, shift );
|
||||
|
||||
if (!cursor.run->len)
|
||||
{
|
||||
|
|
|
@ -126,12 +126,12 @@ static inline ME_DisplayItem *row_get_di( ME_Row *row )
|
|||
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;
|
||||
void editor_propagate_char_ofs( ME_Paragraph *para, ME_Run *run, int shift ) 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,
|
||||
ME_Style *style, const WCHAR *str, int len, int flags ) DECLSPEC_HIDDEN;
|
||||
void ME_CheckCharOffsets(ME_TextEditor *editor) DECLSPEC_HIDDEN;
|
||||
void ME_PropagateCharOffset(ME_DisplayItem *p, int shift) DECLSPEC_HIDDEN;
|
||||
/* this one accounts for 1/2 char tolerance */
|
||||
int ME_CharFromPointContext(ME_Context *c, int cx, ME_Run *run, BOOL closest, BOOL visual_order) DECLSPEC_HIDDEN;
|
||||
int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Run *run, BOOL closest, BOOL visual_order) DECLSPEC_HIDDEN;
|
||||
|
@ -147,7 +147,6 @@ ME_Run *run_split( ME_TextEditor *editor, ME_Cursor *cursor ) DECLSPEC_HIDDEN;
|
|||
void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run) DECLSPEC_HIDDEN;
|
||||
SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run *run, int nLen,
|
||||
int startx, int *pAscent, int *pDescent) DECLSPEC_HIDDEN;
|
||||
void ME_SkipAndPropagateCharOffset(ME_DisplayItem *p, int shift) DECLSPEC_HIDDEN;
|
||||
void ME_SetCharFormat(ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN;
|
||||
void ME_SetSelectionCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN;
|
||||
void ME_GetCharFormat(ME_TextEditor *editor, const ME_Cursor *from,
|
||||
|
|
|
@ -674,7 +674,7 @@ ME_Paragraph *para_split( ME_TextEditor *editor, ME_Run *run, ME_Style *style,
|
|||
para_mark_rewrap( editor, &new_para->prev_para->member.para );
|
||||
|
||||
/* we've added the end run, so we need to modify nCharOfs in the next paragraphs */
|
||||
ME_PropagateCharOffset( para_get_di( next_para ), eol_len );
|
||||
editor_propagate_char_ofs( next_para, NULL, eol_len );
|
||||
editor->nParagraphs++;
|
||||
|
||||
return new_para;
|
||||
|
@ -688,8 +688,7 @@ ME_Paragraph *para_join( ME_TextEditor *editor, ME_Paragraph *para, BOOL use_fir
|
|||
ME_Paragraph *next = para_next( para );
|
||||
ME_Run *end_run, *next_first_run, *tmp_run;
|
||||
ME_Cell *cell = NULL;
|
||||
int i, shift;
|
||||
int end_len;
|
||||
int i, end_len;
|
||||
CHARFORMAT2W fmt;
|
||||
ME_Cursor startCur, endCur;
|
||||
ME_String *eol_str;
|
||||
|
@ -751,8 +750,6 @@ ME_Paragraph *para_join( ME_TextEditor *editor, ME_Paragraph *para, BOOL use_fir
|
|||
para->border = next->border;
|
||||
}
|
||||
|
||||
shift = next->nCharOfs - para->nCharOfs - end_len;
|
||||
|
||||
/* Update selection cursors so they don't point to the removed end
|
||||
* paragraph run, and point to the correct paragraph. */
|
||||
for (i = 0; i < editor->nCursors; i++)
|
||||
|
@ -768,8 +765,7 @@ ME_Paragraph *para_join( ME_TextEditor *editor, ME_Paragraph *para, BOOL use_fir
|
|||
|
||||
for (tmp_run = next_first_run; tmp_run; tmp_run = run_next( tmp_run ))
|
||||
{
|
||||
TRACE( "shifting %s by %d (previous %d)\n", debugstr_run( tmp_run ), shift, tmp_run->nCharOfs );
|
||||
tmp_run->nCharOfs += shift;
|
||||
tmp_run->nCharOfs += next->nCharOfs - para->nCharOfs - end_len;
|
||||
tmp_run->para = para;
|
||||
}
|
||||
|
||||
|
@ -789,7 +785,7 @@ ME_Paragraph *para_join( ME_TextEditor *editor, ME_Paragraph *para, BOOL use_fir
|
|||
ME_Remove( para_get_di(next) );
|
||||
para_destroy( editor, next );
|
||||
|
||||
ME_PropagateCharOffset( para->next_para, -end_len );
|
||||
editor_propagate_char_ofs( para_next( para ), NULL, -end_len );
|
||||
|
||||
ME_CheckCharOffsets(editor);
|
||||
|
||||
|
|
|
@ -137,54 +137,32 @@ BOOL ME_CanJoinRuns(const ME_Run *run1, const ME_Run *run2)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void ME_SkipAndPropagateCharOffset(ME_DisplayItem *p, int shift)
|
||||
{
|
||||
p = ME_FindItemFwd(p, diRunOrParagraphOrEnd);
|
||||
assert(p);
|
||||
ME_PropagateCharOffset(p, shift);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* ME_PropagateCharOffsets
|
||||
* editor_propagate_char_ofs
|
||||
*
|
||||
* Shifts (increases or decreases) character offset (relative to beginning of
|
||||
* the document) of the part of the text starting from given place.
|
||||
* Call with only one of para or run non-NULL.
|
||||
*/
|
||||
void ME_PropagateCharOffset(ME_DisplayItem *p, int shift)
|
||||
void editor_propagate_char_ofs( ME_Paragraph *para, ME_Run *run, int shift )
|
||||
{
|
||||
/* Runs in one paragraph contain character offset relative to their owning
|
||||
* paragraph. If we start the shifting from the run, we need to shift
|
||||
* all the relative offsets until the end of the paragraph
|
||||
*/
|
||||
if (p->type == diRun) /* propagate in all runs in this para */
|
||||
assert( !para ^ !run );
|
||||
|
||||
if (run)
|
||||
{
|
||||
TRACE("PropagateCharOffset(%s, %d)\n", debugstr_run( &p->member.run ), shift);
|
||||
do {
|
||||
p->member.run.nCharOfs += shift;
|
||||
assert(p->member.run.nCharOfs >= 0);
|
||||
p = ME_FindItemFwd(p, diRunOrParagraphOrEnd);
|
||||
} while(p->type == diRun);
|
||||
para = para_next( run->para );
|
||||
do
|
||||
{
|
||||
run->nCharOfs += shift;
|
||||
run = run_next( run );
|
||||
} while (run);
|
||||
}
|
||||
/* Runs in next paragraphs don't need their offsets updated, because they,
|
||||
* again, those offsets are relative to their respective paragraphs.
|
||||
* Instead of that, we're updating paragraphs' character offsets.
|
||||
*/
|
||||
if (p->type == diParagraph) /* propagate in all next paras */
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
p->member.para.nCharOfs += shift;
|
||||
assert(p->member.para.nCharOfs >= 0);
|
||||
p = p->member.para.next_para;
|
||||
} while(p->type == diParagraph);
|
||||
}
|
||||
/* diTextEnd also has character offset in it, which makes finding text length
|
||||
* easier. But it needs to be up to date first.
|
||||
*/
|
||||
if (p->type == diTextEnd)
|
||||
{
|
||||
p->member.para.nCharOfs += shift;
|
||||
assert(p->member.para.nCharOfs >= 0);
|
||||
}
|
||||
para->nCharOfs += shift;
|
||||
para = para_next( para );
|
||||
} while (para);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -422,7 +400,7 @@ ME_Run *run_insert( ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style,
|
|||
ME_InsertString( run->para->text, run->nCharOfs, str, len );
|
||||
ME_InsertBefore( run_get_di( insert_before ), run_get_di( run ) );
|
||||
TRACE("Shift length:%d\n", len);
|
||||
ME_PropagateCharOffset( run_get_di( insert_before ), len );
|
||||
editor_propagate_char_ofs( NULL, insert_before, len );
|
||||
para_mark_rewrap( editor, insert_before->para );
|
||||
|
||||
/* Move any cursors that were at the end of the previous run to the end of the inserted run */
|
||||
|
|
Loading…
Reference in a new issue