本文整理汇总了C#中Mono.TextEditor.TextDocument.GetLine方法的典型用法代码示例。如果您正苦于以下问题:C# TextDocument.GetLine方法的具体用法?C# TextDocument.GetLine怎么用?C# TextDocument.GetLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.TextEditor.TextDocument
的用法示例。
在下文中一共展示了TextDocument.GetLine方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindNextWordOffset
int FindNextWordOffset (TextDocument doc, int offset, bool subword)
{
int lineNumber = doc.OffsetToLineNumber (offset);
DocumentLine line = doc.GetLine (lineNumber);
if (line == null)
return offset;
int result = offset;
int endOffset = line.Offset + line.Length;
if (result == endOffset) {
line = doc.GetLine (lineNumber + 1);
if (line != null)
result = line.Offset;
return result;
}
CharacterClass current = GetCharacterClass (doc.GetCharAt (result), subword, false);
while (result < endOffset) {
CharacterClass next = GetCharacterClass (doc.GetCharAt (result), subword, false);
if (next != current) {
// camelCase and PascalCase handling
bool camelSkip = false;
if (next == CharacterClass.LowercaseLetter && current == CharacterClass.UppercaseLetter) {
if (result-2 > line.Offset) {
CharacterClass previous = GetCharacterClass (doc.GetCharAt (result-2), subword, false);
if (previous == CharacterClass.UppercaseLetter && result-2 > offset)
result--;
else
camelSkip = true;
}
}
if (!camelSkip)
break;
}
current = next;
result++;
}
while (result < endOffset && GetCharacterClass (doc.GetCharAt (result), subword, false) == CharacterClass.Whitespace) {
result++;
}
return result;
}
示例2: FindPrevWordOffset
int FindPrevWordOffset (TextDocument doc, int offset, bool subword)
{
int lineNumber = doc.OffsetToLineNumber (offset);
DocumentLine line = doc.GetLine (lineNumber);
if (line == null)
return offset;
int result = offset;
if (result == line.Offset) {
line = doc.GetLine (lineNumber - 1);
if (line != null)
result = line.Offset + line.Length;
return result;
}
CharacterClass current = GetCharacterClass (doc.GetCharAt (result - 1), subword, false);
if (current == CharacterClass.Whitespace && result - 1 > line.Offset) {
result--;
current = GetCharacterClass (doc.GetCharAt (result - 2), subword, false);
}
while (result > line.Offset) {
CharacterClass prev = GetCharacterClass (doc.GetCharAt (result - 1), subword, false);
if (prev != current) {
// camelCase and PascalCase handling
bool camelSkip = false;
if (prev == CharacterClass.UppercaseLetter && current == CharacterClass.LowercaseLetter) {
if (result-2 > line.Offset) {
CharacterClass back2 = GetCharacterClass (doc.GetCharAt (result-2), subword, false);
if (back2 == CharacterClass.UppercaseLetter)
result--;
else
camelSkip = true;
}
}
if (!camelSkip)
break;
}
current = prev;
result--;
}
return result;
}
示例3: UnderLineError
void UnderLineError (Document doc, Error info)
{
var line = doc.GetLine (info.Region.BeginLine);
// If the line is already underlined
if (errors.Any (em => em.LineSegment == line))
return;
ErrorMarker error = new ErrorMarker (textEditor.Document, info, line);
errors.Add (error);
doc.AddMarker (line, error);
}
示例4: GetInsertionPosition
static InsertionPoint GetInsertionPosition (TextDocument doc, int line, int column)
{
int bodyEndOffset = doc.LocationToOffset (line, column) + 1;
DocumentLine curLine = doc.GetLine (line);
if (curLine != null) {
if (bodyEndOffset < curLine.Offset + curLine.Length) {
// case1: positition is somewhere inside the start line
return new InsertionPoint (new DocumentLocation (line, column + 1), NewLineInsertion.Eol, NewLineInsertion.BlankLine);
}
}
// -> if position is at line end check next line
DocumentLine nextLine = doc.GetLine (line + 1);
if (nextLine == null) // check for 1 line case.
return new InsertionPoint (new DocumentLocation (line, column + 1), NewLineInsertion.BlankLine, NewLineInsertion.BlankLine);
for (int i = nextLine.Offset; i < nextLine.Offset + nextLine.Length; i++) {
char ch = doc.GetCharAt (i);
if (!char.IsWhiteSpace (ch)) {
// case2: next line contains non ws chars.
return new InsertionPoint (new DocumentLocation (line + 1, 1), NewLineInsertion.Eol, NewLineInsertion.BlankLine);
}
}
// case3: whitespace line
return new InsertionPoint (new DocumentLocation (line + 1, 1), NewLineInsertion.Eol, NewLineInsertion.None);
}
示例5: CheckStartPoint
static void CheckStartPoint (TextDocument doc, InsertionPoint point, bool isEndPoint)
{
DocumentLine 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).Length) {
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 = NewLineInsertion.Eol;
if (point.Location.Column < line.Length + 1)
point.LineAfter = isEndPoint ? NewLineInsertion.Eol : NewLineInsertion.BlankLine;
}
示例6: CheckEndPoint
static void CheckEndPoint (TextDocument doc, InsertionPoint point, bool isStartPoint)
{
DocumentLine 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.Length + 1)
point.LineAfter = NewLineInsertion.Eol;
}
示例7: StripHeader
static string StripHeader (string content)
{
var doc = new Mono.TextEditor.TextDocument (content);
while (true) {
string lineText = doc.GetLineText (1);
if (lineText == null)
break;
if (lineText.StartsWith ("//")) {
doc.Remove (doc.GetLine (1).SegmentIncludingDelimiter);
continue;
}
break;
}
return doc.Text;
}
示例8: StripDoubleBlankLines
static string StripDoubleBlankLines (string content)
{
var doc = new Mono.TextEditor.TextDocument (content);
for (int i = 1; i + 1 <= doc.LineCount; i++) {
if (IsBlankLine (doc, i) && IsBlankLine (doc, i + 1)) {
doc.Remove (doc.GetLine (i).SegmentIncludingDelimiter);
i--;
continue;
}
}
return doc.Text;
}
示例9: IsBlankLine
static bool IsBlankLine (TextDocument doc, int i)
{
var line = doc.GetLine (i);
return line.Length == line.GetIndentation (doc).Length;
}
示例10: FormatMessage
internal static string FormatMessage (string msg)
{
StringBuilder sb = new StringBuilder ();
bool wasWs = false;
foreach (char ch in msg) {
if (ch == ' ' || ch == '\t') {
if (!wasWs)
sb.Append (' ');
wasWs = true;
continue;
}
wasWs = false;
sb.Append (ch);
}
var doc = new TextDocument ();
doc.Text = sb.ToString ();
for (int i = 1; i <= doc.LineCount; i++) {
string text = doc.GetLineText (i).Trim ();
int idx = text.IndexOf (':');
if (text.StartsWith ("*") && idx >= 0 && idx < text.Length - 1) {
int offset = doc.GetLine (i).EndOffsetIncludingDelimiter;
msg = text.Substring (idx + 1) + doc.GetTextAt (offset, doc.TextLength - offset);
break;
}
}
return msg.TrimStart (' ', '\t');
}
示例11: UrlTextLineMarker
public UrlTextLineMarker (TextDocument doc, IDocumentLine line, string url, Mono.TextEditor.UrlType urlType, string style, int startColumn, int endColumn) : base (doc, doc.GetLine (line.LineNumber), url, urlType, style, startColumn, endColumn)
{
if (doc == null)
throw new ArgumentNullException ("doc");
this.line = line;
}