ACAT.Extensions.Default.UI.Scanners.TalkApplicationScannerAlphabetical.getPreviousPara C# (CSharp) Method

getPreviousPara() private method

Returns the previous para of text from where the cursor is
private getPreviousPara ( ) : String
return String
        private String getPreviousPara()
        {
            int index = TextBoxTalkWindow.SelectionStart;
            var text = TextBoxTalkWindow.Text;

            if (text.Length == 0)
            {
                return String.Empty;
            }

            if (index >= text.Length)
            {
                index = text.Length - 1;
            }

            while (index > 0 && (text[index] == '\r' || text[index] == '\n'))
            {
                index--;
            }

            int endPos = index;

            while (index > 0 && text[index] != '\r' && text[index] != '\n')
            {
                index--;
            }

            if (index > 0 && (text[index] == '\r' || text[index] == '\n'))
            {
                index++;
            }

            int startPos = index;

            return text.Substring(startPos, endPos - startPos + 1);
        }