本文整理汇总了C#中ICSharpCode.TextEditor.Document.LineSegment.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# LineSegment.ToString方法的具体用法?C# LineSegment.ToString怎么用?C# LineSegment.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.TextEditor.Document.LineSegment
的用法示例。
在下文中一共展示了LineSegment.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Insert
int Insert(int lineNumber, int offset, string text)
{
if (text == null || text.Length == 0) {
return 0;
}
textLength += text.Length;
if (lineCollection.Count == 0 || lineNumber >= lineCollection.Count) {
return CreateLines(text, lineCollection.Count, offset);
}
LineSegment line = (LineSegment)lineCollection[lineNumber];
ISegment nextDelimiter = NextDelimiter(text, 0);
if (nextDelimiter == null || nextDelimiter.Offset < 0) {
line.TotalLength += text.Length;
// Console.WriteLine("1:Line length of line {0} set to {1}", lineNumber, line.TotalLength - line.DelimiterLength);
markLines.Add(line);
OnLineLengthChanged(new LineLengthEventArgs(document, lineNumber, offset -line.Offset, text.Length));
return 0;
}
int restLength = line.Offset + line.TotalLength - offset;
if (restLength > 0) {
// Console.WriteLine("Insert: Set restline in line {0} to length {1}", lineNumber, restLength);
LineSegment lineRest = new LineSegment(offset, restLength);
lineRest.DelimiterLength = line.DelimiterLength;
lineRest.Offset += text.Length;
markLines.Add(lineRest);
if (restLength - line.DelimiterLength < 0) {
throw new ApplicationException("tried to insert inside delimiter string " + lineRest.ToString() + "!!!");
}
lineCollection.Insert(lineNumber + 1, lineRest);
OnLineCountChanged(new LineManagerEventArgs(document, lineNumber - 1, 1));
}
line.DelimiterLength = nextDelimiter.Length;
int nextStart = offset + nextDelimiter.Offset + nextDelimiter.Length;
line.TotalLength = nextStart - line.Offset;
// Console.WriteLine("2:Line length of line {0} set to {1}", lineNumber, line.TotalLength - line.DelimiterLength);
markLines.Add(line);
text = text.Substring(nextDelimiter.Offset + nextDelimiter.Length);
return CreateLines(text, lineNumber + 1, nextStart) + 1;
}