Commit 5ddfc36c authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Add a visual vs logical order flag to the character to position mapping routines.

parent b4f8cf8e
......@@ -237,7 +237,7 @@ ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor *pCursor,
assert(run->type == diRun);
}
}
run_x = ME_PointFromCharContext( &c, &run->member.run, pCursor->nOffset );
run_x = ME_PointFromCharContext( &c, &run->member.run, pCursor->nOffset, TRUE );
*height = pSizeRun->member.run.nAscent + pSizeRun->member.run.nDescent;
*x = c.rcView.left + run->member.run.pt.x + run_x - editor->horz_si.nPos;
......@@ -887,7 +887,7 @@ static BOOL ME_FindRunInRow(ME_TextEditor *editor, ME_DisplayItem *pRow,
if (x >= run_x && x < run_x+width)
{
cursor->nOffset = ME_CharFromPoint(editor, x-run_x, &pNext->member.run, TRUE);
cursor->nOffset = ME_CharFromPoint(editor, x-run_x, &pNext->member.run, TRUE, TRUE);
cursor->pRun = pNext;
cursor->pPara = ME_GetParagraph( cursor->pRun );
return exact;
......@@ -1182,7 +1182,7 @@ static int ME_GetXForArrow(ME_TextEditor *editor, ME_Cursor *pCursor)
}
else {
x = pRun->member.run.pt.x;
x += ME_PointFromChar(editor, &pRun->member.run, pCursor->nOffset);
x += ME_PointFromChar(editor, &pRun->member.run, pCursor->nOffset, TRUE);
}
editor->nUDArrowX = x;
}
......
......@@ -3936,7 +3936,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
ME_RunOfsFromCharOfs(editor, nCharOfs, &pPara, &pRun, &nOffset);
assert(pRun->type == diRun);
pt.y = pRun->member.run.pt.y;
pt.x = pRun->member.run.pt.x + ME_PointFromChar(editor, &pRun->member.run, nOffset);
pt.x = pRun->member.run.pt.x + ME_PointFromChar(editor, &pRun->member.run, nOffset, TRUE);
pt.y += pPara->member.para.pt.y + editor->rcFormat.top;
pt.x += editor->rcFormat.left;
......
......@@ -140,10 +140,10 @@ ME_DisplayItem *ME_InsertRunAtCursor(ME_TextEditor *editor, ME_Cursor *cursor,
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) DECLSPEC_HIDDEN;
int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Run *run, BOOL closest) DECLSPEC_HIDDEN;
int ME_PointFromCharContext(ME_Context *c, ME_Run *pRun, int nOffset) DECLSPEC_HIDDEN;
int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset) DECLSPEC_HIDDEN;
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;
int ME_PointFromCharContext(ME_Context *c, ME_Run *pRun, int nOffset, BOOL visual_order) DECLSPEC_HIDDEN;
int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset, BOOL visual_order) DECLSPEC_HIDDEN;
int ME_CanJoinRuns(const ME_Run *run1, const ME_Run *run2) DECLSPEC_HIDDEN;
void ME_JoinRuns(ME_TextEditor *editor, ME_DisplayItem *p) DECLSPEC_HIDDEN;
ME_DisplayItem *ME_SplitRunSimple(ME_TextEditor *editor, ME_Cursor *cursor) DECLSPEC_HIDDEN;
......
......@@ -306,9 +306,9 @@ static void get_selection_rect( ME_Context *c, ME_Run *run, int from, int to, in
{
from = max( 0, from );
to = min( run->len, to );
r->left = ME_PointFromCharContext( c, run, from );
r->left = ME_PointFromCharContext( c, run, from, TRUE );
r->top = 0;
r->right = ME_PointFromCharContext( c, run, to );
r->right = ME_PointFromCharContext( c, run, to, TRUE );
r->bottom = cy;
return;
}
......@@ -1235,7 +1235,7 @@ void ME_EnsureVisible(ME_TextEditor *editor, ME_Cursor *pCursor)
if (editor->styleFlags & ES_AUTOHSCROLL)
{
x = pRun->pt.x + ME_PointFromChar(editor, pRun, pCursor->nOffset);
x = pRun->pt.x + ME_PointFromChar(editor, pRun, pCursor->nOffset, TRUE);
if (x > editor->horz_si.nPos + editor->sizeWindow.cx)
x = x + 1 - editor->sizeWindow.cx;
else if (x > editor->horz_si.nPos)
......
......@@ -415,7 +415,7 @@ void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run)
* closest = FALSE cx = 0..7 return 0, cx = 8..15 return 1
* closest = TRUE cx = 0..3 return 0, cx = 4..11 return 1.
*/
int ME_CharFromPointContext(ME_Context *c, int cx, ME_Run *run, BOOL closest)
int ME_CharFromPointContext(ME_Context *c, int cx, ME_Run *run, BOOL closest, BOOL visual_order)
{
ME_String *mask_text = NULL;
WCHAR *str;
......@@ -464,13 +464,13 @@ int ME_CharFromPointContext(ME_Context *c, int cx, ME_Run *run, BOOL closest)
return fit;
}
int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Run *run, BOOL closest)
int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Run *run, BOOL closest, BOOL visual_order)
{
ME_Context c;
int ret;
ME_InitContext( &c, editor, ITextHost_TxGetDC( editor->texthost ) );
ret = ME_CharFromPointContext( &c, cx, run, closest );
ret = ME_CharFromPointContext( &c, cx, run, closest, visual_order );
ME_DestroyContext(&c);
return ret;
}
......@@ -499,7 +499,7 @@ static void ME_GetTextExtent(ME_Context *c, LPCWSTR szText, int nChars, ME_Style
* Returns a run-relative pixel position given a run-relative character
* position (character offset)
*/
int ME_PointFromCharContext(ME_Context *c, ME_Run *pRun, int nOffset)
int ME_PointFromCharContext(ME_Context *c, ME_Run *pRun, int nOffset, BOOL visual_order)
{
SIZE size;
ME_String *mask_text = NULL;
......@@ -532,13 +532,13 @@ int ME_PointFromCharContext(ME_Context *c, ME_Run *pRun, int nOffset)
*
* Calls ME_PointFromCharContext after first creating a context.
*/
int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset)
int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset, BOOL visual_order)
{
ME_Context c;
int ret;
ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
ret = ME_PointFromCharContext( &c, pRun, nOffset );
ret = ME_PointFromCharContext( &c, pRun, nOffset, visual_order );
ME_DestroyContext(&c);
return ret;
......
......@@ -107,7 +107,7 @@ static ME_DisplayItem *split_run_extents(ME_WrapContext *wc, ME_DisplayItem *ite
static int find_split_point( ME_Context *c, int cx, ME_Run *run )
{
if (!run->len || cx <= 0) return 0;
return ME_CharFromPointContext( c, cx, run, FALSE );
return ME_CharFromPointContext( c, cx, run, FALSE, FALSE );
}
static ME_DisplayItem *ME_MakeRow(int height, int baseline, int width)
......
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