Commit 58a48aa7 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Allow selecting the final end-of-paragraph when using the right arrow key.

parent c005b98d
......@@ -200,7 +200,7 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to)
ME_CursorFromCharOfs(editor, from, &editor->pCursors[1]);
editor->pCursors[0] = editor->pCursors[1];
ME_MoveCursorChars(editor, &editor->pCursors[0], to - from);
ME_MoveCursorChars(editor, &editor->pCursors[0], to - from, FALSE);
/* Selection is not allowed in the middle of an end paragraph run. */
if (editor->pCursors[1].pRun->member.run.nFlags & MERF_ENDPARA)
editor->pCursors[1].nOffset = 0;
......@@ -627,10 +627,11 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
}
/* Move the cursor nRelOfs characters (either forwards or backwards)
* If final_eop is TRUE, allow moving the cursor to the end of the final eop.
*
* returns the actual number of characters moved.
**/
int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs, BOOL final_eop)
{
cursor->nOffset += nRelOfs;
if (cursor->nOffset < 0)
......@@ -682,11 +683,11 @@ int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
return nRelOfs;
}
if (new_offset >= ME_GetTextLength(editor))
if (new_offset >= ME_GetTextLength(editor) + (final_eop ? 1 : 0))
{
/* new offset at the end of the text */
ME_SetCursorToEnd(editor, cursor, FALSE);
nRelOfs -= new_offset - ME_GetTextLength(editor);
ME_SetCursorToEnd(editor, cursor, final_eop);
nRelOfs -= new_offset - (ME_GetTextLength(editor) + (final_eop ? 1 : 0));
return nRelOfs;
}
......@@ -1547,14 +1548,14 @@ ME_ArrowKey(ME_TextEditor *editor, int nVKey, BOOL extend, BOOL ctrl)
if (ctrl)
success = ME_MoveCursorWords(editor, &tmp_curs, -1);
else
success = ME_MoveCursorChars(editor, &tmp_curs, -1);
success = ME_MoveCursorChars(editor, &tmp_curs, -1, extend);
break;
case VK_RIGHT:
editor->bCaretAtEnd = FALSE;
if (ctrl)
success = ME_MoveCursorWords(editor, &tmp_curs, +1);
else
success = ME_MoveCursorChars(editor, &tmp_curs, +1);
success = ME_MoveCursorChars(editor, &tmp_curs, +1, extend);
break;
case VK_UP:
ME_MoveCursorLines(editor, &tmp_curs, -1);
......
......@@ -1650,7 +1650,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
int linebreakSize = editor->bEmulateVersion10 ? 2 : 1;
ME_Cursor linebreakCursor = *selEnd;
ME_MoveCursorChars(editor, &linebreakCursor, -linebreakSize);
ME_MoveCursorChars(editor, &linebreakCursor, -linebreakSize, FALSE);
ME_GetTextW(editor, lastchar, 2, &linebreakCursor, linebreakSize, FALSE, FALSE);
if (lastchar[0] == '\r' && (lastchar[1] == '\n' || lastchar[1] == '\0')) {
ME_InternalDeleteText(editor, &linebreakCursor, linebreakSize, FALSE);
......@@ -1805,7 +1805,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
{
ME_CursorFromCharOfs(editor, nMin - 1, &cursor);
wLastChar = *get_text( &cursor.pRun->member.run, cursor.nOffset );
ME_MoveCursorChars(editor, &cursor, 1);
ME_MoveCursorChars(editor, &cursor, 1, FALSE);
} else {
ME_CursorFromCharOfs(editor, nMin, &cursor);
}
......@@ -1881,7 +1881,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
{
ME_CursorFromCharOfs(editor, nMax + 1, &cursor);
wLastChar = *get_text( &cursor.pRun->member.run, cursor.nOffset );
ME_MoveCursorChars(editor, &cursor, -1);
ME_MoveCursorChars(editor, &cursor, -1, FALSE);
} else {
ME_CursorFromCharOfs(editor, nMax, &cursor);
}
......
......@@ -178,7 +178,7 @@ BOOL ME_DeleteTextAtCursor(ME_TextEditor *editor, int nCursor, int nChars) DECLS
void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
const WCHAR *str, int len, ME_Style *style) DECLSPEC_HIDDEN;
void ME_InsertEndRowFromCursor(ME_TextEditor *editor, int nCursor) DECLSPEC_HIDDEN;
int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs) DECLSPEC_HIDDEN;
int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs, BOOL final_eop) DECLSPEC_HIDDEN;
BOOL ME_ArrowKey(ME_TextEditor *ed, int nVKey, BOOL extend, BOOL ctrl) DECLSPEC_HIDDEN;
int ME_GetCursorOfs(const ME_Cursor *cursor) DECLSPEC_HIDDEN;
......
......@@ -451,7 +451,7 @@ static HRESULT get_textfont_prop_for_pos(const IRichEditOleImpl *reole, int pos,
ME_CursorFromCharOfs(reole->editor, pos, &from);
to = from;
ME_MoveCursorChars(reole->editor, &to, 1);
ME_MoveCursorChars(reole->editor, &to, 1, FALSE);
ME_GetCharFormat(reole->editor, &from, &to, &fmt);
switch (propid)
......
......@@ -291,7 +291,7 @@ void ME_ProtectPartialTableDeletion(ME_TextEditor *editor, ME_Cursor *c, int *nC
ME_DisplayItem *this_para = c->pPara;
ME_DisplayItem *end_para;
ME_MoveCursorChars(editor, &c2, *nChars);
ME_MoveCursorChars(editor, &c2, *nChars, FALSE);
end_para = c2.pPara;
if (c2.pRun->member.run.nFlags & MERF_ENDPARA) {
/* End offset might be in the middle of the end paragraph run.
......
......@@ -349,7 +349,7 @@ static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo)
ME_Cursor start, end;
ME_CursorFromCharOfs(editor, undo->u.set_char_fmt.pos, &start);
end = start;
ME_MoveCursorChars(editor, &end, undo->u.set_char_fmt.len);
ME_MoveCursorChars(editor, &end, undo->u.set_char_fmt.len, FALSE);
ME_SetCharFormat(editor, &start, &end, &undo->u.set_char_fmt.fmt);
break;
}
......
......@@ -881,11 +881,8 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
ME_Cursor cursor = *start;
ME_DisplayItem *prev_para = cursor.pPara;
ME_Cursor endCur = cursor;
int actual_chars;
actual_chars = ME_MoveCursorChars(editor, &endCur, nChars);
/* Include the final \r which MoveCursorChars will ignore. */
if (actual_chars != nChars) endCur.nOffset++;
ME_MoveCursorChars(editor, &endCur, nChars, TRUE);
if (!ME_StreamOutRTFHeader(pStream, dwFormat))
return FALSE;
......
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