static public string GetTextBetween(this ScintillaGateway document, int start, int end = -1) { if (end == -1) { end = document.GetLength(); } using (var tr = new TextRange(start, end, end - start + 1)) //+1 for null termination { document.GetTextRange(tr); return(tr.lpstrText); } }
static public string TextAfterPosition(this ScintillaGateway document, int position, int maxLength) { int bufCapacity = maxLength + 1; int currentPos = position; int fullLength = document.GetLength(); int startPos = currentPos; int endPos = Math.Min(currentPos + bufCapacity, fullLength); int size = endPos - startPos; if (size > 0) { using (var tr = new TextRange(startPos, endPos, bufCapacity)) { document.GetTextRange(tr); return(tr.lpstrText); } } else { return(null); } }