richedit: Set the default paragraph format consistently.
I created a function to set the default paragraph format to ensure consistency when this is done. This initial paragraph format is also now more consistent with native richedit controls. The dwMask value always appears to have the same value when retrieved from the native richedit controls, so all the mask values are now initialized when the PARAFORMAT2 structure is created.
This commit is contained in:
parent
aba425eb70
commit
8172d69e8f
|
@ -1040,13 +1040,16 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
|
||||||
ME_InternalDeleteText(editor, from, to-from);
|
ME_InternalDeleteText(editor, from, to-from);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
ME_DisplayItem *para_item;
|
||||||
style = editor->pBuffer->pDefaultStyle;
|
style = editor->pBuffer->pDefaultStyle;
|
||||||
ME_AddRefStyle(style);
|
ME_AddRefStyle(style);
|
||||||
SendMessageA(editor->hWnd, EM_SETSEL, 0, 0);
|
SendMessageA(editor->hWnd, EM_SETSEL, 0, 0);
|
||||||
ME_InternalDeleteText(editor, 0, ME_GetTextLength(editor));
|
ME_InternalDeleteText(editor, 0, ME_GetTextLength(editor));
|
||||||
from = to = 0;
|
from = to = 0;
|
||||||
ME_ClearTempStyle(editor);
|
ME_ClearTempStyle(editor);
|
||||||
/* FIXME restore default paragraph formatting ! */
|
|
||||||
|
para_item = ME_GetParagraph(editor->pCursors[0].pRun);
|
||||||
|
ME_SetDefaultParaFormat(para_item->member.para.pFmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -231,6 +231,7 @@ void ME_GetSelectionParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt);
|
||||||
void ME_MarkForWrapping(ME_TextEditor *editor, ME_DisplayItem *first, const ME_DisplayItem *last);
|
void ME_MarkForWrapping(ME_TextEditor *editor, ME_DisplayItem *first, const ME_DisplayItem *last);
|
||||||
void ME_MarkForPainting(ME_TextEditor *editor, ME_DisplayItem *first, const ME_DisplayItem *last);
|
void ME_MarkForPainting(ME_TextEditor *editor, ME_DisplayItem *first, const ME_DisplayItem *last);
|
||||||
void ME_MarkAllForWrapping(ME_TextEditor *editor);
|
void ME_MarkAllForWrapping(ME_TextEditor *editor);
|
||||||
|
void ME_SetDefaultParaFormat(PARAFORMAT2 *pFmt);
|
||||||
|
|
||||||
/* paint.c */
|
/* paint.c */
|
||||||
void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, const RECT *rcUpdate);
|
void ME_PaintContent(ME_TextEditor *editor, HDC hDC, BOOL bOnlyNew, const RECT *rcUpdate);
|
||||||
|
|
|
@ -151,8 +151,7 @@ ME_DisplayItem *ME_MakeDI(ME_DIType type) {
|
||||||
item->prev = item->next = NULL;
|
item->prev = item->next = NULL;
|
||||||
if (type == diParagraph || type == diUndoSplitParagraph) {
|
if (type == diParagraph || type == diUndoSplitParagraph) {
|
||||||
item->member.para.pFmt = ALLOC_OBJ(PARAFORMAT2);
|
item->member.para.pFmt = ALLOC_OBJ(PARAFORMAT2);
|
||||||
item->member.para.pFmt->cbSize = sizeof(PARAFORMAT2);
|
ME_SetDefaultParaFormat(item->member.para.pFmt);
|
||||||
item->member.para.pFmt->dwMask = 0;
|
|
||||||
item->member.para.nFlags = MEPF_REWRAP;
|
item->member.para.nFlags = MEPF_REWRAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ static const WCHAR wszParagraphSign[] = {0xB6, 0};
|
||||||
void ME_MakeFirstParagraph(ME_TextEditor *editor)
|
void ME_MakeFirstParagraph(ME_TextEditor *editor)
|
||||||
{
|
{
|
||||||
ME_Context c;
|
ME_Context c;
|
||||||
PARAFORMAT2 fmt;
|
|
||||||
CHARFORMAT2W cf;
|
CHARFORMAT2W cf;
|
||||||
LOGFONTW lf;
|
LOGFONTW lf;
|
||||||
HFONT hf;
|
HFONT hf;
|
||||||
|
@ -62,13 +61,6 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor)
|
||||||
cf.bPitchAndFamily = lf.lfPitchAndFamily;
|
cf.bPitchAndFamily = lf.lfPitchAndFamily;
|
||||||
cf.bCharSet = lf.lfCharSet;
|
cf.bCharSet = lf.lfCharSet;
|
||||||
|
|
||||||
ZeroMemory(&fmt, sizeof(fmt));
|
|
||||||
fmt.cbSize = sizeof(fmt);
|
|
||||||
fmt.dwMask = PFM_ALIGNMENT | PFM_OFFSET | PFM_STARTINDENT | PFM_RIGHTINDENT | PFM_TABSTOPS;
|
|
||||||
fmt.wAlignment = PFA_LEFT;
|
|
||||||
|
|
||||||
*para->member.para.pFmt = fmt;
|
|
||||||
|
|
||||||
style = ME_MakeStyle(&cf);
|
style = ME_MakeStyle(&cf);
|
||||||
text->pDefaultStyle = style;
|
text->pDefaultStyle = style;
|
||||||
|
|
||||||
|
@ -520,3 +512,13 @@ void ME_GetSelectionParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt)
|
||||||
para = para->member.para.next_para;
|
para = para->member.para.next_para;
|
||||||
} while(1);
|
} while(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ME_SetDefaultParaFormat(PARAFORMAT2 *pFmt)
|
||||||
|
{
|
||||||
|
ZeroMemory(pFmt, sizeof(PARAFORMAT2));
|
||||||
|
pFmt->cbSize = sizeof(PARAFORMAT2);
|
||||||
|
pFmt->dwMask = PFM_ALL2;
|
||||||
|
pFmt->wAlignment = PFA_LEFT;
|
||||||
|
pFmt->sStyle = -1;
|
||||||
|
pFmt->bOutlineLevel = TRUE;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue