Commit c8862864 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Use run and para ptrs in the cursor move lines function.

parent 2c2020dd
...@@ -1241,13 +1241,17 @@ static void ...@@ -1241,13 +1241,17 @@ static void
ME_MoveCursorLines(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs, BOOL extend) ME_MoveCursorLines(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs, BOOL extend)
{ {
ME_DisplayItem *pRun = pCursor->pRun; ME_DisplayItem *pRun = pCursor->pRun;
ME_DisplayItem *pOldPara = pCursor->pPara; ME_Paragraph *old_para = &pCursor->pPara->member.para, *new_para;
ME_DisplayItem *pItem, *pNewPara; ME_DisplayItem *pItem;
int x = ME_GetXForArrow(editor, pCursor); int x = ME_GetXForArrow(editor, pCursor);
if (editor->bCaretAtEnd && !pCursor->nOffset) if (editor->bCaretAtEnd && !pCursor->nOffset)
if (!ME_PrevRun(&pOldPara, &pRun, TRUE)) {
return; ME_Run *prev = run_prev_all_paras( &pRun->member.run );
if (!prev) return;
pRun = run_get_di( prev );
old_para = prev->para;
}
if (nRelOfs == -1) if (nRelOfs == -1)
{ {
...@@ -1262,25 +1266,23 @@ ME_MoveCursorLines(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs, BOOL ...@@ -1262,25 +1266,23 @@ ME_MoveCursorLines(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs, BOOL
ME_SetCursorToStart(editor, pCursor); ME_SetCursorToStart(editor, pCursor);
return; return;
} }
pNewPara = ME_GetParagraph(pItem); new_para = &ME_GetParagraph(pItem)->member.para;
if (pOldPara->member.para.nFlags & MEPF_ROWEND || if (old_para->nFlags & MEPF_ROWEND ||
(pOldPara->member.para.pCell && (para_cell( old_para ) && para_cell( old_para ) != para_cell( new_para )))
pOldPara->member.para.pCell != pNewPara->member.para.pCell))
{ {
/* Brought out of a cell */ /* Brought out of a cell */
pNewPara = table_row_start( &pOldPara->member.para )->prev_para; new_para = para_prev( table_row_start( old_para ));
if (pNewPara->type == diTextStart) if (!new_para) return; /* At the top, so don't go anywhere. */
return; /* At the top, so don't go anywhere. */ pItem = ME_FindItemFwd( para_get_di( new_para ), diStartRow);
pItem = ME_FindItemFwd(pNewPara, diStartRow);
} }
if (pNewPara->member.para.nFlags & MEPF_ROWEND) if (new_para->nFlags & MEPF_ROWEND)
{ {
/* Brought into a table row */ /* Brought into a table row */
ME_Cell *cell = &ME_FindItemBack(pNewPara, diCell)->member.cell; ME_Cell *cell = table_row_end_cell( new_para );
while (x < cell->pt.x && cell->prev_cell) while (x < cell->pt.x && cell_prev( cell ))
cell = &cell->prev_cell->member.cell; cell = cell_prev( cell );
if (cell->next_cell) /* else - we are still at the end of the row */ if (cell_next( cell )) /* else - we are still at the end of the row */
pItem = ME_FindItemBack(cell->next_cell, diStartRow); pItem = ME_FindItemBack( cell_get_di( cell_next( cell ) ), diStartRow );
} }
} }
else else
...@@ -1293,25 +1295,22 @@ ME_MoveCursorLines(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs, BOOL ...@@ -1293,25 +1295,22 @@ ME_MoveCursorLines(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs, BOOL
ME_SetCursorToEnd(editor, pCursor, TRUE); ME_SetCursorToEnd(editor, pCursor, TRUE);
return; return;
} }
pNewPara = ME_GetParagraph(pItem); new_para = &ME_GetParagraph(pItem)->member.para;
if (pOldPara->member.para.nFlags & MEPF_ROWSTART || if (old_para->nFlags & MEPF_ROWSTART ||
(pOldPara->member.para.pCell && (para_cell( old_para ) && para_cell( old_para ) != para_cell( new_para )))
pOldPara->member.para.pCell != pNewPara->member.para.pCell))
{ {
/* Brought out of a cell */ /* Brought out of a cell */
pNewPara = table_row_end( &pOldPara->member.para )->next_para; new_para = para_next( table_row_end( old_para ) );
if (pNewPara->type == diTextEnd) if (!para_next( new_para )) return; /* At the bottom, so don't go anywhere. */
return; /* At the bottom, so don't go anywhere. */ pItem = ME_FindItemFwd( para_get_di( new_para ), diStartRow );
pItem = ME_FindItemFwd(pNewPara, diStartRow);
} }
if (pNewPara->member.para.nFlags & MEPF_ROWSTART) if (new_para->nFlags & MEPF_ROWSTART)
{ {
/* Brought into a table row */ /* Brought into a table row */
ME_DisplayItem *cell = ME_FindItemFwd(pNewPara, diCell); ME_Cell *cell = table_row_first_cell( new_para );
while (cell->member.cell.next_cell && while (cell_next( cell ) && x >= cell_next( cell )->pt.x)
x >= cell->member.cell.next_cell->member.cell.pt.x) cell = cell_next( cell );
cell = cell->member.cell.next_cell; pItem = ME_FindItemFwd( cell_get_di( cell ), diStartRow );
pItem = ME_FindItemFwd(cell, diStartRow);
} }
} }
if (!pItem) if (!pItem)
......
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