本文整理汇总了C#中Mono.TextEditor.TextEditorData.GetLineByOffset方法的典型用法代码示例。如果您正苦于以下问题:C# TextEditorData.GetLineByOffset方法的具体用法?C# TextEditorData.GetLineByOffset怎么用?C# TextEditorData.GetLineByOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.TextEditor.TextEditorData
的用法示例。
在下文中一共展示了TextEditorData.GetLineByOffset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PasteFromPrimary
public static int PasteFromPrimary (TextEditorData data, int insertionOffset)
{
var result = PasteFrom (Clipboard.Get (CopyOperation.PRIMARYCLIPBOARD_ATOM), data, false, insertionOffset, true);
data.Document.CommitLineUpdate (data.GetLineByOffset (insertionOffset));
return result;
}
示例2: HandleSpecialSelectionKey
public override void HandleSpecialSelectionKey (TextEditorData textEditorData,uint unicodeKey)
{
string start, end;
GetSelectionSurroundings (textEditorData, unicodeKey, out start, out end);
var selection = textEditorData.MainSelection;
if (textEditorData.MainSelection.SelectionMode == SelectionMode.Block) {
int startCol = System.Math.Min (selection.Anchor.Column, selection.Lead.Column) - 1;
int endCol = System.Math.Max (selection.Anchor.Column, selection.Lead.Column);
for (int lineNumber = selection.MinLine; lineNumber <= selection.MaxLine; lineNumber++) {
DocumentLine lineSegment = textEditorData.GetLine (lineNumber);
if (lineSegment.Offset + startCol < lineSegment.EndOffset)
textEditorData.Insert (lineSegment.Offset + startCol, start);
if (lineSegment.Offset + endCol < lineSegment.EndOffset)
textEditorData.Insert (lineSegment.Offset + endCol, end);
}
textEditorData.MainSelection = new Selection (
new DocumentLocation (selection.Anchor.Line, endCol == selection.Anchor.Column ? endCol + start.Length : startCol + 1 + start.Length),
new DocumentLocation (selection.Lead.Line, endCol == selection.Anchor.Column ? startCol + 1 + start.Length : endCol + start.Length),
Mono.TextEditor.SelectionMode.Block);
textEditorData.Document.CommitMultipleLineUpdate (textEditorData.MainSelection.MinLine, textEditorData.MainSelection.MaxLine);
} else {
int anchorOffset = selection.GetAnchorOffset (textEditorData);
int leadOffset = selection.GetLeadOffset (textEditorData);
if (leadOffset < anchorOffset) {
int tmp = anchorOffset;
anchorOffset = leadOffset;
leadOffset = tmp;
}
textEditorData.Insert (anchorOffset, start);
textEditorData.Insert (leadOffset >= anchorOffset ? leadOffset + start.Length : leadOffset, end);
// textEditorData.SetSelection (anchorOffset + start.Length, leadOffset + start.Length);
if (CSharpTextEditorIndentation.OnTheFlyFormatting) {
var l1 = textEditorData.GetLineByOffset (anchorOffset);
var l2 = textEditorData.GetLineByOffset (leadOffset);
OnTheFlyFormatter.Format (document, l1.Offset, l2.EndOffsetIncludingDelimiter);
}
}
}
示例3: TestGuessSemicolonInsertionOffset
void TestGuessSemicolonInsertionOffset(string fooBar, bool expected = true)
{
StringBuilder sb = new StringBuilder ();
int semicolonOffset = 0;
int guessedOffset = 0;
for (int i = 0; i <fooBar.Length; i++) {
char ch = fooBar [i];
if (ch == '$') {
semicolonOffset = sb.Length - 1;
} else if (ch == '~') {
guessedOffset = sb.Length - 1;
} else {
sb.Append (ch);
}
}
var data = new TextEditorData ();
data.Text = sb.ToString ();
int guessed;
Assert.AreEqual (expected, CSharpTextEditorIndentation.GuessSemicolonInsertionOffset (data, data.GetLineByOffset (semicolonOffset), semicolonOffset, out guessed));
if (expected)
Assert.AreEqual (guessedOffset, guessed);
}
示例4: TryFindSymbolBlock
static bool TryFindSymbolBlock(TextEditorData data, char command, out SymbolBlock result)
{
char end, begin;
if (!BeginToEndCharMap.TryGetValue (command, out end)) end = command;
if (!EndToBeginCharMap.TryGetValue (command, out begin)) begin = command;
var offset = data.Caret.Offset;
var startTokenOffset = ParseForChar(data, offset, 0, end, begin, false);
var endTokenOffset = ParseForChar(data, offset, data.Length, begin, end, true);
// Use the editor's FindMatchingBrace built-in functionality. It's better at handling erroneous braces
// inside quotes. We still need to do the above paragraph because we needed to find the braces.
var matchingStartBrace = endTokenOffset.HasValue ? data.Document.GetMatchingBracketOffset(
endTokenOffset.GetValueOrDefault ()) : -1;
if (matchingStartBrace >= 0 && (!startTokenOffset.HasValue
|| matchingStartBrace != startTokenOffset.GetValueOrDefault ()))
startTokenOffset = matchingStartBrace;
var matchingEndBrace = startTokenOffset.HasValue && data.GetCharAt (offset) != end ?
data.Document.GetMatchingBracketOffset(startTokenOffset.GetValueOrDefault ()) : -1;
if (matchingEndBrace >= 0 && (!endTokenOffset.HasValue
|| matchingEndBrace != endTokenOffset.GetValueOrDefault ()))
endTokenOffset = matchingEndBrace;
if (!startTokenOffset.HasValue || !endTokenOffset.HasValue) throw new ViModeAbortException();
result = new SymbolBlock
{
StartOffset = startTokenOffset.GetValueOrDefault (),
EndOffset = endTokenOffset.GetValueOrDefault (),
StartLine = data.GetLineByOffset (startTokenOffset.GetValueOrDefault()),
EndLine = data.GetLineByOffset (endTokenOffset.GetValueOrDefault()),
};
return true;
}