mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-14 20:35:38 +00:00
richedit: Joined paragraph format depends on number of characters deleted.
This commit is contained in:
parent
11c8039699
commit
4e56a3cda9
|
@ -267,6 +267,7 @@ void ME_InternalDeleteText(ME_TextEditor *editor, int nOfs,
|
|||
{
|
||||
ME_Cursor c;
|
||||
int shift = 0;
|
||||
int totalChars = nChars;
|
||||
|
||||
while(nChars > 0)
|
||||
{
|
||||
|
@ -275,12 +276,15 @@ void ME_InternalDeleteText(ME_TextEditor *editor, int nOfs,
|
|||
run = &c.pRun->member.run;
|
||||
if (run->nFlags & MERF_ENDPARA) {
|
||||
int eollen = run->nCR + run->nLF;
|
||||
BOOL keepFirstParaFormat;
|
||||
|
||||
if (!ME_FindItemFwd(c.pRun, diParagraph))
|
||||
{
|
||||
return;
|
||||
}
|
||||
ME_JoinParagraphs(editor, ME_GetParagraph(c.pRun));
|
||||
keepFirstParaFormat = (totalChars == nChars && nChars <= eollen &&
|
||||
run->nCharOfs);
|
||||
ME_JoinParagraphs(editor, ME_GetParagraph(c.pRun), keepFirstParaFormat);
|
||||
/* ME_SkipAndPropagateCharOffset(p->pRun, shift); */
|
||||
ME_CheckCharOffsets(editor);
|
||||
nChars -= (eollen < nChars) ? eollen : nChars;
|
||||
|
|
|
@ -218,7 +218,8 @@ ME_DisplayItem *ME_GetParagraph(ME_DisplayItem *run);
|
|||
void ME_GetSelectionParas(ME_TextEditor *editor, ME_DisplayItem **para, ME_DisplayItem **para_end);
|
||||
void ME_MakeFirstParagraph(ME_TextEditor *editor);
|
||||
ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *rp, ME_Style *style, int numCR, int numLF);
|
||||
ME_DisplayItem *ME_JoinParagraphs(ME_TextEditor *editor, ME_DisplayItem *tp);
|
||||
ME_DisplayItem *ME_JoinParagraphs(ME_TextEditor *editor, ME_DisplayItem *tp,
|
||||
BOOL keepFirstParaFormat);
|
||||
void ME_DumpParaStyle(ME_Paragraph *s);
|
||||
void ME_DumpParaStyleToBuf(const PARAFORMAT2 *pFmt, char buf[2048]);
|
||||
void ME_SetParaFormat(ME_TextEditor *editor, ME_DisplayItem *para, const PARAFORMAT2 *pFmt);
|
||||
|
|
|
@ -167,7 +167,8 @@ ME_DisplayItem *ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *run, ME
|
|||
|
||||
/* join tp with tp->member.para.next_para, keeping tp's style; this
|
||||
* is consistent with the original */
|
||||
ME_DisplayItem *ME_JoinParagraphs(ME_TextEditor *editor, ME_DisplayItem *tp)
|
||||
ME_DisplayItem *ME_JoinParagraphs(ME_TextEditor *editor, ME_DisplayItem *tp,
|
||||
BOOL keepFirstParaFormat)
|
||||
{
|
||||
ME_DisplayItem *pNext, *pFirstRunInNext, *pRun, *pTmp;
|
||||
int i, shift;
|
||||
|
@ -195,14 +196,17 @@ ME_DisplayItem *ME_JoinParagraphs(ME_TextEditor *editor, ME_DisplayItem *tp)
|
|||
ME_InitCharFormat2W(&fmt);
|
||||
ME_SetCharFormat(editor, pNext->member.para.nCharOfs - end_len, end_len, &fmt);
|
||||
}
|
||||
undo = ME_AddUndoItem(editor, diUndoSplitParagraph, NULL);
|
||||
undo = ME_AddUndoItem(editor, diUndoSplitParagraph, pNext);
|
||||
if (undo)
|
||||
{
|
||||
undo->nStart = pNext->member.para.nCharOfs - end_len;
|
||||
undo->nCR = pRun->member.run.nCR;
|
||||
undo->nLF = pRun->member.run.nLF;
|
||||
assert(pNext->member.para.pFmt->cbSize == sizeof(PARAFORMAT2));
|
||||
*undo->di.member.para.pFmt = *pNext->member.para.pFmt;
|
||||
}
|
||||
if (!keepFirstParaFormat)
|
||||
{
|
||||
ME_AddUndoItem(editor, diUndoSetParagraphFormat, tp);
|
||||
*tp->member.para.pFmt = *pNext->member.para.pFmt;
|
||||
}
|
||||
|
||||
shift = pNext->member.para.nCharOfs - tp->member.para.nCharOfs - end_len;
|
||||
|
|
|
@ -89,10 +89,9 @@ ME_UndoItem *ME_AddUndoItem(ME_TextEditor *editor, ME_DIType type, const ME_Disp
|
|||
case diUndoJoinParagraphs:
|
||||
break;
|
||||
case diUndoSplitParagraph:
|
||||
assert(pdi->member.para.pFmt->cbSize == sizeof(PARAFORMAT2));
|
||||
pItem->member.para.pFmt = ALLOC_OBJ(PARAFORMAT2);
|
||||
pItem->member.para.pFmt->cbSize = sizeof(PARAFORMAT2);
|
||||
pItem->member.para.pFmt->dwMask = 0;
|
||||
|
||||
*pItem->member.para.pFmt = *pdi->member.para.pFmt;
|
||||
break;
|
||||
default:
|
||||
assert(0 == "AddUndoItem, unsupported item type");
|
||||
|
@ -282,8 +281,11 @@ static void ME_PlayUndoItem(ME_TextEditor *editor, ME_DisplayItem *pItem)
|
|||
case diUndoSetParagraphFormat:
|
||||
{
|
||||
ME_Cursor tmp;
|
||||
ME_DisplayItem *para;
|
||||
ME_CursorFromCharOfs(editor, pItem->member.para.nCharOfs, &tmp);
|
||||
ME_SetParaFormat(editor, ME_FindItemBack(tmp.pRun, diParagraph), pItem->member.para.pFmt);
|
||||
para = ME_FindItemBack(tmp.pRun, diParagraph);
|
||||
ME_AddUndoItem(editor, diUndoSetParagraphFormat, para);
|
||||
*para->member.para.pFmt = *pItem->member.para.pFmt;
|
||||
break;
|
||||
}
|
||||
case diUndoSetCharFormat:
|
||||
|
@ -306,7 +308,7 @@ static void ME_PlayUndoItem(ME_TextEditor *editor, ME_DisplayItem *pItem)
|
|||
ME_Cursor tmp;
|
||||
ME_CursorFromCharOfs(editor, pUItem->nStart, &tmp);
|
||||
/* the only thing that's needed is paragraph offset, so no need to split runs */
|
||||
ME_JoinParagraphs(editor, ME_GetParagraph(tmp.pRun));
|
||||
ME_JoinParagraphs(editor, ME_GetParagraph(tmp.pRun), TRUE);
|
||||
break;
|
||||
}
|
||||
case diUndoSplitParagraph:
|
||||
|
|
Loading…
Reference in a new issue