Dylan Smith : richedit: Removed ME_StrRelPos, ME_StrRelPos2, & ME_PosToVPos functions.
Alexandre Julliard
julliard at winehq.org
Mon Feb 9 10:29:32 CST 2009
Module: wine
Branch: master
Commit: c8b44555656edc8e27e6f1444fa6846539d75c1b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c8b44555656edc8e27e6f1444fa6846539d75c1b
Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date: Sat Feb 7 13:21:29 2009 -0500
richedit: Removed ME_StrRelPos, ME_StrRelPos2, & ME_PosToVPos functions.
These functions were just being used for addition, so it was simpler to
remove the functions and modify the places it was used.
The ME_StrRelPos2 and ME_PosToVPos were just simple wrappers around
ME_StrRelPos, and ME_PosToVPos wasn't being used.
---
dlls/riched20/caret.c | 10 +++++-----
dlls/riched20/editor.h | 3 ---
dlls/riched20/run.c | 27 ++++++++++++---------------
dlls/riched20/string.c | 46 +++++++---------------------------------------
dlls/riched20/wrap.c | 6 ++----
5 files changed, 26 insertions(+), 66 deletions(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index e0298d2..43ad44c 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -576,7 +576,7 @@ static BOOL
ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs)
{
ME_DisplayItem *pRun = pCursor->pRun;
-
+
if (nRelOfs == -1)
{
if (!pCursor->nOffset)
@@ -608,17 +608,17 @@ ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs)
else
pCursor->nOffset = pRun->member.run.strText->nLen;
}
-
+
if (pCursor->nOffset)
- pCursor->nOffset = ME_StrRelPos2(pCursor->pRun->member.run.strText, pCursor->nOffset, nRelOfs);
+ pCursor->nOffset = pCursor->nOffset + nRelOfs;
return TRUE;
}
else
{
if (!(pRun->member.run.nFlags & MERF_ENDPARA))
{
- int new_ofs = ME_StrRelPos2(pRun->member.run.strText, pCursor->nOffset, nRelOfs);
-
+ int new_ofs = pCursor->nOffset + nRelOfs;
+
if (new_ofs < pRun->member.run.strText->nLen)
{
pCursor->nOffset = new_ofs;
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 4c87eed..68ab596 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -100,9 +100,6 @@ int ME_IsSplitable(const ME_String *s);
int ME_FindNonWhitespaceV(const ME_String *s, int nVChar);
int ME_FindWhitespaceV(ME_String *s, int nVChar);
int ME_CallWordBreakProc(ME_TextEditor *editor, ME_String *str, INT start, INT code);
-int ME_StrRelPos(const ME_String *s, int nVChar, int *pRelChars);
-int ME_StrRelPos2(const ME_String *s, int nVChar, int nRelChars);
-int ME_PosToVPos(const ME_String *s, int nPos);
void ME_StrDeleteV(ME_String *s, int nVChar, int nChars);
/* smart helpers for A<->W conversions, they reserve/free memory and call MultiByte<->WideChar functions */
LPWSTR ME_ToUnicode(BOOL unicode, LPVOID psz);
diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c
index c36f25f..d4aaaa2 100644
--- a/dlls/riched20/run.c
+++ b/dlls/riched20/run.c
@@ -500,21 +500,21 @@ int ME_CharFromPoint(ME_Context *c, int cx, ME_Run *run)
/******************************************************************************
* ME_CharFromPointCursor
- *
+ *
* Returns a character position inside the run given a run-relative
- * pixel horizontal position. This version rounds to the nearest character edge
- * (ie. if the second character is at pixel position 8, then for cx=0..3
+ * pixel horizontal position. This version rounds to the nearest character edge
+ * (ie. if the second character is at pixel position 8, then for cx=0..3
* it returns 0, and for cx=4..7 it returns 1).
- *
+ *
* It is used for mouse click handling, for better usability (and compatibility
- * with the native control).
- */
+ * with the native control).
+ */
int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
{
ME_String *strRunText;
/* This could point to either the run's real text, or it's masked form in a password control */
-
- int fit = 0, fit1 = 0;
+
+ int fit = 0;
ME_Context c;
HGDIOBJ hOldFont;
SIZE sz, sz2, sz3;
@@ -548,18 +548,15 @@ int ME_CharFromPointCursor(ME_TextEditor *editor, int cx, ME_Run *run)
cx, &fit, NULL, &sz);
if (fit != strRunText->nLen)
{
- int chars = 1;
-
GetTextExtentPoint32W(c.hDC, strRunText->szData, fit, &sz2);
- fit1 = ME_StrRelPos(strRunText, fit, &chars);
- GetTextExtentPoint32W(c.hDC, strRunText->szData, fit1, &sz3);
+ GetTextExtentPoint32W(c.hDC, strRunText->szData, fit + 1, &sz3);
if (cx >= (sz2.cx+sz3.cx)/2)
- fit = fit1;
+ fit = fit + 1;
}
-
+
if (editor->cPasswordMask)
ME_DestroyString(strRunText);
-
+
ME_UnselectStyleFont(&c, run->style, hOldFont);
ME_DestroyContext(&c);
return fit;
diff --git a/dlls/riched20/string.c b/dlls/riched20/string.c
index 2b6b559..128e3c2 100644
--- a/dlls/riched20/string.c
+++ b/dlls/riched20/string.c
@@ -141,49 +141,17 @@ int ME_IsSplitable(const ME_String *s)
return 0;
}
-int ME_StrRelPos(const ME_String *s, int nVChar, int *pRelChars)
-{
- int nRelChars = *pRelChars;
-
- TRACE("%s,%d,&%d\n", debugstr_w(s->szData), nVChar, *pRelChars);
-
- assert(*pRelChars);
- if (!nRelChars)
- return nVChar;
-
- if (nRelChars>0)
- nRelChars = min(*pRelChars, s->nLen - nVChar);
- else
- nRelChars = max(*pRelChars, -nVChar);
- nVChar += nRelChars;
- *pRelChars -= nRelChars;
- return nVChar;
-}
-
-int ME_StrRelPos2(const ME_String *s, int nVChar, int nRelChars)
-{
- return ME_StrRelPos(s, nVChar, &nRelChars);
-}
-
-int ME_PosToVPos(const ME_String *s, int nPos)
-{
- if (!nPos)
- return 0;
- return ME_StrRelPos2(s, 0, nPos);
-}
-
void ME_StrDeleteV(ME_String *s, int nVChar, int nChars)
{
- int end_ofs;
-
- assert(nVChar >=0 && nVChar <= s->nLen);
+ int end_ofs = nVChar + nChars;
+
assert(nChars >= 0);
- assert(nVChar+nChars <= s->nLen);
-
- end_ofs = ME_StrRelPos2(s, nVChar, nChars);
+ assert(nVChar >= 0);
assert(end_ofs <= s->nLen);
- memmove(s->szData+nVChar, s->szData+end_ofs, 2*(s->nLen+1-end_ofs));
- s->nLen -= (end_ofs - nVChar);
+
+ memmove(s->szData + nVChar, s->szData + end_ofs,
+ (s->nLen - end_ofs + 1) * sizeof(WCHAR));
+ s->nLen -= nChars;
}
int ME_FindNonWhitespaceV(const ME_String *s, int nVChar) {
diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c
index a51e2db..54c90eb 100644
--- a/dlls/riched20/wrap.c
+++ b/dlls/riched20/wrap.c
@@ -316,11 +316,9 @@ static ME_DisplayItem *ME_SplitByBacktracking(ME_WrapContext *wc, ME_DisplayItem
else
{
/* split point inside first character - no choice but split after that char */
- int chars = 1;
- int pos2 = ME_StrRelPos(run->strText, 0, &chars);
- if (pos2 != len) {
+ if (len != 1) {
/* the run is more than 1 char, so we may split */
- return ME_SplitRun(wc, piter, pos2);
+ return ME_SplitRun(wc, piter, 1);
}
/* the run is one char, can't split it */
return piter;
More information about the wine-cvs
mailing list