riched20: Use row and para ptrs in the cursor up/down handler.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ab95fb31fc
commit
cb9353bca9
|
@ -1196,80 +1196,70 @@ static int ME_GetXForArrow(ME_TextEditor *editor, ME_Cursor *pCursor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void cursor_move_line( ME_TextEditor *editor, ME_Cursor *cursor, BOOL up, BOOL extend )
|
||||||
ME_MoveCursorLines(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs, BOOL extend)
|
|
||||||
{
|
{
|
||||||
ME_DisplayItem *pRun = run_get_di( pCursor->run );
|
ME_Paragraph *old_para = cursor->para, *new_para;
|
||||||
ME_Paragraph *old_para = pCursor->para, *new_para;
|
ME_Row *row = row_from_cursor( cursor );
|
||||||
ME_DisplayItem *pItem;
|
int x = ME_GetXForArrow( editor, cursor );
|
||||||
int x = ME_GetXForArrow(editor, pCursor);
|
|
||||||
|
|
||||||
if (nRelOfs == -1)
|
if (up)
|
||||||
{
|
|
||||||
/* start of this row */
|
|
||||||
pItem = ME_FindItemBack(pRun, diStartRow);
|
|
||||||
assert(pItem);
|
|
||||||
/* start of the previous row */
|
|
||||||
pItem = ME_FindItemBack(pItem, diStartRow);
|
|
||||||
if (!pItem) /* row not found */
|
|
||||||
{
|
{
|
||||||
if (extend)
|
/* start of the previous row */
|
||||||
ME_SetCursorToStart(editor, pCursor);
|
row = row_prev_all_paras( row );
|
||||||
return;
|
if (!row)
|
||||||
|
{
|
||||||
|
if (extend) ME_SetCursorToStart( editor, cursor );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
new_para = row_para( row );
|
||||||
|
if (old_para->nFlags & MEPF_ROWEND ||
|
||||||
|
(para_cell( old_para ) && para_cell( old_para ) != para_cell( new_para )))
|
||||||
|
{
|
||||||
|
/* Brought out of a cell */
|
||||||
|
new_para = para_prev( table_row_start( old_para ));
|
||||||
|
if (!new_para) return; /* At the top, so don't go anywhere. */
|
||||||
|
row = para_first_row( new_para );
|
||||||
|
}
|
||||||
|
if (new_para->nFlags & MEPF_ROWEND)
|
||||||
|
{
|
||||||
|
/* Brought into a table row */
|
||||||
|
ME_Cell *cell = table_row_end_cell( new_para );
|
||||||
|
while (x < cell->pt.x && cell_prev( cell ))
|
||||||
|
cell = cell_prev( cell );
|
||||||
|
if (cell_next( cell )) /* else - we are still at the end of the row */
|
||||||
|
row = para_end_row( cell_end_para( cell ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
new_para = &ME_GetParagraph(pItem)->member.para;
|
else
|
||||||
if (old_para->nFlags & MEPF_ROWEND ||
|
|
||||||
(para_cell( old_para ) && para_cell( old_para ) != para_cell( new_para )))
|
|
||||||
{
|
{
|
||||||
/* Brought out of a cell */
|
/* start of the next row */
|
||||||
new_para = para_prev( table_row_start( old_para ));
|
row = row_next_all_paras( row );
|
||||||
if (!new_para) return; /* At the top, so don't go anywhere. */
|
if (!row)
|
||||||
pItem = ME_FindItemFwd( para_get_di( new_para ), diStartRow);
|
{
|
||||||
|
if (extend) ME_SetCursorToEnd( editor, cursor, TRUE );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
new_para = row_para( row );
|
||||||
|
if (old_para->nFlags & MEPF_ROWSTART ||
|
||||||
|
(para_cell( old_para ) && para_cell( old_para ) != para_cell( new_para )))
|
||||||
|
{
|
||||||
|
/* Brought out of a cell */
|
||||||
|
new_para = para_next( table_row_end( old_para ) );
|
||||||
|
if (!para_next( new_para )) return; /* At the bottom, so don't go anywhere. */
|
||||||
|
row = para_first_row( new_para );
|
||||||
|
}
|
||||||
|
if (new_para->nFlags & MEPF_ROWSTART)
|
||||||
|
{
|
||||||
|
/* Brought into a table row */
|
||||||
|
ME_Cell *cell = table_row_first_cell( new_para );
|
||||||
|
while (cell_next( cell ) && x >= cell_next( cell )->pt.x)
|
||||||
|
cell = cell_next( cell );
|
||||||
|
row = para_first_row( cell_first_para( cell ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (new_para->nFlags & MEPF_ROWEND)
|
if (!row) return;
|
||||||
{
|
|
||||||
/* Brought into a table row */
|
row_cursor( editor, row, x, cursor );
|
||||||
ME_Cell *cell = table_row_end_cell( new_para );
|
|
||||||
while (x < cell->pt.x && cell_prev( cell ))
|
|
||||||
cell = cell_prev( cell );
|
|
||||||
if (cell_next( cell )) /* else - we are still at the end of the row */
|
|
||||||
pItem = ME_FindItemBack( cell_get_di( cell_next( cell ) ), diStartRow );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* start of the next row */
|
|
||||||
pItem = ME_FindItemFwd(pRun, diStartRow);
|
|
||||||
if (!pItem) /* row not found */
|
|
||||||
{
|
|
||||||
if (extend)
|
|
||||||
ME_SetCursorToEnd(editor, pCursor, TRUE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
new_para = &ME_GetParagraph(pItem)->member.para;
|
|
||||||
if (old_para->nFlags & MEPF_ROWSTART ||
|
|
||||||
(para_cell( old_para ) && para_cell( old_para ) != para_cell( new_para )))
|
|
||||||
{
|
|
||||||
/* Brought out of a cell */
|
|
||||||
new_para = para_next( table_row_end( old_para ) );
|
|
||||||
if (!para_next( new_para )) return; /* At the bottom, so don't go anywhere. */
|
|
||||||
pItem = ME_FindItemFwd( para_get_di( new_para ), diStartRow );
|
|
||||||
}
|
|
||||||
if (new_para->nFlags & MEPF_ROWSTART)
|
|
||||||
{
|
|
||||||
/* Brought into a table row */
|
|
||||||
ME_Cell *cell = table_row_first_cell( new_para );
|
|
||||||
while (cell_next( cell ) && x >= cell_next( cell )->pt.x)
|
|
||||||
cell = cell_next( cell );
|
|
||||||
pItem = ME_FindItemFwd( cell_get_di( cell ), diStartRow );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!pItem)
|
|
||||||
{
|
|
||||||
/* row not found - ignore */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
row_cursor( editor, &pItem->member.row, x, pCursor );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ME_ArrowPageUp( ME_TextEditor *editor, ME_Cursor *cursor )
|
static void ME_ArrowPageUp( ME_TextEditor *editor, ME_Cursor *cursor )
|
||||||
|
@ -1434,10 +1424,10 @@ ME_ArrowKey(ME_TextEditor *editor, int nVKey, BOOL extend, BOOL ctrl)
|
||||||
success = ME_MoveCursorChars(editor, &tmp_curs, +1, extend);
|
success = ME_MoveCursorChars(editor, &tmp_curs, +1, extend);
|
||||||
break;
|
break;
|
||||||
case VK_UP:
|
case VK_UP:
|
||||||
ME_MoveCursorLines(editor, &tmp_curs, -1, extend);
|
cursor_move_line( editor, &tmp_curs, TRUE, extend );
|
||||||
break;
|
break;
|
||||||
case VK_DOWN:
|
case VK_DOWN:
|
||||||
ME_MoveCursorLines(editor, &tmp_curs, +1, extend);
|
cursor_move_line( editor, &tmp_curs, FALSE, extend );
|
||||||
break;
|
break;
|
||||||
case VK_PRIOR:
|
case VK_PRIOR:
|
||||||
ME_ArrowPageUp(editor, &tmp_curs);
|
ME_ArrowPageUp(editor, &tmp_curs);
|
||||||
|
|
|
@ -208,7 +208,6 @@ void editor_get_selection_para_fmt( ME_TextEditor *editor, PARAFORMAT2 *fmt ) DE
|
||||||
void editor_mark_rewrap_all( ME_TextEditor *editor ) DECLSPEC_HIDDEN;
|
void editor_mark_rewrap_all( ME_TextEditor *editor ) DECLSPEC_HIDDEN;
|
||||||
void editor_set_default_para_fmt(ME_TextEditor *editor, PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN;
|
void editor_set_default_para_fmt(ME_TextEditor *editor, PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN;
|
||||||
BOOL editor_set_selection_para_fmt( ME_TextEditor *editor, const PARAFORMAT2 *fmt ) DECLSPEC_HIDDEN;
|
BOOL editor_set_selection_para_fmt( ME_TextEditor *editor, const PARAFORMAT2 *fmt ) DECLSPEC_HIDDEN;
|
||||||
ME_DisplayItem *ME_GetParagraph(ME_DisplayItem *run) DECLSPEC_HIDDEN;
|
|
||||||
void ME_MakeFirstParagraph(ME_TextEditor *editor) DECLSPEC_HIDDEN;
|
void ME_MakeFirstParagraph(ME_TextEditor *editor) DECLSPEC_HIDDEN;
|
||||||
void ME_DumpParaStyle(ME_Paragraph *s) DECLSPEC_HIDDEN;
|
void ME_DumpParaStyle(ME_Paragraph *s) DECLSPEC_HIDDEN;
|
||||||
void ME_DumpParaStyleToBuf(const PARAFORMAT2 *pFmt, char buf[2048]) DECLSPEC_HIDDEN;
|
void ME_DumpParaStyleToBuf(const PARAFORMAT2 *pFmt, char buf[2048]) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -794,10 +794,6 @@ ME_Paragraph *para_join( ME_TextEditor *editor, ME_Paragraph *para, BOOL use_fir
|
||||||
return para;
|
return para;
|
||||||
}
|
}
|
||||||
|
|
||||||
ME_DisplayItem *ME_GetParagraph(ME_DisplayItem *item) {
|
|
||||||
return ME_FindItemBackOrHere(item, diParagraph);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ME_DumpParaStyleToBuf(const PARAFORMAT2 *pFmt, char buf[2048])
|
void ME_DumpParaStyleToBuf(const PARAFORMAT2 *pFmt, char buf[2048])
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
|
Loading…
Reference in New Issue