[PATCH v2 2/8] riched20: Add get_total_width() to get widest paragraph number.
Sergio Gómez Del Real
sdelreal at codeweavers.com
Thu Nov 29 07:44:49 CST 2018
Signed-off-by: Sergio Gómez Del Real <sdelreal at codeweavers.com>
---
dlls/riched20/editor.h | 1 +
dlls/riched20/para.c | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index e1a002bfaa..eb37368602 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -202,6 +202,7 @@ void ME_MarkAllForWrapping(ME_TextEditor *editor) DECLSPEC_HIDDEN;
void ME_SetDefaultParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN;
void para_num_init( ME_Context *c, ME_Paragraph *para ) DECLSPEC_HIDDEN;
void para_num_clear( struct para_num *pn ) DECLSPEC_HIDDEN;
+int get_total_width(ME_TextEditor *editor) DECLSPEC_HIDDEN;
/* paint.c */
void ME_PaintContent(ME_TextEditor *editor, HDC hDC, const RECT *rcUpdate) DECLSPEC_HIDDEN;
diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c
index 3d86734aa1..c5755b19f4 100644
--- a/dlls/riched20/para.c
+++ b/dlls/riched20/para.c
@@ -36,11 +36,34 @@ void destroy_para(ME_TextEditor *editor, ME_DisplayItem *item)
{
assert(item->type == diParagraph);
+ if (item->member.para.nWidth == editor->nTotalWidth)
+ {
+ item->member.para.nWidth = 0;
+ editor->nTotalWidth = get_total_width(editor);
+ }
ME_DestroyString(item->member.para.text);
para_num_clear( &item->member.para.para_num );
ME_DestroyDisplayItem(item);
}
+int get_total_width(ME_TextEditor *editor)
+{
+ ME_Paragraph *para;
+ int total_width = 0;
+
+ if (editor->pBuffer->pFirst && editor->pBuffer->pLast)
+ {
+ para = &editor->pBuffer->pFirst->next->member.para;
+ while (para != &editor->pBuffer->pLast->member.para && para->next_para)
+ {
+ total_width = max(total_width, para->nWidth);
+ para = ¶->next_para->member.para;
+ }
+ }
+
+ return total_width;
+}
+
void ME_MakeFirstParagraph(ME_TextEditor *editor)
{
ME_Context c;
--
2.17.1
More information about the wine-devel
mailing list