Example #1
0
        /// <summary>
        /// Calculates the 1-based line and column number position based
        /// on the given buffer offset.
        /// </summary>
        /// <param name="bufferOffset">The buffer offset to convert.</param>
        /// <returns>A new BufferPosition containing the position of the offset.</returns>
        public BufferPosition GetPositionAtOffset(int bufferOffset)
        {
            BufferRange bufferRange =
                GetRangeBetweenOffsets(
                    bufferOffset, bufferOffset);

            return(bufferRange.Start);
        }
Example #2
0
        /// <summary>
        /// Compares two instances of the BufferRange class.
        /// </summary>
        /// <param name="obj">The object to which this instance will be compared.</param>
        /// <returns>True if the ranges are equal, false otherwise.</returns>
        public override bool Equals(object obj)
        {
            if (!(obj is BufferRange))
            {
                return(false);
            }

            BufferRange other = (BufferRange)obj;

            return
                (this.Start.Equals(other.Start) &&
                 this.End.Equals(other.End));
        }
 /// <summary>
 /// Gets the text under a specific range
 /// </summary>
 public string GetTextInRange(BufferRange range)
 {
     return(string.Join(Environment.NewLine, GetLinesInRange(range)));
 }