riched20: Clearly separate the selection setting functions.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
14e34bedbf
commit
5419a9804a
|
@ -122,8 +122,14 @@ int ME_GetTextLengthEx(ME_TextEditor *editor, const GETTEXTLENGTHEX *how)
|
|||
return length;
|
||||
}
|
||||
|
||||
|
||||
int ME_SetSelection(ME_TextEditor *editor, int from, int to)
|
||||
/******************************************************************
|
||||
* set_selection_cursors
|
||||
*
|
||||
* Updates the selection cursors.
|
||||
*
|
||||
* Note that this does not invalidate either the old or the new selections.
|
||||
*/
|
||||
int set_selection_cursors(ME_TextEditor *editor, int from, int to)
|
||||
{
|
||||
int selectionEnd = 0;
|
||||
const int len = ME_GetTextLength(editor);
|
||||
|
@ -139,7 +145,6 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to)
|
|||
{
|
||||
ME_SetCursorToStart(editor, &editor->pCursors[1]);
|
||||
ME_SetCursorToEnd(editor, &editor->pCursors[0], TRUE);
|
||||
ME_InvalidateSelection(editor);
|
||||
return len + 1;
|
||||
}
|
||||
|
||||
|
@ -165,7 +170,6 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to)
|
|||
end --;
|
||||
}
|
||||
editor->pCursors[1] = editor->pCursors[0];
|
||||
ME_Repaint(editor);
|
||||
}
|
||||
return end;
|
||||
}
|
||||
|
@ -194,7 +198,6 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to)
|
|||
{
|
||||
ME_SetCursorToEnd(editor, &editor->pCursors[0], FALSE);
|
||||
editor->pCursors[1] = editor->pCursors[0];
|
||||
ME_InvalidateSelection(editor);
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
|
@ -1622,7 +1622,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
|
|||
} else {
|
||||
style = editor->pBuffer->pDefaultStyle;
|
||||
ME_AddRefStyle(style);
|
||||
ME_SetSelection(editor, 0, 0);
|
||||
set_selection_cursors(editor, 0, 0);
|
||||
ME_InternalDeleteText(editor, &editor->pCursors[1],
|
||||
ME_GetTextLength(editor), FALSE);
|
||||
from = to = 0;
|
||||
|
@ -1756,9 +1756,9 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
|
|||
cf.dwMask = CFM_ALL2;
|
||||
ME_MoveCursorChars(editor, &lastcharCursor, -1, FALSE);
|
||||
ME_GetCharFormat(editor, &lastcharCursor, &linebreakCursor, &cf);
|
||||
ME_SetSelection(editor, newto, -1);
|
||||
set_selection_cursors(editor, newto, -1);
|
||||
ME_SetSelectionCharFormat(editor, &cf);
|
||||
ME_SetSelection(editor, newto, newto);
|
||||
set_selection_cursors(editor, newto, newto);
|
||||
|
||||
ME_MoveCursorChars(editor, &linebreakCursor, -linebreakSize, FALSE);
|
||||
ME_GetTextW(editor, lastchar, 2, &linebreakCursor, linebreakSize, FALSE, FALSE);
|
||||
|
@ -1781,7 +1781,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
|
|||
ERR("EM_STREAMIN without SF_TEXT or SF_RTF\n");
|
||||
/* put the cursor at the top */
|
||||
if (!(format & SFF_SELECTION))
|
||||
ME_SetSelection(editor, 0, 0);
|
||||
set_selection_cursors(editor, 0, 0);
|
||||
ME_CursorFromCharOfs(editor, from, &start);
|
||||
ME_UpdateLinkAttribute(editor, &start, to - from);
|
||||
}
|
||||
|
@ -2147,14 +2147,14 @@ static int ME_GetTextRange(ME_TextEditor *editor, WCHAR *strText,
|
|||
}
|
||||
}
|
||||
|
||||
static int handle_EM_EXSETSEL( ME_TextEditor *editor, int to, int from )
|
||||
int set_selection( ME_TextEditor *editor, int to, int from )
|
||||
{
|
||||
int end;
|
||||
|
||||
TRACE("%d - %d\n", to, from );
|
||||
|
||||
ME_InvalidateSelection( editor );
|
||||
end = ME_SetSelection( editor, to, from );
|
||||
end = set_selection_cursors( editor, to, from );
|
||||
ME_InvalidateSelection( editor );
|
||||
update_caret( editor );
|
||||
ME_SendSelChange( editor );
|
||||
|
@ -2682,7 +2682,7 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
|
|||
case 'A':
|
||||
if (ctrl_is_down)
|
||||
{
|
||||
handle_EM_EXSETSEL( editor, 0, -1 );
|
||||
set_selection( editor, 0, -1 );
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
@ -3796,7 +3796,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
|
|||
}
|
||||
case EM_SETSEL:
|
||||
{
|
||||
return handle_EM_EXSETSEL( editor, wParam, lParam );
|
||||
return set_selection( editor, wParam, lParam );
|
||||
}
|
||||
case EM_SETSCROLLPOS:
|
||||
{
|
||||
|
@ -3821,7 +3821,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
|
|||
{
|
||||
CHARRANGE range = *(CHARRANGE *)lParam;
|
||||
|
||||
return handle_EM_EXSETSEL( editor, range.cpMin, range.cpMax );
|
||||
return set_selection( editor, range.cpMin, range.cpMax );
|
||||
}
|
||||
case EM_SHOWSCROLLBAR:
|
||||
{
|
||||
|
@ -4122,7 +4122,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
|
|||
TRACE("WM_SETTEXT - NULL\n");
|
||||
ME_SetCursorToStart(editor, &cursor);
|
||||
ME_UpdateLinkAttribute(editor, &cursor, INT_MAX);
|
||||
ME_SetSelection(editor, 0, 0);
|
||||
set_selection_cursors(editor, 0, 0);
|
||||
editor->nModifyStep = 0;
|
||||
ME_CommitUndo(editor);
|
||||
ME_EmptyUndoStack(editor);
|
||||
|
@ -4813,7 +4813,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
|
|||
HeapFree(GetProcessHeap(), 0, lpCompStr);
|
||||
|
||||
if (dwIndex == GCS_COMPSTR)
|
||||
ME_SetSelection(editor,editor->imeStartIndex,
|
||||
set_selection_cursors(editor,editor->imeStartIndex,
|
||||
editor->imeStartIndex + dwBufLen/sizeof(WCHAR));
|
||||
}
|
||||
ME_ReleaseStyle(style);
|
||||
|
|
|
@ -149,7 +149,7 @@ void ME_SetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *mod) DECLSPEC_
|
|||
|
||||
/* caret.c */
|
||||
void ME_SetCursorToStart(ME_TextEditor *editor, ME_Cursor *cursor) DECLSPEC_HIDDEN;
|
||||
int ME_SetSelection(ME_TextEditor *editor, int from, int to) DECLSPEC_HIDDEN;
|
||||
int set_selection_cursors(ME_TextEditor *editor, int from, int to) DECLSPEC_HIDDEN;
|
||||
BOOL ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs) DECLSPEC_HIDDEN;
|
||||
void hide_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN;
|
||||
void show_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN;
|
||||
|
@ -255,6 +255,7 @@ void ME_RTFSpecialCharHook(struct _RTF_Info *info) DECLSPEC_HIDDEN;
|
|||
void ME_StreamInFill(ME_InStream *stream) DECLSPEC_HIDDEN;
|
||||
extern BOOL me_debug DECLSPEC_HIDDEN;
|
||||
void ME_ReplaceSel(ME_TextEditor *editor, BOOL can_undo, const WCHAR *str, int len) DECLSPEC_HIDDEN;
|
||||
int set_selection( ME_TextEditor *editor, int to, int from ) DECLSPEC_HIDDEN;
|
||||
|
||||
/* table.c */
|
||||
BOOL ME_IsInTable(ME_DisplayItem *pItem) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -2149,7 +2149,7 @@ static HRESULT WINAPI ITextRange_fnSelect(ITextRange *me)
|
|||
if (!This->child.reole)
|
||||
return CO_E_RELEASED;
|
||||
|
||||
ME_SetSelection(This->child.reole->editor, This->start, This->end);
|
||||
set_selection(This->child.reole->editor, This->start, This->end);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -4649,7 +4649,7 @@ static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG value)
|
|||
ME_GetSelectionOfs(This->reOle->editor, &start, &end);
|
||||
hr = textrange_setstart(This->reOle, value, &start, &end);
|
||||
if (hr == S_OK)
|
||||
ME_SetSelection(This->reOle->editor, start, end);
|
||||
set_selection(This->reOle->editor, start, end);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
@ -4684,7 +4684,7 @@ static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG value)
|
|||
ME_GetSelectionOfs(This->reOle->editor, &start, &end);
|
||||
hr = textrange_setend(This->reOle, value, &start, &end);
|
||||
if (hr == S_OK)
|
||||
ME_SetSelection(This->reOle->editor, start, end);
|
||||
set_selection(This->reOle->editor, start, end);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
@ -4803,7 +4803,7 @@ static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart)
|
|||
ME_GetSelectionOfs(This->reOle->editor, &start, &end);
|
||||
hres = range_Collapse(bStart, &start, &end);
|
||||
if (SUCCEEDED(hres))
|
||||
ME_SetSelection(This->reOle->editor, start, end);
|
||||
set_selection(This->reOle->editor, start, end);
|
||||
return hres;
|
||||
}
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ DECLSPEC_HIDDEN HRESULT __thiscall fnTextSrv_TxSetText(ITextServices *iface, LPC
|
|||
ME_InternalDeleteText(This->editor, &cursor, ME_GetTextLength(This->editor), FALSE);
|
||||
if(pszText)
|
||||
ME_InsertTextFromCursor(This->editor, 0, pszText, -1, This->editor->pBuffer->pDefaultStyle);
|
||||
ME_SetSelection(This->editor, 0, 0);
|
||||
set_selection_cursors(This->editor, 0, 0);
|
||||
This->editor->nModifyStep = 0;
|
||||
OleFlushClipboard();
|
||||
ME_EmptyUndoStack(This->editor);
|
||||
|
|
Loading…
Reference in New Issue