[PATCH 5/5] riched20: Use row ptrs in the cursor to co-ordinates function.

Huw Davies huw at codeweavers.com
Mon Oct 26 03:46:42 CDT 2020


Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/riched20/caret.c   | 24 +++++++++++-------------
 dlls/riched20/editor.h  |  2 +-
 dlls/riched20/richole.c |  4 ++--
 3 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index 49ae1b2769a..834f9fd3afe 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -218,31 +218,29 @@ int set_selection_cursors(ME_TextEditor *editor, int from, int to)
 }
 
 
-void ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor *pCursor,
-                             int *x, int *y, int *height)
+void cursor_coords( ME_TextEditor *editor, ME_Cursor *cursor,
+                    int *x, int *y, int *height )
 {
-  ME_DisplayItem *row;
-  ME_Run *run = &pCursor->pRun->member.run;
-  ME_Paragraph *para = &pCursor->pPara->member.para;
+  ME_Row *row;
+  ME_Run *run = &cursor->pRun->member.run;
+  ME_Paragraph *para = &cursor->pPara->member.para;
   ME_Run *size_run = run, *prev;
   ME_Context c;
   int run_x;
 
-  assert(height && x && y);
   assert(~para->nFlags & MEPF_REWRAP);
 
-  row = ME_FindItemBack( run_get_di( run ), diStartRowOrParagraph );
-  assert(row && row->type == diStartRow);
+  row = row_from_cursor( cursor );
 
   ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
 
-  if (!pCursor->nOffset && (prev = run_prev( run ))) size_run = prev;
+  if (!cursor->nOffset && (prev = run_prev( run ))) size_run = prev;
 
-  run_x = ME_PointFromCharContext( &c, run, pCursor->nOffset, TRUE );
+  run_x = ME_PointFromCharContext( &c, run, cursor->nOffset, TRUE );
 
   *height = size_run->nAscent + size_run->nDescent;
   *x = c.rcView.left + run->pt.x + run_x - editor->horz_si.nPos;
-  *y = c.rcView.top + para->pt.y + row->member.row.nBaseline
+  *y = c.rcView.top + para->pt.y + row->nBaseline
        + run->pt.y - size_run->nAscent - editor->vert_si.nPos;
   ME_DestroyContext(&c);
   return;
@@ -252,7 +250,7 @@ void create_caret(ME_TextEditor *editor)
 {
   int x, y, height;
 
-  ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height);
+  cursor_coords( editor, &editor->pCursors[0], &x, &y, &height );
   ITextHost_TxCreateCaret(editor->texthost, NULL, 0, height);
   editor->caret_height = height;
   editor->caret_hidden = TRUE;
@@ -281,7 +279,7 @@ void update_caret(ME_TextEditor *editor)
   if (!editor->bHaveFocus) return;
   if (!ME_IsSelection(editor))
   {
-    ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height);
+    cursor_coords( editor, &editor->pCursors[0], &x, &y, &height );
     if (height != editor->caret_height) create_caret(editor);
     x = min(x, editor->rcFormat.right-1);
     ITextHost_TxSetCaretPos(editor->texthost, x, y);
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index e197e3e9a9b..f4484f57d39 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -164,6 +164,7 @@ static inline ME_DisplayItem *run_get_di( ME_Run *run )
 }
 
 /* caret.c */
+void cursor_coords( ME_TextEditor *editor, ME_Cursor *cursor, int *x, int *y, int *height ) DECLSPEC_HIDDEN;
 void ME_SetCursorToStart(ME_TextEditor *editor, ME_Cursor *cursor) DECLSPEC_HIDDEN;
 int set_selection_cursors(ME_TextEditor *editor, int from, int to) DECLSPEC_HIDDEN;
 BOOL ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs) DECLSPEC_HIDDEN;
@@ -192,7 +193,6 @@ BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start, int nChars,
 int ME_GetTextLength(ME_TextEditor *editor) DECLSPEC_HIDDEN;
 int ME_GetTextLengthEx(ME_TextEditor *editor, const GETTEXTLENGTHEX *how) DECLSPEC_HIDDEN;
 ME_Style *ME_GetSelectionInsertStyle(ME_TextEditor *editor) DECLSPEC_HIDDEN;
-void ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor *pCursor, int *x, int *y, int *height) DECLSPEC_HIDDEN;
 
 /* context.c */
 void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC) DECLSPEC_HIDDEN;
diff --git a/dlls/riched20/richole.c b/dlls/riched20/richole.c
index 2f2e5e09d1f..21b63911954 100644
--- a/dlls/riched20/richole.c
+++ b/dlls/riched20/richole.c
@@ -2734,11 +2734,11 @@ static HRESULT WINAPI ITextRange_fnScrollIntoView(ITextRange *me, LONG value)
     {
     case tomStart:
         cursor_from_char_ofs( editor, This->start, &cursor );
-        ME_GetCursorCoordinates(editor, &cursor, &x, &y, &height);
+        cursor_coords( editor, &cursor, &x, &y, &height );
         break;
     case tomEnd:
         cursor_from_char_ofs( editor, This->end, &cursor );
-        ME_GetCursorCoordinates(editor, &cursor, &x, &y, &height);
+        cursor_coords( editor, &cursor, &x, &y, &height );
         break;
     default:
         FIXME("bStart value %d not handled\n", value);
-- 
2.23.0




More information about the wine-devel mailing list