Module: wine
Branch: master
Commit: c8b44555656edc8e27e6f1444fa6846539d75c1b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c8b44555656edc8e27e6f1444…
Author: Dylan Smith <dylan.ah.smith(a)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;
Module: wine
Branch: master
Commit: 1eb0f73ab026a302cdde1fa4fe7a7d7e9cb86711
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1eb0f73ab026a302cdde1fa4f…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com>
Date: Sat Feb 7 13:21:23 2009 -0500
richedit: Got rid of ME_GetCharFwd and ME_GetCharBack.
These two functions were being used for simple operations, to get the
first or last character when pre-computing flags for splitting runs.
The call to ME_GetCharBack wasn't even giving the correct result, it
would always return -1 since it is being called with nPos of 0.
This patch simplifies the code by removing the functions and getting the
characters directly from the string.
---
dlls/riched20/editor.h | 2 --
dlls/riched20/run.c | 19 ++++++++++---------
dlls/riched20/string.c | 26 --------------------------
3 files changed, 10 insertions(+), 37 deletions(-)
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 2e53c22..4c87eed 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -100,8 +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_GetCharFwd(const ME_String *s, int nPos); /* get char starting from start */
-int ME_GetCharBack(const ME_String *s, int nPos); /* get char starting from \0 */
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);
diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c
index ed066ea..c36f25f 100644
--- a/dlls/riched20/run.c
+++ b/dlls/riched20/run.c
@@ -406,38 +406,39 @@ ME_InsertRunAtCursor(ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style,
/******************************************************************************
* ME_UpdateRunFlags
- *
+ *
* Determine some of run attributes given its content (style, text content).
- * Some flags cannot be determined by this function (MERF_GRAPHICS,
- * MERF_ENDPARA)
- */
+ * Some flags cannot be determined by this function (MERF_GRAPHICS,
+ * MERF_ENDPARA)
+ */
void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run)
{
- assert(run->nCharOfs != -1);
+ ME_String *strText = run->strText;
+ assert(run->nCharOfs >= 0);
if (RUN_IS_HIDDEN(run) || run->nFlags & MERF_TABLESTART)
run->nFlags |= MERF_HIDDEN;
else
run->nFlags &= ~MERF_HIDDEN;
- if (ME_IsSplitable(run->strText))
+ if (ME_IsSplitable(strText))
run->nFlags |= MERF_SPLITTABLE;
else
run->nFlags &= ~MERF_SPLITTABLE;
if (!(run->nFlags & MERF_NOTEXT)) {
- if (ME_IsWhitespaces(run->strText))
+ if (ME_IsWhitespaces(strText))
run->nFlags |= MERF_WHITESPACE | MERF_STARTWHITE | MERF_ENDWHITE;
else
{
run->nFlags &= ~MERF_WHITESPACE;
- if (ME_IsWSpace(ME_GetCharFwd(run->strText,0)))
+ if (ME_IsWSpace(strText->szData[0]))
run->nFlags |= MERF_STARTWHITE;
else
run->nFlags &= ~MERF_STARTWHITE;
- if (ME_IsWSpace(ME_GetCharBack(run->strText,0)))
+ if (ME_IsWSpace(strText->szData[strText->nLen - 1]))
run->nFlags |= MERF_ENDWHITE;
else
run->nFlags &= ~MERF_ENDWHITE;
diff --git a/dlls/riched20/string.c b/dlls/riched20/string.c
index 7cc0001..2b6b559 100644
--- a/dlls/riched20/string.c
+++ b/dlls/riched20/string.c
@@ -186,32 +186,6 @@ void ME_StrDeleteV(ME_String *s, int nVChar, int nChars)
s->nLen -= (end_ofs - nVChar);
}
-int ME_GetCharFwd(const ME_String *s, int nPos)
-{
- int nVPos = 0;
-
- assert(nPos < s->nLen);
- if (nPos)
- nVPos = ME_StrRelPos2(s, nVPos, nPos);
-
- if (nVPos < s->nLen)
- return s->szData[nVPos];
- return -1;
-}
-
-int ME_GetCharBack(const ME_String *s, int nPos)
-{
- int nVPos = s->nLen;
-
- assert(nPos < s->nLen);
- if (nPos)
- nVPos = ME_StrRelPos2(s, nVPos, -nPos);
-
- if (nVPos < s->nLen)
- return s->szData[nVPos];
- return -1;
-}
-
int ME_FindNonWhitespaceV(const ME_String *s, int nVChar) {
int i;
for (i = nVChar; i<s->nLen && ME_IsWSpace(s->szData[i]); i++)
Module: wine
Branch: master
Commit: 5f15de0690da4b289360da55f740a61fad7ad2cb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5f15de0690da4b289360da55f…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com>
Date: Sat Feb 7 13:21:17 2009 -0500
richedit: Removed ME_StrLen and ME_StrVLen field access functions.
These functions were probably previously needed because of some wierd
special handling of backspace characters, but currently there is no
reason why the nLen field can't be accessed directly.
Having to functions that just access the string length field just causes
slightly more effort for someone to look at the code, because they need
to enter the function to find out what it actually is doing.
---
dlls/riched20/caret.c | 10 +++++-----
dlls/riched20/editor.c | 22 +++++++++++-----------
dlls/riched20/editor.h | 3 ---
dlls/riched20/paint.c | 6 +++---
dlls/riched20/run.c | 14 +++++++-------
dlls/riched20/string.c | 25 +++----------------------
dlls/riched20/wrap.c | 6 +++---
dlls/riched20/writer.c | 4 ++--
8 files changed, 34 insertions(+), 56 deletions(-)
Diff: http://source.winehq.org/git/wine.git/?a=commitdiff;h=5f15de0690da4b289360d…
Module: wine
Branch: master
Commit: f148d82093fe44d8e405ad4ab9704b185fa3c2ce
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f148d82093fe44d8e405ad4ab…
Author: Dylan Smith <dylan.ah.smith(a)gmail.com>
Date: Sat Feb 7 13:21:10 2009 -0500
richedit: Got rid of useless function ME_VPosToPos.
The function was just returning the second parameter. It had some
commented out code that indicated that previously backslashes weren't
included in the length. Native wordpad doesn't handle backspaces in a
special way, so this must have been an internal representation that
complicated finding the position of characters.
---
dlls/riched20/editor.h | 1 -
dlls/riched20/run.c | 3 +--
dlls/riched20/string.c | 19 -------------------
3 files changed, 1 insertions(+), 22 deletions(-)
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 90dcd2a..8064450 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -107,7 +107,6 @@ int ME_GetCharFwd(const ME_String *s, int nPos); /* get char starting from start
int ME_GetCharBack(const ME_String *s, int nPos); /* get char starting from \0 */
int ME_StrRelPos(const ME_String *s, int nVChar, int *pRelChars);
int ME_StrRelPos2(const ME_String *s, int nVChar, int nRelChars);
-int ME_VPosToPos(ME_String *s, int nVPos);
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 */
diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c
index fae7603..265c0ab 100644
--- a/dlls/riched20/run.c
+++ b/dlls/riched20/run.c
@@ -310,8 +310,7 @@ ME_DisplayItem *ME_SplitRunSimple(ME_TextEditor *editor, ME_DisplayItem *item, i
item2 = ME_MakeRun(run->style,
ME_VSplitString(run->strText, nVChar), run->nFlags&MERF_SPLITMASK);
- item2->member.run.nCharOfs = item->member.run.nCharOfs+
- ME_VPosToPos(item->member.run.strText, nVChar);
+ item2->member.run.nCharOfs = item->member.run.nCharOfs + nVChar;
run2 = &item2->member.run;
ME_InsertBefore(item->next, item2);
diff --git a/dlls/riched20/string.c b/dlls/riched20/string.c
index d8852fb..f534d7e 100644
--- a/dlls/riched20/string.c
+++ b/dlls/riched20/string.c
@@ -184,25 +184,6 @@ int ME_StrRelPos2(const ME_String *s, int nVChar, int nRelChars)
return ME_StrRelPos(s, nVChar, &nRelChars);
}
-int ME_VPosToPos(ME_String *s, int nVPos)
-{
- return nVPos;
- /*
- int i = 0, len = 0;
- if (!nVPos)
- return 0;
- while (i < s->nLen)
- {
- if (i == nVPos)
- return len;
- if (s->szData[i]=='\\') i++;
- i++;
- len++;
- }
- return len;
- */
-}
-
int ME_PosToVPos(const ME_String *s, int nPos)
{
if (!nPos)