Example #1
0
 private bool ends_in_enter()
 {
     if (indexes_.Count > 0)
     {
         bool ends_in_enter = indexes_.Last() + 2 >= string_.Length;
         return(ends_in_enter);
     }
     else
     {
         return(false);
     }
 }
Example #2
0
        private string line_at_impl(int idx)
        {
            // note : it's possible to ask for an invalid line, while refreshing on the other thread
            //Debug.Assert(idx < line_count);

            if (idx == 0)
            {
                return((indexes_.Count > 0) ? string_.ToString(0, indexes_[0]) : "");
            }

            if (idx < indexes_.Count)
            {
                int start = indexes_[idx - 1] + 1;
                int end   = indexes_[idx];
                // 1.3.11+ account for enters in all cases : '\r', '\n', '\r\n', '\n\r'
                if (start < end && (string_[start] == '\r' || string_[start] == '\n'))
                {
                    ++start;
                }

                return(string_.ToString(start, end - start));
            }
            else if (idx == indexes_.Count)
            {
                // last line
                int start = indexes_.Last() + 1;
                int end   = string_.Length;
                if (end <= start)
                {
                    return("");
                }

                // 1.3.11+ account for enters in all cases : '\r', '\n', '\r\n', '\n\r'
                if (start < end && (string_[start] == '\r' || string_[start] == '\n'))
                {
                    ++start;
                }

                return(string_.ToString(start, end - start));
            }
            else
            {
                return("");
            }
        }