riched20: Allow selecting the final end-of-paragraph when using the right arrow key.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c005b98d91
commit
58a48aa79b
|
@ -200,7 +200,7 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to)
|
||||||
|
|
||||||
ME_CursorFromCharOfs(editor, from, &editor->pCursors[1]);
|
ME_CursorFromCharOfs(editor, from, &editor->pCursors[1]);
|
||||||
editor->pCursors[0] = 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. */
|
/* Selection is not allowed in the middle of an end paragraph run. */
|
||||||
if (editor->pCursors[1].pRun->member.run.nFlags & MERF_ENDPARA)
|
if (editor->pCursors[1].pRun->member.run.nFlags & MERF_ENDPARA)
|
||||||
editor->pCursors[1].nOffset = 0;
|
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)
|
/* 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.
|
* 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;
|
cursor->nOffset += nRelOfs;
|
||||||
if (cursor->nOffset < 0)
|
if (cursor->nOffset < 0)
|
||||||
|
@ -682,11 +683,11 @@ int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
|
||||||
return 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 */
|
/* new offset at the end of the text */
|
||||||
ME_SetCursorToEnd(editor, cursor, FALSE);
|
ME_SetCursorToEnd(editor, cursor, final_eop);
|
||||||
nRelOfs -= new_offset - ME_GetTextLength(editor);
|
nRelOfs -= new_offset - (ME_GetTextLength(editor) + (final_eop ? 1 : 0));
|
||||||
return nRelOfs;
|
return nRelOfs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1547,14 +1548,14 @@ ME_ArrowKey(ME_TextEditor *editor, int nVKey, BOOL extend, BOOL ctrl)
|
||||||
if (ctrl)
|
if (ctrl)
|
||||||
success = ME_MoveCursorWords(editor, &tmp_curs, -1);
|
success = ME_MoveCursorWords(editor, &tmp_curs, -1);
|
||||||
else
|
else
|
||||||
success = ME_MoveCursorChars(editor, &tmp_curs, -1);
|
success = ME_MoveCursorChars(editor, &tmp_curs, -1, extend);
|
||||||
break;
|
break;
|
||||||
case VK_RIGHT:
|
case VK_RIGHT:
|
||||||
editor->bCaretAtEnd = FALSE;
|
editor->bCaretAtEnd = FALSE;
|
||||||
if (ctrl)
|
if (ctrl)
|
||||||
success = ME_MoveCursorWords(editor, &tmp_curs, +1);
|
success = ME_MoveCursorWords(editor, &tmp_curs, +1);
|
||||||
else
|
else
|
||||||
success = ME_MoveCursorChars(editor, &tmp_curs, +1);
|
success = ME_MoveCursorChars(editor, &tmp_curs, +1, extend);
|
||||||
break;
|
break;
|
||||||
case VK_UP:
|
case VK_UP:
|
||||||
ME_MoveCursorLines(editor, &tmp_curs, -1);
|
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;
|
int linebreakSize = editor->bEmulateVersion10 ? 2 : 1;
|
||||||
ME_Cursor linebreakCursor = *selEnd;
|
ME_Cursor linebreakCursor = *selEnd;
|
||||||
|
|
||||||
ME_MoveCursorChars(editor, &linebreakCursor, -linebreakSize);
|
ME_MoveCursorChars(editor, &linebreakCursor, -linebreakSize, FALSE);
|
||||||
ME_GetTextW(editor, lastchar, 2, &linebreakCursor, linebreakSize, FALSE, FALSE);
|
ME_GetTextW(editor, lastchar, 2, &linebreakCursor, linebreakSize, FALSE, FALSE);
|
||||||
if (lastchar[0] == '\r' && (lastchar[1] == '\n' || lastchar[1] == '\0')) {
|
if (lastchar[0] == '\r' && (lastchar[1] == '\n' || lastchar[1] == '\0')) {
|
||||||
ME_InternalDeleteText(editor, &linebreakCursor, linebreakSize, FALSE);
|
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);
|
ME_CursorFromCharOfs(editor, nMin - 1, &cursor);
|
||||||
wLastChar = *get_text( &cursor.pRun->member.run, cursor.nOffset );
|
wLastChar = *get_text( &cursor.pRun->member.run, cursor.nOffset );
|
||||||
ME_MoveCursorChars(editor, &cursor, 1);
|
ME_MoveCursorChars(editor, &cursor, 1, FALSE);
|
||||||
} else {
|
} else {
|
||||||
ME_CursorFromCharOfs(editor, nMin, &cursor);
|
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);
|
ME_CursorFromCharOfs(editor, nMax + 1, &cursor);
|
||||||
wLastChar = *get_text( &cursor.pRun->member.run, cursor.nOffset );
|
wLastChar = *get_text( &cursor.pRun->member.run, cursor.nOffset );
|
||||||
ME_MoveCursorChars(editor, &cursor, -1);
|
ME_MoveCursorChars(editor, &cursor, -1, FALSE);
|
||||||
} else {
|
} else {
|
||||||
ME_CursorFromCharOfs(editor, nMax, &cursor);
|
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,
|
void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
|
||||||
const WCHAR *str, int len, ME_Style *style) DECLSPEC_HIDDEN;
|
const WCHAR *str, int len, ME_Style *style) DECLSPEC_HIDDEN;
|
||||||
void ME_InsertEndRowFromCursor(ME_TextEditor *editor, int nCursor) 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;
|
BOOL ME_ArrowKey(ME_TextEditor *ed, int nVKey, BOOL extend, BOOL ctrl) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
int ME_GetCursorOfs(const ME_Cursor *cursor) 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);
|
ME_CursorFromCharOfs(reole->editor, pos, &from);
|
||||||
to = from;
|
to = from;
|
||||||
ME_MoveCursorChars(reole->editor, &to, 1);
|
ME_MoveCursorChars(reole->editor, &to, 1, FALSE);
|
||||||
ME_GetCharFormat(reole->editor, &from, &to, &fmt);
|
ME_GetCharFormat(reole->editor, &from, &to, &fmt);
|
||||||
|
|
||||||
switch (propid)
|
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 *this_para = c->pPara;
|
||||||
ME_DisplayItem *end_para;
|
ME_DisplayItem *end_para;
|
||||||
|
|
||||||
ME_MoveCursorChars(editor, &c2, *nChars);
|
ME_MoveCursorChars(editor, &c2, *nChars, FALSE);
|
||||||
end_para = c2.pPara;
|
end_para = c2.pPara;
|
||||||
if (c2.pRun->member.run.nFlags & MERF_ENDPARA) {
|
if (c2.pRun->member.run.nFlags & MERF_ENDPARA) {
|
||||||
/* End offset might be in the middle of the end paragraph run.
|
/* 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_Cursor start, end;
|
||||||
ME_CursorFromCharOfs(editor, undo->u.set_char_fmt.pos, &start);
|
ME_CursorFromCharOfs(editor, undo->u.set_char_fmt.pos, &start);
|
||||||
end = 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);
|
ME_SetCharFormat(editor, &start, &end, &undo->u.set_char_fmt.fmt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -881,11 +881,8 @@ static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream,
|
||||||
ME_Cursor cursor = *start;
|
ME_Cursor cursor = *start;
|
||||||
ME_DisplayItem *prev_para = cursor.pPara;
|
ME_DisplayItem *prev_para = cursor.pPara;
|
||||||
ME_Cursor endCur = cursor;
|
ME_Cursor endCur = cursor;
|
||||||
int actual_chars;
|
|
||||||
|
|
||||||
actual_chars = ME_MoveCursorChars(editor, &endCur, nChars);
|
ME_MoveCursorChars(editor, &endCur, nChars, TRUE);
|
||||||
/* Include the final \r which MoveCursorChars will ignore. */
|
|
||||||
if (actual_chars != nChars) endCur.nOffset++;
|
|
||||||
|
|
||||||
if (!ME_StreamOutRTFHeader(pStream, dwFormat))
|
if (!ME_StreamOutRTFHeader(pStream, dwFormat))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Reference in New Issue