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


C# TextEditor.GetLineByOffset方法代码示例

本文整理汇总了C#中TextEditor.GetLineByOffset方法的典型用法代码示例。如果您正苦于以下问题:C# TextEditor.GetLineByOffset方法的具体用法?C# TextEditor.GetLineByOffset怎么用?C# TextEditor.GetLineByOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextEditor的用法示例。


在下文中一共展示了TextEditor.GetLineByOffset方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetItem

		public override Task<TooltipItem> GetItem (TextEditor editor, DocumentContext ctx, int offset, CancellationToken token = default(CancellationToken))
		{
			var ed = GetExtensibleTextEditor (editor);
			if (ed == null)
				return Task.FromResult<TooltipItem> (null);

			string errorInformation = ed.GetErrorInformationAt (offset);
			if (string.IsNullOrEmpty (errorInformation))
				return Task.FromResult<TooltipItem> (null);

			return Task.FromResult (new TooltipItem (errorInformation, editor.GetLineByOffset (offset)));
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:12,代码来源:CompileErrorTooltipProvider.cs

示例2: Insert

		public int Insert (TextEditor editor, DocumentContext ctx, string text)
		{
			int offset = editor.LocationToOffset (Location);
			using (var undo = editor.OpenUndoGroup ()) {
				
				var line = editor.GetLineByOffset (offset);
				int insertionOffset = line.Offset + Location.Column - 1;
				offset = insertionOffset;
				InsertNewLine (editor, LineBefore, ref offset);
				int result = offset - insertionOffset;

				editor.InsertText (offset, text);
				offset += text.Length;
				InsertNewLine (editor, LineAfter, ref offset);
				CodeFormatterService.Format (editor, ctx, TextSegment.FromBounds (insertionOffset - 1, offset));
				return result;
			}
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:18,代码来源:InsertionPoint.cs

示例3: GetItem

        public override TooltipItem GetItem(TextEditor editor, int offset)
        {
            // Note: Normally, the document already should be open
            var doc=IdeApp.Workbench.GetDocument(editor.Document.FileName);

            if (doc == null || !(doc.ParsedDocument is ParsedDModule))
                return null;

            // Due the first note, the AST already should exist
            var ast = (doc.ParsedDocument as ParsedDModule).DDom;

            if (ast == null)
                return null;

            // Get code cache
            var codeCache = DResolverWrapper.CreateCacheList(doc);

            // Create editor context
            var line=editor.GetLineByOffset(offset);

            var ed = new EditorData {
                CaretOffset=offset,
                CaretLocation = new CodeLocation(offset - line.Offset, editor.OffsetToLineNumber(offset)),
                ModuleCode = editor.Text,
                ParseCache = codeCache,
                SyntaxTree = ast
            };

            // Let the engine build all contents
            DResolver.NodeResolutionAttempt att;
            var rr = DResolver.ResolveTypeLoosely(ed, out att);

            // Create tool tip item
            if (rr != null)
                return new TooltipItem(rr, offset, 1);
            return null;
        }
开发者ID:Geod24,项目名称:Mono-D,代码行数:37,代码来源:DToolTipProvider.cs

示例4: GetItem

        public TooltipItem GetItem(TextEditor editor, int offset)
        {
            // Note: Normally, the document already should be open
            var doc=IdeApp.Workbench.GetDocument(editor.Document.FileName);

            if (doc == null || !(doc.ParsedDocument is ParsedDModule))
                return null;

            // Due the first note, the AST already should exist
            var ast = (doc.ParsedDocument as ParsedDModule).DDom;

            if (ast == null)
                return null;

            // Get code cache
            var codeCache = DCodeCompletionSupport.EnumAvailableModules(doc);

            // Create editor context
            var line=editor.GetLineByOffset(offset);

            var EditorContext = new EditorData {
                CaretOffset=offset,
                CaretLocation = new CodeLocation(offset - line.Offset, editor.OffsetToLineNumber(offset)),
                ModuleCode = editor.Text,
                ParseCache = codeCache,
                SyntaxTree=ast as DModule
            };

            // Let the engine build all contents
            var ttContents= AbstractTooltipProvider.BuildToolTip(EditorContext);

            // Create tool tip item
            if (ttContents != null)
                return new TooltipItem(ttContents, offset, 1);
            return null;
        }
开发者ID:robik,项目名称:Mono-D,代码行数:36,代码来源:DToolTipProvider.cs

示例5: Draw

			public override void Draw (TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
			{
				var line = editor.GetLine (loc.Line);
				var x = editor.ColumnToX (line, loc.Column) - editor.HAdjustment.Value + editor.TextViewMargin.XOffset + editor.TextViewMargin.TextStartPosition;

				cr.Rectangle (Math.Floor (x) + 0.5, Math.Floor (y) + 0.5 + (line == editor.GetLineByOffset (startOffset) ? editor.LineHeight - tagMarkerHeight - 1 : 0), tagMarkerWidth * cr.LineWidth, tagMarkerHeight * cr.LineWidth);

				if (HslColor.Brightness (editor.ColorStyle.PlainText.Background) < 0.5) {
					cr.Color = new Cairo.Color (0.8, 0.8, 1, 0.9);
				} else {
					cr.Color = new Cairo.Color (0.2, 0.2, 1, 0.9);
				}
				cr.Stroke ();
			}
开发者ID:kenkendk,项目名称:monodevelop,代码行数:14,代码来源:CodeActionEditorExtension.cs

示例6: GetDiffRectangles

		public static ICollection<Cairo.Rectangle> GetDiffRectangles (TextEditor editor, int startOffset, int endOffset)
		{
			ICollection<Cairo.Rectangle> rectangles = new List<Cairo.Rectangle> ();
			var startLine = editor.GetLineByOffset (startOffset);
			var endLine = editor.GetLineByOffset (endOffset);
			int lineCount = endLine.LineNumber - startLine.LineNumber;
			var line = startLine;
			for (int i = 0; i <= lineCount; i++) {
				Cairo.Point point = editor.LocationToPoint (editor.Document.OffsetToLocation (Math.Max (startOffset, line.Offset)), true);
				Cairo.Point point2 = editor.LocationToPoint (editor.Document.OffsetToLocation (Math.Min (line.EndOffset, endOffset)), true);
				rectangles.Add (new Cairo.Rectangle (point.X - editor.TextViewMargin.XOffset, point.Y, point2.X - point.X, editor.LineHeight));
				line = line.NextLine;
			}
			return rectangles;
		}
开发者ID:telebovich,项目名称:monodevelop,代码行数:15,代码来源:EditorCompareWidgetBase.cs

示例7: GetDiffRectangle

		public static Cairo.Rectangle GetDiffRectangle (TextEditor editor, int startOffset, int endOffset)
		{
			var point = editor.LocationToPoint (editor.Document.OffsetToLocation (startOffset), true);
			Cairo.Point point2;
			var line = editor.GetLineByOffset (startOffset);
			if (line.Offset + line.Length < endOffset) {
				point2 = new Cairo.Point ((int)(point.X + editor.TextViewMargin.CharWidth * (endOffset - startOffset)), point.Y);
			} else {
				point2 = editor.LocationToPoint (editor.Document.OffsetToLocation (endOffset), true);
			}
			return new Cairo.Rectangle (point.X - editor.TextViewMargin.XOffset, point.Y, point2.X - point.X, editor.LineHeight);
		}
开发者ID:rajeshpillai,项目名称:monodevelop,代码行数:12,代码来源:EditorCompareWidgetBase.cs

示例8: DisableWithPragma

		public async void DisableWithPragma (TextEditor editor, DocumentContext context, Diagnostic fix, CancellationToken cancellationToken = default(CancellationToken))
		{
			var line = editor.GetLineByOffset (fix.Location.SourceSpan.Start);
			var span = new TextSpan (line.Offset, line.Length);
			var fixes = await CSharpSuppressionFixProvider.Instance.GetSuppressionsAsync (context.AnalysisDocument, span, new [] { fix }, cancellationToken ).ConfigureAwait (false);
			foreach (var f in fixes) {
				RunAction (context, f.Action, cancellationToken);
			}
		}
开发者ID:powerumc,项目名称:monodevelop_korean,代码行数:9,代码来源:CodeDiagnosticDescriptor.cs

示例9: Draw

		public override void Draw (TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
		{
			if (Debugger.DebuggingService.IsDebugging)
				return;
			int markerStart = Segment.Offset;
			int markerEnd = Segment.EndOffset;
			if (markerEnd < startOffset || markerStart > endOffset) 
				return;
			
			bool drawOverlay = result.InspectionMark == IssueMarker.GrayOut;
			
			if (drawOverlay && editor.IsSomethingSelected) {
				var selectionRange = editor.SelectionRange;
				if (selectionRange.Contains (markerStart) && selectionRange.Contains (markerEnd))
					return;
				if (selectionRange.Contains (markerEnd))
					markerEnd = selectionRange.Offset;
				if (selectionRange.Contains (markerStart))
					markerStart = selectionRange.EndOffset;
				if (markerEnd <= markerStart)
					return;
			}
			
			double drawFrom;
			double drawTo;
				
			if (markerStart < startOffset && endOffset < markerEnd) {
				drawTo = endXPos;
				var line = editor.GetLineByOffset (startOffset);
				int offset = line.GetIndentation (editor.Document).Length;
				drawFrom = startXPos + (layout.IndexToPos (offset).X  / Pango.Scale.PangoScale);
			} else {
				int start;
				if (startOffset < markerStart) {
					start = markerStart;
				} else {
					var line = editor.GetLineByOffset (startOffset);
					int offset = line.GetIndentation (editor.Document).Length;
					start = startOffset + offset;
				}
				int end = endOffset < markerEnd ? endOffset : markerEnd;
				int x_pos;

				x_pos = layout.IndexToPos (start - startOffset).X;
				drawFrom = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
				x_pos = layout.IndexToPos (end - startOffset).X;
	
				drawTo = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
			}
			
			drawFrom = System.Math.Max (drawFrom, editor.TextViewMargin.XOffset);
			drawTo = System.Math.Max (drawTo, editor.TextViewMargin.XOffset);
			if (drawFrom >= drawTo)
				return;
			
			double height = editor.LineHeight / 5;
			cr.SetSourceColor (GetColor (editor, Result));
			if (drawOverlay) {
				cr.Rectangle (drawFrom, y, drawTo - drawFrom, editor.LineHeight);
				var color = editor.ColorStyle.PlainText.Background;
				color.A = 0.6;
				cr.SetSourceColor (color);
				cr.Fill ();
			} else if (result.InspectionMark == IssueMarker.WavedLine) {	
				Pango.CairoHelper.ShowErrorUnderline (cr, drawFrom, y + editor.LineHeight - height, drawTo - drawFrom, height);
			} else if (result.InspectionMark == IssueMarker.DottedLine) {
				cr.Save ();
				cr.LineWidth = 1;
				cr.MoveTo (drawFrom + 1, y + editor.LineHeight - 1 + 0.5);
				cr.RelLineTo (System.Math.Min (drawTo - drawFrom, 4 * 3), 0);
				cr.SetDash (new double[] { 2, 2 }, 0);
				cr.Stroke ();
				cr.Restore ();
			} else {
				cr.MoveTo (drawFrom, y + editor.LineHeight - 1);
				cr.LineTo (drawTo, y + editor.LineHeight - 1);
				cr.Stroke ();
			}
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:79,代码来源:ResultMarker.cs


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