Пример #1
0
        static List <ustring> WordWrap(ustring text, int margin)
        {
            int start = 0, end;
            var lines = new List <ustring> ();

            text = StripCRLF(text);

            while ((end = start + margin) < text.Length)
            {
                while (text [end] != ' ' && end > start)
                {
                    end -= 1;
                }

                if (end == start)
                {
                    end = start + margin;
                }

                lines.Add(text [start, end]);
                start = end + 1;
            }

            if (start < text.Length)
            {
                lines.Add(text.Substring(start));
            }

            return(lines);
        }