From 5ddfc36cc0c2c5055f666eac641a4d7538e96322 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Wed, 17 Apr 2013 12:56:37 +0100 Subject: [PATCH] riched20: Add a visual vs logical order flag to the character to position mapping routines. --- dlls/riched20/caret.c | 6 +++--- dlls/riched20/editor.c | 2 +- dlls/riched20/editor.h | 8 ++++---- dlls/riched20/paint.c | 6 +++--- dlls/riched20/run.c | 12 ++++++------ dlls/riched20/wrap.c | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index b41ee9ebcde..b39a8c7e10d 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -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; } diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index f49079914a7..1b4788cc9c4 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -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; diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h index f7cac1f4aae..d34fbd0fbbf 100644 --- a/dlls/riched20/editor.h +++ b/dlls/riched20/editor.h @@ -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; diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c index 0ab4e2b11ab..80d9586940b 100644 --- a/dlls/riched20/paint.c +++ b/dlls/riched20/paint.c @@ -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) diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c index 010fb80067c..4bb1c0b7857 100644 --- a/dlls/riched20/run.c +++ b/dlls/riched20/run.c @@ -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; diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c index 9bebd8a28c2..ebb7b295896 100644 --- a/dlls/riched20/wrap.c +++ b/dlls/riched20/wrap.c @@ -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) -- 2.11.4.GIT