richedit: Trailing spaces should not affect alignment shift length.
This commit is contained in:
parent
308582b4f5
commit
c8e2552ad9
|
@ -58,10 +58,12 @@ static void ME_BeginRow(ME_WrapContext *wc)
|
|||
static void ME_InsertRowStart(ME_WrapContext *wc, const ME_DisplayItem *pEnd)
|
||||
{
|
||||
ME_DisplayItem *p, *row, *para;
|
||||
BOOL bSkippingSpaces = TRUE;
|
||||
int ascent = 0, descent = 0, width=0, shift = 0, align = 0;
|
||||
/* wrap text */
|
||||
para = ME_GetParagraph(wc->pRowStart);
|
||||
for (p = wc->pRowStart; p!=pEnd; p = p->next)
|
||||
|
||||
for (p = pEnd->prev; p!=wc->pRowStart->prev; p = p->prev)
|
||||
{
|
||||
/* ENDPARA run shouldn't affect row height, except if it's the only run in the paragraph */
|
||||
if (p->type==diRun && ((p==wc->pRowStart) || !(p->member.run.nFlags & MERF_ENDPARA))) { /* FIXME add more run types */
|
||||
|
@ -69,10 +71,34 @@ static void ME_InsertRowStart(ME_WrapContext *wc, const ME_DisplayItem *pEnd)
|
|||
ascent = p->member.run.nAscent;
|
||||
if (p->member.run.nDescent>descent)
|
||||
descent = p->member.run.nDescent;
|
||||
if (!(p->member.run.nFlags & (MERF_ENDPARA|MERF_SKIPPED)))
|
||||
if (bSkippingSpaces)
|
||||
{
|
||||
/* Exclude space characters from run width.
|
||||
* Other whitespace or delimiters are not treated this way. */
|
||||
SIZE sz;
|
||||
int len = p->member.run.strText->nLen;
|
||||
WCHAR *text = p->member.run.strText->szData + len - 1;
|
||||
|
||||
assert (len);
|
||||
while (len && *(text--) == ' ')
|
||||
len--;
|
||||
if (len)
|
||||
{
|
||||
if (len == p->member.run.strText->nLen)
|
||||
{
|
||||
width += p->member.run.nWidth;
|
||||
} else {
|
||||
sz = ME_GetRunSize(wc->context, ¶->member.para,
|
||||
&p->member.run, len, p->member.run.pt.x);
|
||||
width += sz.cx;
|
||||
}
|
||||
}
|
||||
bSkippingSpaces = !len;
|
||||
} else if (!(p->member.run.nFlags & MERF_ENDPARA))
|
||||
width += p->member.run.nWidth;
|
||||
}
|
||||
}
|
||||
|
||||
row = ME_MakeRow(ascent+descent, ascent, width);
|
||||
row->member.row.nYPos = wc->pt.y;
|
||||
row->member.row.nLMargin = (!wc->nRow ? wc->nFirstMargin : wc->nLeftMargin);
|
||||
|
@ -98,7 +124,7 @@ static void ME_InsertRowStart(ME_WrapContext *wc, const ME_DisplayItem *pEnd)
|
|||
static void ME_WrapEndParagraph(ME_WrapContext *wc, ME_DisplayItem *p)
|
||||
{
|
||||
if (wc->pRowStart)
|
||||
ME_InsertRowStart(wc, p->next);
|
||||
ME_InsertRowStart(wc, p);
|
||||
|
||||
/*
|
||||
p = p->member.para.prev_para->next;
|
||||
|
|
Loading…
Reference in New Issue