当前位置: 首页>>代码示例>>C#>>正文


C# TextEditorData.GetLineByOffset方法代码示例

本文整理汇总了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;
		}
开发者ID:kekekeks,项目名称:monodevelop,代码行数:6,代码来源:ClipboardActions.cs

示例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);
				}
			}
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:41,代码来源:CSharpSelectionSurroundingProvider.cs

示例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);
 }
开发者ID:Kalnor,项目名称:monodevelop,代码行数:22,代码来源:CSharpTextEditorIndentationTests.cs

示例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;
        }
开发者ID:dlprows,项目名称:VimAddin,代码行数:36,代码来源:ViActions.cs


注:本文中的Mono.TextEditor.TextEditorData.GetLineByOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。