Dylan Smith : richedit: Prevented underlining the end of paragraph character.

Alexandre Julliard julliard at winehq.org
Fri Jul 11 08:44:46 CDT 2008


Module: wine
Branch: master
Commit: 9bcfa942a0dfe629a32d0d8b0e7d684f903f9c49
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9bcfa942a0dfe629a32d0d8b0e7d684f903f9c49

Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date:   Thu Jul 10 18:28:41 2008 -0400

richedit: Prevented underlining the end of paragraph character.

---

 dlls/riched20/paint.c |   48 +++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 43 insertions(+), 5 deletions(-)

diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c
index 1aa10b1..ec39953 100644
--- a/dlls/riched20/paint.c
+++ b/dlls/riched20/paint.c
@@ -160,6 +160,41 @@ int ME_twips2pointsY(ME_Context *c, int y)
     return y * c->dpi.cy * c->editor->nZoomNumerator / 1440 / c->editor->nZoomDenominator;
 }
 
+static void ME_HighlightSpace(ME_Context *c, int x, int y, LPCWSTR szText,
+                              int nChars, ME_Style *s, int width,
+                              int nSelFrom, int nSelTo, int ymin, int cy)
+{
+  HDC hDC = c->hDC;
+  HGDIOBJ hOldFont = NULL;
+  SIZE sz;
+  int selWidth;
+  /* Only highlight if there is a selection in the run and when
+   * EM_HIDESELECTION is not being used to hide the selection. */
+  if (nSelFrom >= nChars || nSelTo < 0 || nSelFrom >= nSelTo
+      || c->editor->bHideSelection)
+    return;
+  hOldFont = ME_SelectStyleFont(c, s);
+  if (width <= 0)
+  {
+    GetTextExtentPoint32W(hDC, szText, nChars, &sz);
+    width = sz.cx;
+  }
+  if (nSelFrom < 0) nSelFrom = 0;
+  if (nSelTo > nChars) nSelTo = nChars;
+  GetTextExtentPoint32W(hDC, szText, nSelFrom, &sz);
+  x += sz.cx;
+  if (nSelTo != nChars)
+  {
+    GetTextExtentPoint32W(hDC, szText+nSelFrom, nSelTo-nSelFrom, &sz);
+    selWidth = sz.cx;
+  } else {
+    selWidth = width - sz.cx;
+  }
+  ME_UnselectStyleFont(c, s, hOldFont);
+
+  PatBlt(hDC, x, ymin, selWidth, cy, DSTINVERT);
+}
+
 static void ME_DrawTextWithStyle(ME_Context *c, int x, int y, LPCWSTR szText,
                                  int nChars, ME_Style *s, int width,
                                  int nSelFrom, int nSelTo, int ymin, int cy)
@@ -287,14 +322,17 @@ static void ME_DrawRun(ME_Context *c, int x, int y, ME_DisplayItem *rundi, ME_Pa
   ME_GetSelection(c->editor, &nSelFrom, &nSelTo);
 
   /* Draw selected end-of-paragraph mark */
-  if (run->nFlags & MERF_ENDPARA && runofs >= nSelFrom && runofs < nSelTo)
-    ME_DrawTextWithStyle(c, x, y, wszSpace, 1, run->style, 0, 0, 1,
-                         c->pt.y + start->member.row.nYPos,
-                         start->member.row.nHeight);
-
   /* you can always comment it out if you need visible paragraph marks */
   if (run->nFlags & MERF_ENDPARA)
+  {
+    if (runofs >= nSelFrom && runofs < nSelTo)
+    {
+      ME_HighlightSpace(c, x, y, wszSpace, 1, run->style, 0, 0, 1,
+                        c->pt.y + start->member.row.nYPos,
+                        start->member.row.nHeight);
+    }
     return;
+  }
 
   if (run->nFlags & (MERF_TAB | MERF_CELL))
   {




More information about the wine-cvs mailing list