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


C# TextEditor.DocumentLocation类代码示例

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


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

示例1: Left

		public static void Left (TextEditorData data)
		{
			if (Platform.IsMac && data.IsSomethingSelected && !data.Caret.PreserveSelection) {
				data.Caret.Offset = System.Math.Min (data.SelectionAnchor, data.Caret.Offset);
				data.ClearSelection ();
				return;
			}
			
			if (data.Caret.Column > DocumentLocation.MinColumn) {
				DocumentLine line = data.Document.GetLine (data.Caret.Line);
				if (data.Caret.Column > line.Length + 1) {
					if (data.Caret.AllowCaretBehindLineEnd) {
						data.Caret.Column--;
					} else {
						data.Caret.Column = line.Length + 1;
					}
				} else {
					int offset = data.Caret.Offset - 1;
					foreach (var folding in data.Document.GetFoldingsFromOffset (offset).Where (f => f.IsFolded && f.Offset < offset)) {
						offset = System.Math.Min (offset, folding.Offset);
					}
					data.Caret.Offset = offset;
				}
			} else if (data.Caret.Line > DocumentLocation.MinLine) {
				DocumentLine prevLine = data.Document.GetLine (data.Caret.Line - 1);
				var nextLocation = new DocumentLocation (data.Caret.Line - 1, prevLine.Length + 1);
				if (data.HasIndentationTracker && data.Options.IndentStyle == IndentStyle.Virtual && nextLocation.Column == DocumentLocation.MinColumn)
					nextLocation = new DocumentLocation (data.Caret.Line - 1, data.GetVirtualIndentationColumn (nextLocation));
				data.Caret.Location = nextLocation;
			}
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:31,代码来源:CaretMoveActions.cs

示例2: TestCreateMethod

		void TestCreateMethod (string input, string outputString, bool returnWholeFile)
		{
			var generator = new CSharpCodeGeneratorNode ();
			MonoDevelop.Projects.CodeGeneration.CodeGenerator.AddGenerator (generator);
			var refactoring = new CreateMethodCodeGenerator ();
			RefactoringOptions options = ExtractMethodTests.CreateRefactoringOptions (input);
			Assert.IsTrue (refactoring.IsValid (options));
			if (returnWholeFile) {
				refactoring.SetInsertionPoint (CodeGenerationService.GetInsertionPoints (options.Document, refactoring.DeclaringType).First ());
			} else {
				DocumentLocation loc = new DocumentLocation (1, 1);
				refactoring.SetInsertionPoint (new InsertionPoint (loc, NewLineInsertion.Eol, NewLineInsertion.Eol));
			}
			List<Change> changes = refactoring.PerformChanges (options, null);
//			changes.ForEach (c => Console.WriteLine (c));
			// get just the generated method.
			string output = ExtractMethodTests.GetOutput (options, changes);
			if (returnWholeFile) {
				Assert.IsTrue (ExtractMethodTests.CompareSource (output, outputString), "Expected:" + Environment.NewLine + outputString + Environment.NewLine + "was:" + Environment.NewLine + output);
				return;
			}
			output = output.Substring (0, output.IndexOf ('}') + 1).Trim ();
			// crop 1 level of indent
			Document doc = new Document (output);
			foreach (LineSegment line in doc.Lines) {
				if (doc.GetCharAt (line.Offset) == '\t')
					((IBuffer)doc).Remove (line.Offset, 1);
			}
			output = doc.Text;
			
			Assert.IsTrue (ExtractMethodTests.CompareSource (output, outputString), "Expected:" + Environment.NewLine + outputString + Environment.NewLine + "was:" + Environment.NewLine + output);
			MonoDevelop.Projects.CodeGeneration.CodeGenerator.RemoveGenerator (generator);
		}
开发者ID:hduregger,项目名称:monodevelop,代码行数:33,代码来源:CreateMethodTests.cs

示例3: Update

        protected override void Update(CommandInfo info)
        {
            Document doc = IdeApp.Workbench.ActiveDocument;
            var editor = doc.GetContent<ITextEditorDataProvider> ();
            info.Enabled = false;
            if (doc != null
                && editor != null
                && doc.Project is MonoDroidProject)
            {
                var data = editor.GetTextEditorData ();

                var loc = new DocumentLocation (data.Caret.Line, data.Caret.Column);

                ResolveResult result;
                AstNode node;
                if (!doc.TryResolveAt (loc, out result, out node)) {
                    return;
                }

                var memberResolve = result as MemberResolveResult;
                if (memberResolve == null) {
                    return;
                }

                info.Enabled = ResourceHelper.IsResourcesMemberField(memberResolve);
            }
        }
开发者ID:matthewrdev,项目名称:xamarin-android-open-layout-definition,代码行数:27,代码来源:OpenResourceHandler.cs

示例4: FormatStatmentAt

		public static void FormatStatmentAt (MonoDevelop.Ide.Gui.Document data, DocumentLocation location)
		{
			var offset = data.Editor.LocationToOffset (location);
			var policyParent = data.Project != null ? data.Project.Policies : PolicyService.DefaultPolicies;
			var mimeTypeChain = DesktopService.GetMimeTypeInheritanceChain (CSharpFormatter.MimeType);
			Format (policyParent, mimeTypeChain, data, offset, offset, false, true);
		}		
开发者ID:telebovich,项目名称:monodevelop,代码行数:7,代码来源:OnTheFlyFormatter.cs

示例5: TryResolveAt

        public static bool TryResolveAt(this Document doc, DocumentLocation loc, out ResolveResult result, out AstNode node)
        {
            if(doc == null)
                throw new ArgumentNullException("doc");

            result = null;
            node = null;
            var parsed_doc = doc.ParsedDocument;
            if(parsed_doc == null)
                return false;

            var unit = parsed_doc.GetAst<SyntaxTree>();
            var parsed_file = parsed_doc.ParsedFile as BVE5UnresolvedFile;

            if(unit == null || parsed_file == null)
                return false;

            try{
                result = ResolveAtLocation.Resolve(new Lazy<ICompilation>(() => doc.Compilation), parsed_file, unit, loc, out node);
                if(result == null || node is Statement)
                    return false;
            }catch(Exception e){
                Console.WriteLine("Got resolver exception:" + e);
                return false;
            }
            return true;
        }
开发者ID:hazama-yuinyan,项目名称:monodevelop-bvebinding,代码行数:27,代码来源:HelperMethods.cs

示例6: Selection

		public Selection (DocumentLocation anchor, DocumentLocation lead, SelectionMode selectionMode = SelectionMode.Normal)
		{
			if (anchor.Line < DocumentLocation.MinLine || anchor.Column < DocumentLocation.MinColumn)
				throw new ArgumentOutOfRangeException ("anchor", anchor + " is out of range.");
			if (lead.Line < DocumentLocation.MinLine || lead.Column < DocumentLocation.MinColumn)
				throw new ArgumentOutOfRangeException ("lead", lead + " is out of range.");
			this.Anchor        = anchor;
			this.Lead          = lead;
			this.SelectionMode = selectionMode;
		}
开发者ID:txdv,项目名称:monodevelop,代码行数:10,代码来源:Selection.cs

示例7: Selection

		public Selection (DocumentLocation anchor, DocumentLocation lead, SelectionMode selectionMode)
		{
			if (anchor.Line < DocumentLocation.MinLine || anchor.Column < DocumentLocation.MinColumn)
				throw new ArgumentException ("anchor");
			if (lead.Line < DocumentLocation.MinLine || lead.Column < DocumentLocation.MinColumn)
				throw new ArgumentException ("lead");
			this.Anchor        = anchor;
			this.Lead          = lead;
			this.SelectionMode = selectionMode;
		}
开发者ID:nickname100,项目名称:monodevelop,代码行数:10,代码来源:Selection.cs

示例8: GetIndentationString

		string GetIndentationString (DocumentLocation loc)
		{
			var line = data.Document.GetLine (loc.Line);
			if (line == null)
				return "";
			// Get context to the end of the line w/o changing the main engine's state
			var offset = line.Offset;
			string curIndent = line.GetIndentation (data.Document);
			try {
				stateTracker.Update (Math.Min (data.Length, offset + Math.Min (line.Length, loc.Column - 1)));
				int nlwsp = curIndent.Length;
				if (!stateTracker.LineBeganInsideMultiLineComment || (nlwsp < line.LengthIncludingDelimiter && data.Document.GetCharAt (offset + nlwsp) == '*'))
					return stateTracker.ThisLineIndent;
			} catch (Exception e) {
				LoggingService.LogError ("Error while indenting at "+ loc, e); 
			}
			return curIndent;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:18,代码来源:JSonIndentationTracker.cs

示例9: Run

        protected override void Run()
        {
            Document doc = IdeApp.Workbench.ActiveDocument;
            var editor = doc.GetContent<ITextEditorDataProvider> ();
            if (doc != null
                && editor != null
                && doc.Project is MonoDroidProject)
            {
                var data = editor.GetTextEditorData ();
                var offset = data.Caret.Offset;

                var loc = new DocumentLocation (data.Caret.Line, data.Caret.Column);

                ResolveResult result;
                AstNode node;
                if (!doc.TryResolveAt (loc, out result, out node)) {
                    return;
                }

                var memberResolve = result as MemberResolveResult;
                if (memberResolve == null) {
                    return;
                }

                if (ResourceHelper.IsResourcesMemberField(memberResolve)) {

                    MonoDevelop.Projects.Project project;
                    if (memberResolve.Type.TryGetSourceProject (out project))
                    {
                        var androidProject = project as MonoDroidProject;
                        var fileNames = ResourceHelper.ResolveToFilenames (memberResolve, androidProject, ResourceFolders.LAYOUT);

                        if (fileNames.Count == 1) {
                            IdeApp.Workbench.OpenDocument(new FileOpenInformation(fileNames[0], project));
                        } else if (fileNames.Count > 1) {
                            OpenAutoOpenWindow (doc, data, project, fileNames);
                        } else {
                            Console.WriteLine ("Failed to resolve the layout");
                        }
                    }
                }
            }
        }
开发者ID:matthewrdev,项目名称:xamarin-android-open-layout-definition,代码行数:43,代码来源:OpenResourceHandler.cs

示例10: GetIndentationString

		string GetIndentationString (int offset, DocumentLocation loc)
		{
			stateTracker.UpdateEngine (Math.Min (data.Length, offset + 1));
			LineSegment line = data.Document.GetLine (loc.Line);

			// Get context to the end of the line w/o changing the main engine's state
			var ctx = (CSharpIndentEngine)stateTracker.Engine.Clone ();
			for (int max = offset; max < line.Offset + line.Length; max++) {
				ctx.Push (data.Document.GetCharAt (max));
			}
//			int pos = line.Offset;
			string curIndent = line.GetIndentation (data.Document);
			int nlwsp = curIndent.Length;
//			int o = offset > pos + nlwsp ? offset - (pos + nlwsp) : 0;
			if (!stateTracker.Engine.LineBeganInsideMultiLineComment || (nlwsp < line.LengthIncludingDelimiter && data.Document.GetCharAt (line.Offset + nlwsp) == '*')) {
				return ctx.ThisLineIndent;
			}
			return curIndent;
		}
开发者ID:txdv,项目名称:monodevelop,代码行数:19,代码来源:CSharpIndentVirtualSpaceManager.cs

示例11: LocationToPoint

		public Cairo.Point LocationToPoint (DocumentLocation loc, bool useAbsoluteCoordinates)
		{
			DocumentLine line = Document.GetLine (loc.Line);
			if (line == null)
				return new Cairo.Point (-1, -1);
			int x = (int)(ColumnToX (line, loc.Column) + this.XOffset + this.TextStartPosition);
			int y = (int)LineToY (loc.Line);
			return useAbsoluteCoordinates ? new Cairo.Point (x, y) : new Cairo.Point (x - (int)this.textEditor.HAdjustment.Value, y - (int)this.textEditor.VAdjustment.Value);
		}
开发者ID:OnorioCatenacci,项目名称:monodevelop,代码行数:9,代码来源:TextViewMargin.cs

示例12: CalculateClickLocation

		internal bool CalculateClickLocation (double x, double y, out DocumentLocation clickLocation)
		{
			VisualLocationTranslator trans = new VisualLocationTranslator (this);

			clickLocation = trans.PointToLocation (x, y);
			if (clickLocation.Line < DocumentLocation.MinLine || clickLocation.Column < DocumentLocation.MinColumn)
				return false;
			DocumentLine line = Document.GetLine (clickLocation.Line);
			if (line != null && clickLocation.Column >= line.Length + 1 && GetWidth (Document.GetTextAt (line.SegmentIncludingDelimiter) + "-") < x) {
				clickLocation = new DocumentLocation (clickLocation.Line, line.Length + 1);
				if (textEditor.GetTextEditorData ().HasIndentationTracker && textEditor.Options.IndentStyle == IndentStyle.Virtual && clickLocation.Column == 1) {
					int indentationColumn = this.textEditor.GetTextEditorData ().GetVirtualIndentationColumn (clickLocation);
					if (indentationColumn > clickLocation.Column)
						clickLocation = new DocumentLocation (clickLocation.Line, indentationColumn);
				}
			}
			return true;
		}
开发者ID:OnorioCatenacci,项目名称:monodevelop,代码行数:18,代码来源:TextViewMargin.cs

示例13: IsInsideSelection

		bool IsInsideSelection (DocumentLocation clickLocation)
		{
			var selection = textEditor.MainSelection;
			if (selection.SelectionMode == SelectionMode.Block) {
				int minColumn = System.Math.Min (selection.Anchor.Column, selection.Lead.Column);
				int maxColumn = System.Math.Max (selection.Anchor.Column, selection.Lead.Column);

				return selection.MinLine <= clickLocation.Line && clickLocation.Line <= selection.MaxLine &&
					minColumn <= clickLocation.Column && clickLocation.Column <= maxColumn;
			}
			return selection.Start <= clickLocation && clickLocation < selection.End;
		}
开发者ID:powerumc,项目名称:monodevelop_korean,代码行数:12,代码来源:TextViewMargin.cs

示例14: GetVirtualSpaceLayout

		LayoutWrapper GetVirtualSpaceLayout (DocumentLine line, DocumentLocation location)
		{
			string virtualSpace = "";
			var data = textEditor.GetTextEditorData ();
			if (data.HasIndentationTracker && line.Length == 0) {
				virtualSpace = this.textEditor.GetTextEditorData ().GetIndentationString (location);
			}
			if (location.Column > line.Length + 1 + virtualSpace.Length)
				virtualSpace += new string (' ', location.Column - line.Length - 1 - virtualSpace.Length);
			// predit layout already contains virtual space.
			if (!string.IsNullOrEmpty (textEditor.preeditString))
				virtualSpace = "";
			LayoutWrapper wrapper = new LayoutWrapper (textEditor.LayoutCache.RequestLayout ());
			wrapper.LineChars = virtualSpace.ToCharArray ();
			wrapper.Layout.SetText (virtualSpace);
			wrapper.Layout.Tabs = tabArray;
			wrapper.Layout.FontDescription = textEditor.Options.Font;
			int vy, vx;
			wrapper.Layout.GetSize (out vx, out vy);
			wrapper.Width = wrapper.LastLineWidth = vx / Pango.Scale.PangoScale;
			return wrapper;
		}
开发者ID:powerumc,项目名称:monodevelop_korean,代码行数:22,代码来源:TextViewMargin.cs

示例15: GetHeuristicResult

		static ResolveResult GetHeuristicResult (Document doc, DocumentLocation location, ref AstNode node)
		{
			int offset = doc.Editor.Caret.Offset;
			bool wasLetter = false, wasWhitespaceAfterLetter = false;
			while (offset < doc.Editor.Length) {
				char ch = doc.Editor.GetCharAt (offset);
				bool isLetter = char.IsLetterOrDigit (ch) || ch == '_';
				bool isWhiteSpace = char.IsWhiteSpace (ch);
				bool isValidPunc = ch == '.' || ch == '<' || ch == '>';

				if (!(wasLetter && wasWhitespaceAfterLetter) && (isLetter || isWhiteSpace || isValidPunc)) {
					if (isValidPunc) {
						wasWhitespaceAfterLetter = false;
						wasLetter = false;
					}
					offset++;
				} else {
					offset--;
					while (offset > 1) {
						ch = doc.Editor.GetCharAt (offset - 1);
						if (!(ch == '.' || char.IsWhiteSpace (ch)))
							break;
						offset--;
					}
					break;
				}

				wasLetter |= isLetter;
				if (wasLetter)
					wasWhitespaceAfterLetter |= isWhiteSpace;
			}

			var unit = SyntaxTree.Parse (CreateStub (doc, offset), doc.FileName);

			return ResolveAtLocation.Resolve (
				doc.Compilation, 
				doc.ParsedDocument.ParsedFile as CSharpUnresolvedFile,
				unit,
				location, 
				out node);
		}
开发者ID:EminThaqi,项目名称:monodevelop,代码行数:41,代码来源:ResolveCommandHandler.cs


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