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


C# ITextEditor类代码示例

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


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

示例1: RunImpl

		protected override void RunImpl(ITextEditor editor, int offset, ResolveResult symbol)
		{
			if (symbol == null)
				return;
			
			FilePosition pos = symbol.GetDefinitionPosition();
			if (pos.IsEmpty) {
				IEntity entity;
				if (symbol is MemberResolveResult) {
					entity = ((MemberResolveResult)symbol).ResolvedMember;
				} else if (symbol is TypeResolveResult) {
					entity = ((TypeResolveResult)symbol).ResolvedClass;
				} else {
					entity = null;
				}
				if (entity != null) {
					NavigationService.NavigateTo(entity);
				}
			} else {
				try {
					if (pos.Position.IsEmpty)
						FileService.OpenFile(pos.FileName);
					else
						FileService.JumpToFilePosition(pos.FileName, pos.Line, pos.Column);
				} catch (Exception ex) {
					MessageService.ShowException(ex, "Error jumping to '" + pos.FileName + "'.");
				}
			}
		}
开发者ID:pir0,项目名称:SharpDevelop,代码行数:29,代码来源:GoToDefinition.cs

示例2: EditorScript

		public EditorScript(ITextEditor editor, SDRefactoringContext context, CSharpFormattingOptions formattingOptions)
			: base(editor.Document, formattingOptions, context.TextEditorOptions)
		{
			this.editor = editor;
			this.context = context;
			this.textSegmentCollection = new TextSegmentCollection<TextSegment>((TextDocument)editor.Document);
		}
开发者ID:kristjan84,项目名称:SharpDevelop,代码行数:7,代码来源:EditorScript.cs

示例3: SharpDevelopCompletionWindow

		public SharpDevelopCompletionWindow(ITextEditor editor, TextArea textArea, ICompletionItemList itemList) : base(textArea)
		{
			if (editor == null)
				throw new ArgumentNullException("editor");
			if (itemList == null)
				throw new ArgumentNullException("itemList");
			
			if (!itemList.ContainsAllAvailableItems) {
				// If more items are available (Ctrl+Space wasn't pressed), show this hint
				this.EmptyText = StringParser.Parse("${res:ICSharpCode.AvalonEdit.AddIn.SharpDevelopCompletionWindow.EmptyText}");
			}
			
			InitializeComponent();
			this.Editor = editor;
			this.itemList = itemList;
			ICompletionItem suggestedItem = itemList.SuggestedItem;
			foreach (ICompletionItem item in itemList.Items) {
				ICompletionData adapter = new CodeCompletionDataAdapter(this, item);
				this.CompletionList.CompletionData.Add(adapter);
				if (item == suggestedItem)
					this.CompletionList.SelectedItem = adapter;
			}
			this.StartOffset -= itemList.PreselectionLength;
			this.EndOffset += itemList.PostselectionLength;
		}
开发者ID:fanyjie,项目名称:SharpDevelop,代码行数:25,代码来源:SharpDevelopCompletionWindow.cs

示例4: Attach

		public override void Attach(ITextEditor editor)
		{
			base.Attach(editor);
			
			// try to access the ICSharpCode.AvalonEdit.Rendering.TextView
			// of this ITextEditor
			this.textView = editor.GetService(typeof(TextView)) as TextView;
			
			// if editor is not an AvalonEdit.TextEditor
			// GetService returns null
			if (textView != null) {
				if (SD.Workbench != null) {
//					if (XamlBindingOptions.UseAdvancedHighlighting) {
//						colorizer = new XamlColorizer(editor, textView);
//						// attach the colorizer
//						textView.LineTransformers.Add(colorizer);
//					}
					// add the XamlOutlineContentHost, which manages the tree view
					contentHost = new XamlOutlineContentHost(editor);
					textView.Services.AddService(typeof(IOutlineContentHost), contentHost);
				}
				// add ILanguageBinding
				textView.Services.AddService(typeof(XamlTextEditorExtension), this);
			}
			
			SD.ParserService.ParseInformationUpdated += ParseInformationUpdated;
		}
开发者ID:hefnerliu,项目名称:SharpDevelop,代码行数:27,代码来源:XamlLanguageBinding.cs

示例5: OverrideEqualsGetHashCodeMethodsDialog

		public OverrideEqualsGetHashCodeMethodsDialog(InsertionContext context, ITextEditor editor, ITextAnchor endAnchor,
		                                              ITextAnchor insertionPosition, ITypeDefinition selectedClass, IMethod selectedMethod, AstNode baseCallNode)
			: base(context, editor, insertionPosition)
		{
			if (selectedClass == null)
				throw new ArgumentNullException("selectedClass");
			
			InitializeComponent();
			
			this.selectedClass = selectedClass;
			this.insertionEndAnchor = endAnchor;
			this.selectedMethod = selectedMethod;
			this.baseCallNode = baseCallNode;
			
			addIEquatable.Content = string.Format(StringParser.Parse("${res:AddIns.SharpRefactoring.OverrideEqualsGetHashCodeMethods.AddInterface}"),
			                                      "IEquatable<" + selectedClass.Name + ">");
			
			string otherMethod = selectedMethod.Name == "Equals" ? "GetHashCode" : "Equals";
			
			addOtherMethod.Content = StringParser.Parse("${res:AddIns.SharpRefactoring.OverrideEqualsGetHashCodeMethods.AddOtherMethod}", new StringTagPair("otherMethod", otherMethod));
			
			addIEquatable.IsEnabled = !selectedClass.GetAllBaseTypes().Any(
				type => {
					if (!type.IsParameterized || (type.TypeParameterCount != 1))
						return false;
					if (type.FullName != "System.IEquatable")
						return false;
					return type.TypeArguments.First().FullName == selectedClass.FullName;
				}
			);
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:31,代码来源:OverrideEqualsGetHashCodeMethodsDialog.xaml.cs

示例6: IndentLine

		public override void IndentLine(ITextEditor editor, IDocumentLine line)
		{
			LineIndenter indenter = CreateLineIndenter(editor, line);
			if (!indenter.Indent()) {
				base.IndentLine(editor, line);
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:7,代码来源:ScriptingFormattingStrategy.cs

示例7: Refactor

		protected override bool Refactor(ITextEditor editor, XDocument document)
		{
			if (editor.SelectionLength == 0) {
				MessageService.ShowError("Nothing selected!");
				return false;
			}
			
			Location startLoc = editor.Document.OffsetToPosition(editor.SelectionStart);
			Location endLoc = editor.Document.OffsetToPosition(editor.SelectionStart + editor.SelectionLength);
			
			var selectedItems = (from item in document.Root.Descendants()
			                     where item.IsInRange(startLoc, endLoc) select item).ToList();
			
			if (selectedItems.Any()) {
				var parent = selectedItems.First().Parent;
				
				currentWpfNamespace = parent.GetCurrentNamespaces()
					.First(i => CompletionDataHelper.WpfXamlNamespaces.Contains(i));
				
				var items = selectedItems.Where(i => i.Parent == parent);
				
				return GroupInto(parent, items);
			}
			
			return false;
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:26,代码来源:GroupIntoRefactorings.cs

示例8: ModuleOutlineControl

        internal ModuleOutlineControl(ITextEditor textEditor)
            : this()
        {
            _textEditor = textEditor;

            SD.ParserService.ParseInformationUpdated += ParserService_ParseInformationUpdated;
        }
开发者ID:mks786,项目名称:vb6leap,代码行数:7,代码来源:ModuleOutlineControl.xaml.cs

示例9: Format

		/// <summary>
		/// Formats the specified part of the document.
		/// </summary>
		public static void Format(ITextEditor editor, int offset, int length, CSharpFormattingOptions options)
		{
			var formatter = new CSharpFormatter(options, editor.ToEditorOptions());
			formatter.AddFormattingRegion(new DomRegion(editor.Document.GetLocation(offset), editor.Document.GetLocation(offset + length)));
			var changes = formatter.AnalyzeFormatting(editor.Document, SyntaxTree.Parse(editor.Document));
			changes.ApplyChanges(offset, length);
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:10,代码来源:CSharpFormatter.cs

示例10: Refactor

		protected override bool Refactor(ITextEditor editor, XDocument document)
		{
			Location startLoc = editor.Document.OffsetToPosition(editor.SelectionStart);
			Location endLoc = editor.Document.OffsetToPosition(editor.SelectionStart + editor.SelectionLength);
			
			XName[] names = CompletionDataHelper.WpfXamlNamespaces.Select(item => XName.Get("Grid", item)).ToArray();
			
			XElement selectedItem = document.Root.Descendants()
				.FirstOrDefault(item => item.IsInRange(startLoc, endLoc) && names.Any(ns => ns == item.Name))
				?? document.Root.Elements().FirstOrDefault(i => names.Any(ns => ns == i.Name));
			
			if (selectedItem == null) {
				MessageService.ShowError("Please select a Grid!");
				return false;
			}
			
			EditGridColumnsAndRowsDialog dialog = new EditGridColumnsAndRowsDialog(selectedItem);
			dialog.Owner = WorkbenchSingleton.MainWindow;
			
			if (dialog.ShowDialog() == true) {
				selectedItem.ReplaceWith(dialog.ConstructedTree);
				return true;
			}
			
			return false;
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:26,代码来源:EditGridColumnsAndRowsCommand.cs

示例11: HandleKeyPress

        public CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch)
        {
            if (this.CompletionPossible(editor, ch)) {

                ResourceResolveResult result = ResourceResolverService.Resolve(editor, ch);
                if (result != null) {
                    IResourceFileContent content;
                    if ((content = result.ResourceFileContent) != null) {

                        // If the resolved resource set is the local ICSharpCode.Core resource set
                        // (this may happen through the ICSharpCodeCoreNRefactoryResourceResolver),
                        // we will have to merge in the host resource set (if available)
                        // for the code completion window.
                        if (result.ResourceSetReference.ResourceSetName == ICSharpCodeCoreResourceResolver.ICSharpCodeCoreLocalResourceSetName) {
                            IResourceFileContent hostContent = ICSharpCodeCoreResourceResolver.GetICSharpCodeCoreHostResourceSet(editor.FileName).ResourceFileContent;
                            if (hostContent != null) {
                                content = new MergedResourceFileContent(content, new IResourceFileContent[] { hostContent });
                            }
                        }

                        editor.ShowCompletionWindow(new ResourceCodeCompletionItemList(content, this.OutputVisitor, result.CallingClass != null ? result.CallingClass.Name+"." : null));
                        return CodeCompletionKeyPressResult.Completed;
                    }
                }

            }

            return CodeCompletionKeyPressResult.None;
        }
开发者ID:ichengzi,项目名称:SharpDevelop,代码行数:29,代码来源:AbstractNRefactoryResourceCodeCompletionBinding.cs

示例12: IndentLines

 public override void IndentLines(ITextEditor editor, int beginLine, int endLine)
 {
     //DocumentAccessor acc = new DocumentAccessor(editor.Document, beginLine, endLine);
     //CSharpIndentationStrategy indentStrategy = new CSharpIndentationStrategy();
     //indentStrategy.IndentationString = editor.Options.IndentationString;
     //indentStrategy.Indent(acc, true);
     SharpLua.Visitors.NonModifiedAstBeautifier b = null;
     try
     {
         Lexer l = new Lexer();
         Parser p = new Parser(l.Lex(editor.Document.Text));
         SharpLua.Ast.Chunk c = p.Parse();
         b = new SharpLua.Visitors.NonModifiedAstBeautifier();
         //SharpLua.Visitors.ExactReconstruction b = new SharpLua.Visitors.ExactReconstruction();
         b.options.Tab = editor.Options.IndentationString;
         b.options.TabsToSpaces = editor.Options.ConvertTabsToSpaces;
         int off = editor.Caret.Offset;
         //editor.Document.Text = b.Reconstruct(c);
         editor.Document.Text = b.Beautify(c);
         editor.Caret.Offset = off >= editor.Document.TextLength ? 0 : off;
     }
     catch (LuaSourceException ex)
     {
         LoggingService.Warn("Error parsing document: " + System.IO.Path.GetFileName(ex.GenerateMessage(editor.FileName)));
     }
     catch (System.Exception ex)
     {
         LoggingService.Error("Error formatting document:", ex);
         MessageBox.Show(b.index.ToString() + " "+ b.tok.Count);
         MessageBox.Show("Error formatting Lua script: " + ex.ToString() + "\r\n\r\nPlease report this to the SharpLua GitHub page so it can get fixed");
     }
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:32,代码来源:SharpLuaFormattingStrategy.cs

示例13: SurroundSelectionWithSingleLineComment

		/// <summary>
		/// Default implementation for single line comments.
		/// </summary>
		protected void SurroundSelectionWithSingleLineComment(ITextEditor editor, string comment)
		{
			IDocument document = editor.Document;
			using (document.OpenUndoGroup()) {
				TextLocation startPosition = document.GetLocation(editor.SelectionStart);
				TextLocation endPosition = document.GetLocation(editor.SelectionStart + editor.SelectionLength);
				
				// endLine is one above endPosition if no characters are selected on the last line (e.g. line selection from the margin)
				int endLine = (endPosition.Column == 1 && endPosition.Line > startPosition.Line) ? endPosition.Line - 1 : endPosition.Line;
				
				List<IDocumentLine> lines = new List<IDocumentLine>();
				bool removeComment = true;
				
				for (int i = startPosition.Line; i <= endLine; i++) {
					lines.Add(editor.Document.GetLineByNumber(i));
					if (!document.GetText(lines[i - startPosition.Line]).Trim().StartsWith(comment, StringComparison.Ordinal))
						removeComment = false;
				}
				
				foreach (IDocumentLine line in lines) {
					if (removeComment) {
						document.Remove(line.Offset + document.GetText(line).IndexOf(comment, StringComparison.Ordinal), comment.Length);
					} else {
						document.Insert(line.Offset, comment, AnchorMovementType.BeforeInsertion);
					}
				}
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:31,代码来源:IFormattingStrategy.cs

示例14: FoldingManagerAdapter

 public FoldingManagerAdapter(ITextEditor textEditor)
 {
     AvalonEditTextEditorAdapter adaptor = textEditor as AvalonEditTextEditorAdapter;
     if (adaptor != null) {
         this.foldingManager = FoldingManager.Install(adaptor.TextEditor.TextArea);
     }
 }
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:7,代码来源:FoldingManagerAdapter.cs

示例15: GenerateCompletionList

		/// <inheritdoc/>
		public override ICompletionItemList GenerateCompletionList(ITextEditor editor)
		{
			if (editor == null)
				throw new ArgumentNullException("textEditor");
			ExpressionResult expression = GetExpression(editor);
			return GenerateCompletionListForExpression(editor, expression);
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:8,代码来源:CodeCompletionItemProvider.cs


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