Dylan Smith : richedit: Joined paragraph format depends on number of characters deleted.
Alexandre Julliard
julliard at winehq.org
Tue Aug 5 07:26:44 CDT 2008
Module: wine
Branch: master
Commit: 4e56a3cda93d7332d37779ac1d390f487e025a17
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4e56a3cda93d7332d37779ac1d390f487e025a17
Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date: Mon Aug 4 19:19:01 2008 -0400
richedit: Joined paragraph format depends on number of characters deleted.
---
dlls/riched20/caret.c | 6 +++++-
dlls/riched20/editor.h | 3 ++-
dlls/riched20/para.c | 12 ++++++++----
dlls/riched20/undo.c | 12 +++++++-----
4 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index 3f89398..89cd132 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -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;
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 51f7e53..a32811c 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -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);
diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c
index 4ac234d..5289fdd 100644
--- a/dlls/riched20/para.c
+++ b/dlls/riched20/para.c
@@ -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;
diff --git a/dlls/riched20/undo.c b/dlls/riched20/undo.c
index eaf1791..9fcdc4b 100644
--- a/dlls/riched20/undo.c
+++ b/dlls/riched20/undo.c
@@ -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:
More information about the wine-cvs
mailing list