/// <summary> /// Returns the text between the positions start and end. If end is -1, text is returned to the end of the document. /// The text is 0 terminated, so you must supply a buffer that is at least 1 character longer than the number of characters /// you wish to read. The return value is the length of the returned text not including the terminating 0. /// </summary> public string GetTextByRange(int start, int end, int bufCapacity) { using (var textRange = new Sci_TextRange(start, end, bufCapacity)) { Call(SciMsg.SCI_GETTEXTRANGE, 0, textRange.NativePointer); //return textRange.lpstrText; return(IsUnicode() ? StringUtils.AnsiToUnicode(textRange.lpstrText) : textRange.lpstrText); } }
/// <summary> /// Gets the entire document text. /// </summary> public string GetDocumentText() { var length = GetDocumentLength(); var text = new StringBuilder(length + 1); if (length > 0) { Call(SciMsg.SCI_GETTEXT, length + 1, text); } var ret = text.ToString(); return(IsUnicode() ? StringUtils.AnsiToUnicode(ret) : ret); }
/// <summary> /// Returns the text currently selected (highlighted). /// </summary> /// <returns>Currently selected text.</returns> public string GetSelectedText() { var selLength = GetSelectionLength(); // Todo: Use a string / char array as stringbuilder can't handle null characters? var selectedText = new StringBuilder(selLength); if (selLength > 0) { Call(SciMsg.SCI_GETSELTEXT, 0, selectedText); } var ret = selectedText.ToString(); return(IsUnicode() ? StringUtils.AnsiToUnicode(ret) : ret); }