riched20: Rewrite the run splittable test to take a run parameter.

This commit is contained in:
Huw Davies 2013-01-31 13:47:57 +00:00 committed by Alexandre Julliard
parent 35f21ac826
commit 29e54f07f7
3 changed files with 19 additions and 17 deletions

View File

@ -105,7 +105,6 @@ void ME_DestroyString(ME_String *s) DECLSPEC_HIDDEN;
void ME_AppendString(ME_String *s1, const ME_String *s2) DECLSPEC_HIDDEN;
ME_String *ME_VSplitString(ME_String *orig, int nVPos) DECLSPEC_HIDDEN;
int ME_IsWhitespaces(const ME_String *s) DECLSPEC_HIDDEN;
int ME_IsSplitable(const ME_String *s) DECLSPEC_HIDDEN;
int ME_FindNonWhitespaceV(const ME_String *s, int nVChar) DECLSPEC_HIDDEN;
int ME_CallWordBreakProc(ME_TextEditor *editor, ME_String *str, INT start, INT code) DECLSPEC_HIDDEN;
void ME_StrDeleteV(ME_String *s, int nVChar, int nChars) DECLSPEC_HIDDEN;

View File

@ -376,6 +376,24 @@ ME_InsertRunAtCursor(ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style,
return pDI;
}
static BOOL run_is_splittable( const ME_Run *run )
{
WCHAR *str = get_text( run, 0 ), *p;
int i, len = run->strText->nLen;
BOOL found_ink = FALSE;
for (i = 0, p = str; i < len; i++, p++)
{
if (ME_IsWSpace( *p ))
{
if (found_ink) return TRUE;
}
else
found_ink = TRUE;
}
return FALSE;
}
/******************************************************************************
* ME_UpdateRunFlags
*
@ -393,7 +411,7 @@ void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run)
else
run->nFlags &= ~MERF_HIDDEN;
if (ME_IsSplitable(strText))
if (run_is_splittable( run ))
run->nFlags |= MERF_SPLITTABLE;
else
run->nFlags &= ~MERF_SPLITTABLE;

View File

@ -121,21 +121,6 @@ int ME_IsWhitespaces(const ME_String *s)
return 1;
}
int ME_IsSplitable(const ME_String *s)
{
WCHAR *pos = s->szData;
WCHAR ch;
while(ME_IsWSpace(*pos++))
;
pos--;
while((ch = *pos++) != 0)
{
if (ME_IsWSpace(ch))
return 1;
}
return 0;
}
void ME_StrDeleteV(ME_String *s, int nVChar, int nChars)
{
int end_ofs = nVChar + nChars;