本文整理汇总了C#中Mono.TextEditor.Document.GetLineIndent方法的典型用法代码示例。如果您正苦于以下问题:C# Document.GetLineIndent方法的具体用法?C# Document.GetLineIndent怎么用?C# Document.GetLineIndent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.TextEditor.Document
的用法示例。
在下文中一共展示了Document.GetLineIndent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckStartPoint
static void CheckStartPoint (Document doc, InsertionPoint point, bool isEndPoint)
{
LineSegment line = doc.GetLine (point.Location.Line);
if (line == null)
return;
if (doc.GetLineIndent (line).Length + 1 == point.Location.Column) {
int lineNr = point.Location.Line;
while (lineNr > 1 && doc.GetLineIndent (lineNr - 1).Length == doc.GetLine (lineNr - 1).EditableLength) {
lineNr--;
}
line = doc.GetLine (lineNr);
point.Location = new DocumentLocation (lineNr, doc.GetLineIndent (line).Length + 1);
}
if (doc.GetLineIndent (line).Length + 1 < point.Location.Column)
point.LineBefore = isEndPoint ? NewLineInsertion.Eol : NewLineInsertion.BlankLine;
if (point.Location.Column < line.EditableLength + 1)
point.LineAfter = isEndPoint ? NewLineInsertion.Eol : NewLineInsertion.BlankLine;
}
示例2: CheckEndPoint
static void CheckEndPoint (Document doc, InsertionPoint point, bool isStartPoint)
{
LineSegment line = doc.GetLine (point.Location.Line);
if (line == null)
return;
if (doc.GetLineIndent (line).Length + 1 < point.Location.Column)
point.LineBefore = NewLineInsertion.BlankLine;
if (point.Location.Column < line.EditableLength + 1)
point.LineAfter = NewLineInsertion.Eol;
}
示例3: GetIndent
static string GetIndent (string text)
{
Mono.TextEditor.Document doc = new Mono.TextEditor.Document ();
doc.Text = text;
string result = null;
for (int i = 1; i < doc.LineCount; i++) {
string lineIndent = doc.GetLineIndent (i);
if (doc.GetLine (i).EditableLength == lineIndent.Length)
continue;
if (result == null || lineIndent.Length < result.Length)
result = lineIndent;
}
return result ?? "";
}
示例4: GetInsertionPosition
static InsertionPoint GetInsertionPosition (Document doc, int line, int column)
{
int bodyEndOffset = doc.LocationToOffset (line, column) + 1;
LineSegment curLine = doc.GetLine (line);
if (curLine != null) {
if (bodyEndOffset < curLine.Offset + curLine.EditableLength)
return new InsertionPoint (new DocumentLocation (line, column + 1), NewLineInsertion.BlankLine, NewLineInsertion.BlankLine);
}
LineSegment nextLine = doc.GetLine (line + 1);
int endOffset = nextLine != null ? nextLine.Offset : doc.Length;
for (int i = bodyEndOffset; i < endOffset; i++) {
char ch = doc.GetCharAt (i);
if (!char.IsWhiteSpace (ch))
return new InsertionPoint (doc.OffsetToLocation (i), NewLineInsertion.BlankLine, NewLineInsertion.BlankLine);
}
if (nextLine == null)
return new InsertionPoint (doc.OffsetToLocation (bodyEndOffset - 1), NewLineInsertion.BlankLine, NewLineInsertion.BlankLine);
int oldLine = line;
while (line < doc.LineCount && doc.GetLineIndent (line + 1).Length == doc.GetLine (line + 1).EditableLength)
line++;
NewLineInsertion insertBefore = NewLineInsertion.None;
NewLineInsertion insertAfter = NewLineInsertion.None;
int delta = line - oldLine;
int lineNumber = line + 1;
if (delta == 0) {
insertBefore = NewLineInsertion.Eol;
insertAfter = NewLineInsertion.BlankLine;
} else if (delta == 1) {
insertAfter = NewLineInsertion.BlankLine;
} else if (delta == 2) {
lineNumber--;
insertAfter = NewLineInsertion.BlankLine;
} else if (delta >= 3) {
lineNumber -= 2;
insertAfter = NewLineInsertion.None;
}
return new InsertionPoint (new DocumentLocation (lineNumber, doc.GetLineIndent (lineNumber).Length + 1), insertBefore, insertAfter);
}
示例5: GetInsertionPosition
static InsertionPoint GetInsertionPosition (Document doc, int line, int column)
{
LineSegment nextLine = doc.GetLine (line + 1);
int bodyEndOffset = doc.LocationToOffset (line, column) + 1;
int endOffset = nextLine != null ? nextLine.Offset : doc.Length;
for (int i = bodyEndOffset; i < endOffset; i++) {
char ch = doc.GetCharAt (i);
if (!char.IsWhiteSpace (ch))
return new InsertionPoint (doc.OffsetToLocation (i), true, true);
}
if (nextLine == null)
return new InsertionPoint (doc.OffsetToLocation (bodyEndOffset - 1), true, true);
int oldLine = line;
bool curLineEmpty = false;
if (doc.GetLineIndent (nextLine).Length == nextLine.EditableLength) {
curLineEmpty = true;
while (line + 2 < doc.LineCount && doc.GetLineIndent (line + 2).Length == doc.GetLine (line + 2).EditableLength)
line++;
}
bool insertBefore = !curLineEmpty && line - oldLine <= 1;
bool insertAfter = line - oldLine == 0;
// if (curLineEmpty)
// line++;
int lineNumber = line + 1;
return new InsertionPoint (new DocumentLocation (lineNumber, doc.GetLineIndent (lineNumber).Length), insertBefore, insertAfter);
}
示例6: CheckStartPoint
static void CheckStartPoint (Document doc, InsertionPoint point)
{
LineSegment line = doc.GetLine (point.Location.Line);
if (line == null)
return;
if (doc.GetLineIndent (line).Length < point.Location.Column)
point.ShouldInsertNewLineBefore = true;
if (point.Location.Column < line.EditableLength)
point.ShouldInsertNewLineAfter = true;
}