riched20: Use row and para helpers for the selection function.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0fda889f35
commit
aaf29c7991
|
@ -818,38 +818,28 @@ ME_SelectByType(ME_TextEditor *editor, ME_SelectionType selectionType)
|
||||||
editor->pCursors[1] = editor->pCursors[0];
|
editor->pCursors[1] = editor->pCursors[0];
|
||||||
ME_MoveCursorWords(editor, &editor->pCursors[1], -1);
|
ME_MoveCursorWords(editor, &editor->pCursors[1], -1);
|
||||||
break;
|
break;
|
||||||
case stLine:
|
|
||||||
case stParagraph:
|
case stParagraph:
|
||||||
{
|
editor->pCursors[1] = editor->pCursors[0];
|
||||||
ME_DisplayItem *pItem;
|
|
||||||
ME_DIType fwdSearchType, backSearchType;
|
|
||||||
if (selectionType == stParagraph) {
|
|
||||||
backSearchType = diParagraph;
|
|
||||||
fwdSearchType = diParagraphOrEnd;
|
|
||||||
} else {
|
|
||||||
backSearchType = diStartRow;
|
|
||||||
fwdSearchType = diStartRowOrParagraphOrEnd;
|
|
||||||
}
|
|
||||||
pItem = ME_FindItemFwd(editor->pCursors[0].pRun, fwdSearchType);
|
|
||||||
assert(pItem);
|
|
||||||
if (pItem->type == diTextEnd)
|
|
||||||
editor->pCursors[0].pRun = ME_FindItemBack(pItem, diRun);
|
|
||||||
else
|
|
||||||
editor->pCursors[0].pRun = ME_FindItemFwd(pItem, diRun);
|
|
||||||
editor->pCursors[0].pPara = ME_GetParagraph(editor->pCursors[0].pRun);
|
|
||||||
editor->pCursors[0].nOffset = 0;
|
|
||||||
|
|
||||||
pItem = ME_FindItemBack(pItem, backSearchType);
|
editor->pCursors[0].pRun = run_get_di( para_end_run( &editor->pCursors[0].pPara->member.para ) );
|
||||||
editor->pCursors[1].pRun = ME_FindItemFwd(pItem, diRun);
|
editor->pCursors[0].pPara = para_get_di( editor->pCursors[0].pRun->member.run.para );
|
||||||
editor->pCursors[1].pPara = ME_GetParagraph(editor->pCursors[1].pRun);
|
editor->pCursors[0].nOffset = editor->pCursors[0].pRun->member.run.len;
|
||||||
|
|
||||||
|
editor->pCursors[1].pRun = run_get_di( para_first_run( &editor->pCursors[1].pPara->member.para ) );
|
||||||
editor->pCursors[1].nOffset = 0;
|
editor->pCursors[1].nOffset = 0;
|
||||||
break;
|
break;
|
||||||
|
case stLine:
|
||||||
|
{
|
||||||
|
ME_Row *row = row_from_cursor( editor->pCursors );
|
||||||
|
|
||||||
|
row_first_cursor( row, editor->pCursors + 1 );
|
||||||
|
row_end_cursor( row, editor->pCursors, TRUE );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case stDocument:
|
case stDocument:
|
||||||
/* Select everything with cursor anchored from the start of the text */
|
/* Select everything with cursor anchored from the start of the text */
|
||||||
editor->nSelectionType = stDocument;
|
|
||||||
ME_SetCursorToStart(editor, &editor->pCursors[1]);
|
ME_SetCursorToStart(editor, &editor->pCursors[1]);
|
||||||
ME_SetCursorToEnd(editor, &editor->pCursors[0], FALSE);
|
ME_SetCursorToEnd(editor, &editor->pCursors[0], TRUE);
|
||||||
break;
|
break;
|
||||||
default: assert(0);
|
default: assert(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,10 @@ int ME_ReverseFindNonWhitespaceV(const ME_String *s, int nVChar) DECLSPEC_HIDDEN
|
||||||
int ME_ReverseFindWhitespaceV(const ME_String *s, int nVChar) DECLSPEC_HIDDEN;
|
int ME_ReverseFindWhitespaceV(const ME_String *s, int nVChar) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
/* row.c */
|
/* row.c */
|
||||||
|
void row_end_cursor( ME_Row *row, ME_Cursor *cursor, BOOL include_eop ) DECLSPEC_HIDDEN;
|
||||||
|
void row_first_cursor( ME_Row *row, ME_Cursor *cursor ) DECLSPEC_HIDDEN;
|
||||||
ME_Run *row_first_run( ME_Row *row ) DECLSPEC_HIDDEN;
|
ME_Run *row_first_run( ME_Row *row ) DECLSPEC_HIDDEN;
|
||||||
|
ME_Row *row_from_cursor( ME_Cursor *cursor ) DECLSPEC_HIDDEN;
|
||||||
ME_Row *row_next( ME_Row *row ) DECLSPEC_HIDDEN;
|
ME_Row *row_next( ME_Row *row ) DECLSPEC_HIDDEN;
|
||||||
ME_Run *row_next_run( ME_Row *row, ME_Run *run ) DECLSPEC_HIDDEN;
|
ME_Run *row_next_run( ME_Row *row, ME_Run *run ) DECLSPEC_HIDDEN;
|
||||||
ME_DisplayItem *ME_RowStart(ME_DisplayItem *item) DECLSPEC_HIDDEN;
|
ME_DisplayItem *ME_RowStart(ME_DisplayItem *item) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -53,6 +53,35 @@ ME_Run *row_next_run( ME_Row *row, ME_Run *run )
|
||||||
return &item->member.run;
|
return &item->member.run;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ME_Row *row_from_cursor( ME_Cursor *cursor )
|
||||||
|
{
|
||||||
|
ME_DisplayItem *item;
|
||||||
|
|
||||||
|
item = ME_FindItemBack( cursor->pRun, diStartRow );
|
||||||
|
return &item->member.row;
|
||||||
|
}
|
||||||
|
|
||||||
|
void row_first_cursor( ME_Row *row, ME_Cursor *cursor )
|
||||||
|
{
|
||||||
|
ME_DisplayItem *item;
|
||||||
|
|
||||||
|
item = ME_FindItemFwd( row_get_di( row ), diRun );
|
||||||
|
cursor->pRun = item;
|
||||||
|
cursor->pPara = para_get_di( cursor->pRun->member.run.para );
|
||||||
|
cursor->nOffset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void row_end_cursor( ME_Row *row, ME_Cursor *cursor, BOOL include_eop )
|
||||||
|
{
|
||||||
|
ME_DisplayItem *item, *run;
|
||||||
|
|
||||||
|
item = ME_FindItemFwd( row_get_di( row ), diStartRowOrParagraphOrEnd );
|
||||||
|
run = ME_FindItemBack( item, diRun );
|
||||||
|
cursor->pRun = run;
|
||||||
|
cursor->pPara = para_get_di( cursor->pRun->member.run.para );
|
||||||
|
cursor->nOffset = (item->type == diStartRow || include_eop) ? cursor->pRun->member.run.len : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* I'm sure these functions would simplify some code in caret ops etc,
|
/* I'm sure these functions would simplify some code in caret ops etc,
|
||||||
* I just didn't remember them when I wrote that code
|
* I just didn't remember them when I wrote that code
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue