riched20: Simplify the char offset from run offset function.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
57c2580a73
commit
120ee0de1b
|
@ -4322,15 +4322,15 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
|
||||||
}
|
}
|
||||||
cursor_from_char_ofs( editor, wParam, &cursor );
|
cursor_from_char_ofs( editor, wParam, &cursor );
|
||||||
item = ME_RowStart( cursor.pRun );
|
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);
|
item_end = ME_FindItemFwd(item, diStartRowOrParagraphOrEnd);
|
||||||
if (item_end->type == diStartRow)
|
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
|
else
|
||||||
{
|
{
|
||||||
ME_DisplayItem *endRun = ME_FindItemBack(item_end, diRun);
|
ME_DisplayItem *endRun = ME_FindItemBack(item_end, diRun);
|
||||||
assert(endRun && endRun->member.run.nFlags & MERF_ENDPARA);
|
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;
|
nChars = nNextLineOfs - nThisLineOfs;
|
||||||
TRACE("EM_LINELENGTH(%ld)==%d\n", wParam, nChars);
|
TRACE("EM_LINELENGTH(%ld)==%d\n", wParam, nChars);
|
||||||
|
|
|
@ -120,6 +120,7 @@ int ME_RowNumberFromCharOfs(ME_TextEditor *editor, int nOfs) DECLSPEC_HIDDEN;
|
||||||
/* run.c */
|
/* run.c */
|
||||||
void cursor_from_char_ofs( ME_TextEditor *editor, int char_ofs, ME_Cursor *cursor ) DECLSPEC_HIDDEN;
|
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_create( ME_Style *s, int nFlags ) DECLSPEC_HIDDEN;
|
||||||
ME_Run *run_insert( ME_TextEditor *editor, ME_Cursor *cursor,
|
ME_Run *run_insert( ME_TextEditor *editor, ME_Cursor *cursor,
|
||||||
ME_Style *style, const WCHAR *str, int len, int flags ) DECLSPEC_HIDDEN;
|
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;
|
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,
|
SIZE ME_GetRunSizeCommon(ME_Context *c, const ME_Paragraph *para, ME_Run *run, int nLen,
|
||||||
int startx, int *pAscent, int *pDescent) DECLSPEC_HIDDEN;
|
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_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_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_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.
|
* 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);
|
return run->para->nCharOfs + run->nCharOfs + ofs;
|
||||||
assert(pPara && pPara->type == diParagraph);
|
|
||||||
return pPara->member.para.nCharOfs + pRun->member.run.nCharOfs + nOfs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
|
Loading…
Reference in New Issue