Commit 75433bc3 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Pass a cursor ptr to the insert style retrieval function.

parent e69bb46c
......@@ -473,11 +473,11 @@ static struct re_object* create_re_object(const REOBJECT *reo)
void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCursor)
{
ME_Style *style = ME_GetInsertStyle( editor, nCursor );
ME_Run *run, *prev;
const WCHAR space = ' ';
struct re_object *reobj_prev = NULL;
ME_Cursor *cursor = editor->pCursors + nCursor;
ME_Style *style = style_get_insert_style( editor, cursor );
/* FIXME no no no */
if (ME_IsSelection(editor))
......@@ -508,9 +508,9 @@ void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCur
void ME_InsertEndRowFromCursor(ME_TextEditor *editor, int nCursor)
{
ME_Style *style = ME_GetInsertStyle( editor, nCursor );
const WCHAR space = ' ';
ME_Cursor *cursor = editor->pCursors + nCursor;
ME_Style *style = style_get_insert_style( editor, cursor );
/* FIXME no no no */
if (ME_IsSelection(editor))
......@@ -1510,7 +1510,7 @@ void ME_DeleteSelection(ME_TextEditor *editor)
ME_Style *ME_GetSelectionInsertStyle(ME_TextEditor *editor)
{
return ME_GetInsertStyle(editor, 0);
return style_get_insert_style( editor, editor->pCursors );
}
void ME_SendSelChange(ME_TextEditor *editor)
......
......@@ -2596,7 +2596,7 @@ static BOOL handle_enter(ME_TextEditor *editor)
}
}
style = ME_GetInsertStyle(editor, 0);
style = style_get_insert_style( editor, editor->pCursors );
/* Normally the new eop style is the insert style, however in a list it is copied from the existing
eop style (this prevents the list label style changing when the new eop is inserted).
......@@ -2838,7 +2838,7 @@ static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode,
/* WM_CHAR is restricted to nTextLimit */
if(editor->nTextLimit > ME_GetTextLength(editor) - (to-from))
{
ME_Style *style = ME_GetInsertStyle(editor, 0);
ME_Style *style = style_get_insert_style( editor, editor->pCursors );
ME_ContinueCoalescingTransaction(editor);
ME_InsertTextFromCursor(editor, 0, &wstr, 1, style);
ME_ReleaseStyle(style);
......@@ -4818,7 +4818,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
{
HIMC hIMC;
ME_Style *style = ME_GetInsertStyle(editor, 0);
ME_Style *style = style_get_insert_style( editor, editor->pCursors );
hIMC = ITextHost_TxImmGetContext(editor->texthost);
ME_DeleteSelection(editor);
ME_SaveTempStyle(editor, style);
......
......@@ -47,11 +47,11 @@ static inline const char *debugstr_run( const ME_Run *run )
}
/* style.c */
ME_Style *style_get_insert_style( ME_TextEditor *editor, ME_Cursor *cursor ) DECLSPEC_HIDDEN;
ME_Style *ME_MakeStyle(CHARFORMAT2W *style) DECLSPEC_HIDDEN;
void ME_AddRefStyle(ME_Style *item) DECLSPEC_HIDDEN;
void ME_DestroyStyle(ME_Style *item) DECLSPEC_HIDDEN;
void ME_ReleaseStyle(ME_Style *item) DECLSPEC_HIDDEN;
ME_Style *ME_GetInsertStyle(ME_TextEditor *editor, int nCursor) DECLSPEC_HIDDEN;
ME_Style *ME_ApplyStyle(ME_TextEditor *ed, ME_Style *sSrc, CHARFORMAT2W *style) DECLSPEC_HIDDEN;
void select_style(ME_Context *c, ME_Style *s) DECLSPEC_HIDDEN;
void ME_InitCharFormat2W(CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN;
......
......@@ -1697,7 +1697,7 @@ static HRESULT WINAPI ITextRange_fnSetText(ITextRange *me, BSTR str)
len = lstrlenW(str);
cursor = editor->pCursors[0];
cursor_from_char_ofs( editor, This->start, &editor->pCursors[0] );
style = ME_GetInsertStyle(editor, 0);
style = style_get_insert_style( editor, editor->pCursors );
ME_InsertTextFromCursor(editor, 0, str, len, style);
ME_ReleaseStyle(style);
editor->pCursors[0] = cursor;
......
......@@ -716,7 +716,7 @@ void ME_SetSelectionCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt)
{
ME_Style *s;
if (!editor->pBuffer->pCharStyle)
editor->pBuffer->pCharStyle = ME_GetInsertStyle(editor, 0);
editor->pBuffer->pCharStyle = style_get_insert_style( editor, editor->pCursors );
s = ME_ApplyStyle(editor, editor->pBuffer->pCharStyle, pFmt);
ME_ReleaseStyle(editor->pBuffer->pCharStyle);
editor->pBuffer->pCharStyle = s;
......
......@@ -473,42 +473,26 @@ void ME_ReleaseStyle(ME_Style *s)
ME_DestroyStyle(s);
}
ME_Style *ME_GetInsertStyle(ME_TextEditor *editor, int nCursor)
ME_Style *style_get_insert_style( ME_TextEditor *editor, ME_Cursor *cursor )
{
if (ME_IsSelection(editor))
{
ME_Style *style;
ME_Cursor *from, *to;
ME_Run *prev;
ME_GetSelection(editor, &from, &to);
ME_AddRefStyle(from->pRun->member.run.style);
return from->pRun->member.run.style;
}
if (editor->pBuffer->pCharStyle) {
ME_AddRefStyle(editor->pBuffer->pCharStyle);
return editor->pBuffer->pCharStyle;
}
else
{
ME_Cursor *pCursor = &editor->pCursors[nCursor];
ME_DisplayItem *pRunItem = pCursor->pRun;
ME_DisplayItem *pPrevItem = NULL;
if (pCursor->nOffset) {
ME_Run *pRun = &pRunItem->member.run;
ME_AddRefStyle(pRun->style);
return pRun->style;
}
pPrevItem = ME_FindItemBack(pRunItem, diRunOrParagraph);
if (pPrevItem->type == diRun)
if (ME_IsSelection( editor ))
{
ME_AddRefStyle(pPrevItem->member.run.style);
return pPrevItem->member.run.style;
ME_GetSelection( editor, &from, &to );
style = from->pRun->member.run.style;
}
else if (editor->pBuffer->pCharStyle)
style = editor->pBuffer->pCharStyle;
else if (!cursor->nOffset && (prev = run_prev( &cursor->pRun->member.run )))
style = prev->style;
else
{
ME_AddRefStyle(pRunItem->member.run.style);
return pRunItem->member.run.style;
}
}
style = cursor->pRun->member.run.style;
ME_AddRefStyle( style );
return style;
}
void ME_SaveTempStyle(ME_TextEditor *editor, ME_Style *style)
......
......@@ -63,7 +63,7 @@ static ME_DisplayItem* ME_InsertEndParaFromCursor(ME_TextEditor *editor,
const WCHAR *eol_str, int eol_len,
int paraFlags)
{
ME_Style *pStyle = ME_GetInsertStyle(editor, nCursor);
ME_Style *pStyle = style_get_insert_style( editor, editor->pCursors + nCursor );
ME_Paragraph *para;
ME_Cursor* cursor = &editor->pCursors[nCursor];
......
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