Commit 1abbb78a authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Use row and para ptrs in the ensure visible function.

parent 30ad0b93
......@@ -1176,13 +1176,11 @@ void ME_MouseMove(ME_TextEditor *editor, int x, int y)
if (editor->nSelectionType != stPosition &&
memcmp(&editor->pCursors[1], &editor->pCursors[3], sizeof(ME_Cursor)))
{
/* The scroll the cursor towards the other end, since it was the one
* extended by ME_ExtendAnchorSelection */
ME_EnsureVisible(editor, &editor->pCursors[1]);
} else {
ME_EnsureVisible(editor, &editor->pCursors[0]);
}
editor_ensure_visible( editor, &editor->pCursors[1] );
else
editor_ensure_visible( editor, &editor->pCursors[0] );
ME_InvalidateSelection(editor);
update_caret(editor);
......@@ -1520,7 +1518,7 @@ ME_ArrowKey(ME_TextEditor *editor, int nVKey, BOOL extend, BOOL ctrl)
ME_InvalidateSelection(editor);
ME_Repaint(editor);
hide_caret(editor);
ME_EnsureVisible(editor, &tmp_curs);
editor_ensure_visible( editor, &tmp_curs );
update_caret(editor);
ME_SendSelChange(editor);
return success;
......
......@@ -4095,7 +4095,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
return len;
}
case EM_SCROLLCARET:
ME_EnsureVisible(editor, &editor->pCursors[0]);
editor_ensure_visible( editor, &editor->pCursors[0] );
return 0;
case WM_SETFONT:
{
......
......@@ -242,7 +242,7 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, const RECT *rcUpdate) DECLS
void ME_Repaint(ME_TextEditor *editor) DECLSPEC_HIDDEN;
void ME_RewrapRepaint(ME_TextEditor *editor) DECLSPEC_HIDDEN;
void ME_UpdateRepaint(ME_TextEditor *editor, BOOL update_now) DECLSPEC_HIDDEN;
void ME_EnsureVisible(ME_TextEditor *editor, ME_Cursor *pCursor) DECLSPEC_HIDDEN;
void editor_ensure_visible( ME_TextEditor *editor, ME_Cursor *cursor ) DECLSPEC_HIDDEN;
void ME_InvalidateSelection(ME_TextEditor *editor) DECLSPEC_HIDDEN;
BOOL ME_SetZoom(ME_TextEditor *editor, int numerator, int denominator) DECLSPEC_HIDDEN;
int ME_twips2pointsX(const ME_Context *c, int x) DECLSPEC_HIDDEN;
......
......@@ -117,7 +117,7 @@ void ME_UpdateRepaint(ME_TextEditor *editor, BOOL update_now)
ME_UpdateScrollBar(editor);
/* Ensure that the cursor is visible */
ME_EnsureVisible(editor, &editor->pCursors[0]);
editor_ensure_visible( editor, &editor->pCursors[0] );
ITextHost_TxViewChange(editor->texthost, update_now);
......@@ -1269,19 +1269,17 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
}
}
void ME_EnsureVisible(ME_TextEditor *editor, ME_Cursor *pCursor)
void editor_ensure_visible( ME_TextEditor *editor, ME_Cursor *cursor )
{
ME_Run *pRun = &pCursor->pRun->member.run;
ME_DisplayItem *pRow = ME_FindItemBack(pCursor->pRun, diStartRow);
ME_DisplayItem *pPara = pCursor->pPara;
ME_Run *run = &cursor->pRun->member.run;
ME_Row *row = row_from_cursor( cursor );
ME_Paragraph *para = &cursor->pPara->member.para;
int x, y, yheight;
assert(pRow);
assert(pPara);
if (editor->styleFlags & ES_AUTOHSCROLL)
{
x = pRun->pt.x + ME_PointFromChar(editor, pRun, pCursor->nOffset, TRUE);
x = run->pt.x + ME_PointFromChar( editor, run, cursor->nOffset, TRUE );
if (x > editor->horz_si.nPos + editor->sizeWindow.cx)
x = x + 1 - editor->sizeWindow.cx;
else if (x > editor->horz_si.nPos)
......@@ -1292,14 +1290,15 @@ void ME_EnsureVisible(ME_TextEditor *editor, ME_Cursor *pCursor)
ME_HScrollAbs(editor, x);
return;
}
} else {
if (~editor->styleFlags & ES_AUTOVSCROLL)
return;
}
else
{
if (~editor->styleFlags & ES_AUTOVSCROLL) return;
x = editor->horz_si.nPos;
}
y = pPara->member.para.pt.y + pRow->member.row.pt.y;
yheight = pRow->member.row.nHeight;
y = para->pt.y + row->pt.y;
yheight = row->nHeight;
if (y < editor->vert_si.nPos)
ME_ScrollAbs(editor, x, y);
......
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