Commit 120ee0de authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Simplify the char offset from run offset function.

parent 57c2580a
......@@ -4322,15 +4322,15 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
}
cursor_from_char_ofs( editor, wParam, &cursor );
item = ME_RowStart( cursor.pRun );
nThisLineOfs = ME_CharOfsFromRunOfs( editor, cursor.pPara, ME_FindItemFwd( item, diRun ), 0 );
nThisLineOfs = run_char_ofs( &ME_FindItemFwd( item, diRun )->member.run, 0 );
item_end = ME_FindItemFwd(item, diStartRowOrParagraphOrEnd);
if (item_end->type == diStartRow)
nNextLineOfs = ME_CharOfsFromRunOfs(editor, cursor.pPara, ME_FindItemFwd( item_end, diRun ), 0);
nNextLineOfs = run_char_ofs( &ME_FindItemFwd( item_end, diRun )->member.run, 0 );
else
{
ME_DisplayItem *endRun = ME_FindItemBack(item_end, diRun);
assert(endRun && endRun->member.run.nFlags & MERF_ENDPARA);
nNextLineOfs = item_end->member.para.nCharOfs - endRun->member.run.len;
nNextLineOfs = run_char_ofs( &endRun->member.run, 0 );
}
nChars = nNextLineOfs - nThisLineOfs;
TRACE("EM_LINELENGTH(%ld)==%d\n", wParam, nChars);
......
......@@ -120,6 +120,7 @@ int ME_RowNumberFromCharOfs(ME_TextEditor *editor, int nOfs) DECLSPEC_HIDDEN;
/* run.c */
void cursor_from_char_ofs( ME_TextEditor *editor, int char_ofs, ME_Cursor *cursor ) 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;
......@@ -140,7 +141,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;
int ME_CharOfsFromRunOfs(ME_TextEditor *editor, const ME_DisplayItem *pPara, const ME_DisplayItem *pRun, int nOfs) 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;
......
......@@ -187,18 +187,15 @@ void ME_CheckCharOffsets(ME_TextEditor *editor)
}
/******************************************************************************
* ME_CharOfsFromRunOfs
* run_char_ofs
*
* Converts a character position relative to the start of the run, to a
* Converts a character position relative to the start of the run to a
* character position relative to the start of the document.
* Kind of a "local to global" offset conversion.
*/
int ME_CharOfsFromRunOfs(ME_TextEditor *editor, const ME_DisplayItem *pPara,
const ME_DisplayItem *pRun, int nOfs)
int run_char_ofs( ME_Run *run, int ofs )
{
assert(pRun && pRun->type == diRun);
assert(pPara && pPara->type == diParagraph);
return pPara->member.para.nCharOfs + pRun->member.run.nCharOfs + nOfs;
return run->para->nCharOfs + run->nCharOfs + ofs;
}
/******************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment