Beispiel #1
0
 public static bool CanBreakLineAt(string pszStart, int index)
 {
     if (index == 0 || WordWrap.IsWhiteSpace(pszStart[index]) && WordWrap.IsNonBeginningChar(pszStart[index + 1]) || index > 1 && WordWrap.IsWhiteSpace(pszStart[index - 2]) && ((int)pszStart[index - 1] == 34 && !WordWrap.IsWhiteSpace(pszStart[index])) || (!WordWrap.IsWhiteSpace(pszStart[index - 1]) && (int)pszStart[index] == 34 && WordWrap.IsWhiteSpace(pszStart[index + 1]) || !WordWrap.IsWhiteSpace(pszStart[index]) && !WordWrap.IsEastAsianChar(pszStart[index]) && (!WordWrap.IsEastAsianChar(pszStart[index - 1]) && (int)pszStart[index - 1] != 45)) || WordWrap.IsNonBeginningChar(pszStart[index]))
     {
         return(false);
     }
     else
     {
         return(!WordWrap.IsNonEndingChar(pszStart[index - 1]));
     }
 }
Beispiel #2
0
 public static string FindNonWhiteSpaceBackward(string source, int index, out int offset)
 {
     while (index >= 0 && (WordWrap.IsWhiteSpace(source[index]) || WordWrap.IsLineFeed(source[index])))
     {
         --index;
     }
     offset = index;
     if (index >= 0)
     {
         return(source.Substring(index));
     }
     else
     {
         return((string)null);
     }
 }
Beispiel #3
0
        public static string FindNonWhiteSpaceForward(string text)
        {
            int startIndex = 0;

            while (startIndex < text.Length && WordWrap.IsWhiteSpace(text[startIndex]))
            {
                ++startIndex;
            }
            if (startIndex < text.Length && WordWrap.IsLineFeed(text[startIndex]))
            {
                ++startIndex;
            }
            if (startIndex >= text.Length)
            {
                return((string)null);
            }
            else
            {
                return(text.Substring(startIndex));
            }
        }
Beispiel #4
0
 public static string FindNextLine(SpriteFont spriteFont, string source, uint width, out string EOL, out int EOLOffset)
 {
     if (WordWrap.GetWidth == null || source == null)
     {
         EOL       = (string)null;
         EOLOffset = -1;
         return((string)null);
     }
     else
     {
         int  index = 0;
         uint num   = 0U;
         for (; index < source.Length && !WordWrap.IsLineFeed(source[index]); ++index)
         {
             num += WordWrap.GetWidth(spriteFont, source[index]);
             if (num > width)
             {
                 break;
             }
         }
         if (index == 0)
         {
             EOL = WordWrap.FindNonWhiteSpaceBackward(source, index, out EOLOffset);
             return(WordWrap.FindNonWhiteSpaceForward(source.Substring(index + 1)));
         }
         else if (num <= width)
         {
             EOL = WordWrap.FindNonWhiteSpaceBackward(source, index - 1, out EOLOffset);
             if (index - 1 >= 0 && WordWrap.IsLineFeed(source[index - 1]))
             {
                 return(source.Substring(index));
             }
             if (index < 0 || index >= source.Length)
             {
                 return((string)null);
             }
             else
             {
                 return(WordWrap.FindNonWhiteSpaceForward(source.Substring(index)));
             }
         }
         else
         {
             int startIndex = index;
             for (; index > 0; --index)
             {
                 if (WordWrap.IsWhiteSpace(source[index]))
                 {
                     EOL = WordWrap.FindNonWhiteSpaceBackward(source, index, out EOLOffset);
                     if (EOL != null)
                     {
                         return(WordWrap.FindNonWhiteSpaceForward(source.Substring(index + 1)));
                     }
                     index = EOLOffset + 1;
                 }
                 if (WordWrap.CanBreakLineAt(source, index))
                 {
                     break;
                 }
             }
             if (index <= 0)
             {
                 EOL       = source.Substring(startIndex - 1);
                 EOLOffset = startIndex - 1;
                 return(source.Substring(startIndex));
             }
             else
             {
                 EOL       = source.Substring(index - 1);
                 EOLOffset = index - 1;
                 return(WordWrap.FindNonWhiteSpaceForward(source.Substring(index)));
             }
         }
     }
 }