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.
This commit is contained in:
parent
1eb0f73ab0
commit
c8b4455565
|
@ -610,14 +610,14 @@ ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs)
|
|||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -514,7 +514,7 @@ 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,13 +548,10 @@ 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)
|
||||
|
|
|
@ -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;
|
||||
int end_ofs = nVChar + nChars;
|
||||
|
||||
assert(nVChar >=0 && nVChar <= s->nLen);
|
||||
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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue