Commit 4d72bde6 authored by Fabian Maurer's avatar Fabian Maurer Committed by Alexandre Julliard

riched20: Extract handling of VK_RETURN into a method.

This is basically a no-op to make the following fix simpler Signed-off-by: 's avatarFabian Maurer <dark.shadow4@web.de> Signed-off-by: 's avatarHuw Davies <huw@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 7b742485
......@@ -2427,72 +2427,11 @@ static void ME_UpdateSelectionLinkAttribute(ME_TextEditor *editor)
ME_UpdateLinkAttribute(editor, &start, nChars);
}
static BOOL
ME_KeyDown(ME_TextEditor *editor, WORD nKey)
static BOOL handle_enter(ME_TextEditor *editor)
{
BOOL ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000;
BOOL shift_is_down = GetKeyState(VK_SHIFT) & 0x8000;
if (editor->bMouseCaptured)
return FALSE;
if (nKey != VK_SHIFT && nKey != VK_CONTROL && nKey != VK_MENU)
editor->nSelectionType = stPosition;
switch (nKey)
{
case VK_LEFT:
case VK_RIGHT:
case VK_HOME:
case VK_END:
editor->nUDArrowX = -1;
/* fall through */
case VK_UP:
case VK_DOWN:
case VK_PRIOR:
case VK_NEXT:
ME_CommitUndo(editor); /* End coalesced undos for typed characters */
ME_ArrowKey(editor, nKey, shift_is_down, ctrl_is_down);
return TRUE;
case VK_BACK:
case VK_DELETE:
editor->nUDArrowX = -1;
/* FIXME backspace and delete aren't the same, they act different wrt paragraph style of the merged paragraph */
if (editor->styleFlags & ES_READONLY)
return FALSE;
if (ME_IsSelection(editor))
{
ME_DeleteSelection(editor);
ME_CommitUndo(editor);
}
else if (nKey == VK_DELETE)
{
/* Delete stops group typing.
* (See MSDN remarks on EM_STOPGROUPTYPING message) */
ME_DeleteTextAtCursor(editor, 1, 1);
ME_CommitUndo(editor);
}
else if (ME_ArrowKey(editor, VK_LEFT, FALSE, FALSE))
{
BOOL bDeletionSucceeded;
/* Backspace can be grouped for a single undo */
ME_ContinueCoalescingTransaction(editor);
bDeletionSucceeded = ME_DeleteTextAtCursor(editor, 1, 1);
if (!bDeletionSucceeded && !editor->bEmulateVersion10) { /* v4.1 */
/* Deletion was prevented so the cursor is moved back to where it was.
* (e.g. this happens when trying to delete cell boundaries)
*/
ME_ArrowKey(editor, VK_RIGHT, FALSE, FALSE);
}
ME_CommitCoalescingUndo(editor);
}
else
return TRUE;
ME_MoveCursorFromTableRowStartParagraph(editor);
ME_UpdateSelectionLinkAttribute(editor);
ME_UpdateRepaint(editor, FALSE);
ME_SendRequestResize(editor, FALSE);
return TRUE;
case VK_RETURN:
if (editor->bDialogMode)
{
if (ctrl_is_down)
......@@ -2527,7 +2466,8 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
int from, to;
ME_Style *style, *eop_style;
if (editor->styleFlags & ES_READONLY) {
if (editor->styleFlags & ES_READONLY)
{
MessageBeep(MB_ICONERROR);
return TRUE;
}
......@@ -2535,8 +2475,10 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
ME_GetSelectionOfs(editor, &from, &to);
if (editor->nTextLimit > ME_GetTextLength(editor) - (to-from))
{
if (!editor->bEmulateVersion10) { /* v4.1 */
if (para->member.para.nFlags & MEPF_ROWEND) {
if (!editor->bEmulateVersion10) /* v4.1 */
{
if (para->member.para.nFlags & MEPF_ROWEND)
{
/* Add a new table row after this row. */
para = ME_AppendTableRow(editor, para);
para = para->member.para.next_para;
......@@ -2575,13 +2517,16 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
ME_UpdateRepaint(editor, FALSE);
return TRUE;
}
} else { /* v1.0 - 3.0 */
}
else /* v1.0 - 3.0 */
{
ME_DisplayItem *para = cursor.pPara;
if (ME_IsInTable(para))
{
if (cursor.pRun->member.run.nFlags & MERF_ENDPARA)
{
if (from == to) {
if (from == to)
{
ME_ContinueCoalescingTransaction(editor);
para = ME_AppendTableRow(editor, para);
editor->pCursors[0].pPara = para;
......@@ -2592,14 +2537,17 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
ME_UpdateRepaint(editor, FALSE);
return TRUE;
}
} else {
}
else
{
ME_ContinueCoalescingTransaction(editor);
if (cursor.pRun->member.run.nCharOfs + cursor.nOffset == 0 &&
!ME_IsInTable(para->member.para.prev_para))
{
/* Insert newline before table */
cursor.pRun = ME_FindItemBack(para, diRun);
if (cursor.pRun) {
if (cursor.pRun)
{
editor->pCursors[0].pRun = cursor.pRun;
editor->pCursors[0].pPara = para->member.para.prev_para;
}
......@@ -2607,7 +2555,9 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
editor->pCursors[1] = editor->pCursors[0];
ME_InsertTextFromCursor(editor, 0, &endl, 1,
editor->pCursors[0].pRun->member.run.style);
} else {
}
else
{
editor->pCursors[1] = editor->pCursors[0];
para = ME_AppendTableRow(editor, para);
editor->pCursors[0].pPara = para;
......@@ -2649,7 +2599,76 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
}
return TRUE;
}
break;
return FALSE;
}
static BOOL
ME_KeyDown(ME_TextEditor *editor, WORD nKey)
{
BOOL ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000;
BOOL shift_is_down = GetKeyState(VK_SHIFT) & 0x8000;
if (editor->bMouseCaptured)
return FALSE;
if (nKey != VK_SHIFT && nKey != VK_CONTROL && nKey != VK_MENU)
editor->nSelectionType = stPosition;
switch (nKey)
{
case VK_LEFT:
case VK_RIGHT:
case VK_HOME:
case VK_END:
editor->nUDArrowX = -1;
/* fall through */
case VK_UP:
case VK_DOWN:
case VK_PRIOR:
case VK_NEXT:
ME_CommitUndo(editor); /* End coalesced undos for typed characters */
ME_ArrowKey(editor, nKey, shift_is_down, ctrl_is_down);
return TRUE;
case VK_BACK:
case VK_DELETE:
editor->nUDArrowX = -1;
/* FIXME backspace and delete aren't the same, they act different wrt paragraph style of the merged paragraph */
if (editor->styleFlags & ES_READONLY)
return FALSE;
if (ME_IsSelection(editor))
{
ME_DeleteSelection(editor);
ME_CommitUndo(editor);
}
else if (nKey == VK_DELETE)
{
/* Delete stops group typing.
* (See MSDN remarks on EM_STOPGROUPTYPING message) */
ME_DeleteTextAtCursor(editor, 1, 1);
ME_CommitUndo(editor);
}
else if (ME_ArrowKey(editor, VK_LEFT, FALSE, FALSE))
{
BOOL bDeletionSucceeded;
/* Backspace can be grouped for a single undo */
ME_ContinueCoalescingTransaction(editor);
bDeletionSucceeded = ME_DeleteTextAtCursor(editor, 1, 1);
if (!bDeletionSucceeded && !editor->bEmulateVersion10) { /* v4.1 */
/* Deletion was prevented so the cursor is moved back to where it was.
* (e.g. this happens when trying to delete cell boundaries)
*/
ME_ArrowKey(editor, VK_RIGHT, FALSE, FALSE);
}
ME_CommitCoalescingUndo(editor);
}
else
return TRUE;
ME_MoveCursorFromTableRowStartParagraph(editor);
ME_UpdateSelectionLinkAttribute(editor);
ME_UpdateRepaint(editor, FALSE);
ME_SendRequestResize(editor, FALSE);
return TRUE;
case VK_RETURN:
return handle_enter(editor);
case VK_ESCAPE:
if (editor->bDialogMode && editor->hwndParent)
PostMessageW(editor->hwndParent, WM_CLOSE, 0, 0);
......
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