Module: wine Branch: master Commit: 3c0b519bba468852343e2cd45d9c722d3b3eea31 URL: https://source.winehq.org/git/wine.git/?a=commit;h=3c0b519bba468852343e2cd45...
Author: Sergio Gómez Del Real sdelreal@codeweavers.com Date: Thu Nov 29 08:44:49 2018 -0500
riched20: Add get_total_width() to get widest paragraph number.
Signed-off-by: Sergio Gómez Del Real sdelreal@codeweavers.com Signed-off-by: Huw Davies huw@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
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 e1a002b..eb37368 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 3d86734..c5755b1 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;