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.
This commit is contained in:
parent
5f15de0690
commit
1eb0f73ab0
|
@ -100,8 +100,6 @@ int ME_IsSplitable(const ME_String *s);
|
||||||
int ME_FindNonWhitespaceV(const ME_String *s, int nVChar);
|
int ME_FindNonWhitespaceV(const ME_String *s, int nVChar);
|
||||||
int ME_FindWhitespaceV(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_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_StrRelPos(const ME_String *s, int nVChar, int *pRelChars);
|
||||||
int ME_StrRelPos2(const ME_String *s, int nVChar, int nRelChars);
|
int ME_StrRelPos2(const ME_String *s, int nVChar, int nRelChars);
|
||||||
int ME_PosToVPos(const ME_String *s, int nPos);
|
int ME_PosToVPos(const ME_String *s, int nPos);
|
||||||
|
|
|
@ -406,38 +406,39 @@ ME_InsertRunAtCursor(ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style,
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* ME_UpdateRunFlags
|
* ME_UpdateRunFlags
|
||||||
*
|
*
|
||||||
* Determine some of run attributes given its content (style, text content).
|
* Determine some of run attributes given its content (style, text content).
|
||||||
* Some flags cannot be determined by this function (MERF_GRAPHICS,
|
* Some flags cannot be determined by this function (MERF_GRAPHICS,
|
||||||
* MERF_ENDPARA)
|
* MERF_ENDPARA)
|
||||||
*/
|
*/
|
||||||
void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run)
|
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)
|
if (RUN_IS_HIDDEN(run) || run->nFlags & MERF_TABLESTART)
|
||||||
run->nFlags |= MERF_HIDDEN;
|
run->nFlags |= MERF_HIDDEN;
|
||||||
else
|
else
|
||||||
run->nFlags &= ~MERF_HIDDEN;
|
run->nFlags &= ~MERF_HIDDEN;
|
||||||
|
|
||||||
if (ME_IsSplitable(run->strText))
|
if (ME_IsSplitable(strText))
|
||||||
run->nFlags |= MERF_SPLITTABLE;
|
run->nFlags |= MERF_SPLITTABLE;
|
||||||
else
|
else
|
||||||
run->nFlags &= ~MERF_SPLITTABLE;
|
run->nFlags &= ~MERF_SPLITTABLE;
|
||||||
|
|
||||||
if (!(run->nFlags & MERF_NOTEXT)) {
|
if (!(run->nFlags & MERF_NOTEXT)) {
|
||||||
if (ME_IsWhitespaces(run->strText))
|
if (ME_IsWhitespaces(strText))
|
||||||
run->nFlags |= MERF_WHITESPACE | MERF_STARTWHITE | MERF_ENDWHITE;
|
run->nFlags |= MERF_WHITESPACE | MERF_STARTWHITE | MERF_ENDWHITE;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
run->nFlags &= ~MERF_WHITESPACE;
|
run->nFlags &= ~MERF_WHITESPACE;
|
||||||
|
|
||||||
if (ME_IsWSpace(ME_GetCharFwd(run->strText,0)))
|
if (ME_IsWSpace(strText->szData[0]))
|
||||||
run->nFlags |= MERF_STARTWHITE;
|
run->nFlags |= MERF_STARTWHITE;
|
||||||
else
|
else
|
||||||
run->nFlags &= ~MERF_STARTWHITE;
|
run->nFlags &= ~MERF_STARTWHITE;
|
||||||
|
|
||||||
if (ME_IsWSpace(ME_GetCharBack(run->strText,0)))
|
if (ME_IsWSpace(strText->szData[strText->nLen - 1]))
|
||||||
run->nFlags |= MERF_ENDWHITE;
|
run->nFlags |= MERF_ENDWHITE;
|
||||||
else
|
else
|
||||||
run->nFlags &= ~MERF_ENDWHITE;
|
run->nFlags &= ~MERF_ENDWHITE;
|
||||||
|
|
|
@ -186,32 +186,6 @@ void ME_StrDeleteV(ME_String *s, int nVChar, int nChars)
|
||||||
s->nLen -= (end_ofs - nVChar);
|
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 ME_FindNonWhitespaceV(const ME_String *s, int nVChar) {
|
||||||
int i;
|
int i;
|
||||||
for (i = nVChar; i<s->nLen && ME_IsWSpace(s->szData[i]); i++)
|
for (i = nVChar; i<s->nLen && ME_IsWSpace(s->szData[i]); i++)
|
||||||
|
|
Loading…
Reference in New Issue