• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# TextEditor.TextDocument类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: InvalidMimeTypeInScriptTypeAttribute

		public void InvalidMimeTypeInScriptTypeAttribute ()
		{
			var doc = new TextDocument ();
			var syntaxMode = new WebFormsSyntaxMode ();
			syntaxMode.Document = doc;
			doc.Text = 
@"<%@ Page Language=""C#"" Inherits=""AspnetTest.Default"" %>
<!DOCTYPE html>
<html>
<head runat=""server"">
	<title>Default</title>
</head>
<body>
	<form id=""form1"" runat=""server"">
		<asp:Button id=""button1"" runat=""server"" Text=""Click me!"" OnClick=""button1Clicked"" />
	</form>
	<script type=""></script>
</body>
</html>
";
			var style = new ColorScheme ();
			foreach (DocumentLine line in doc.Lines) {
				Assert.DoesNotThrow (() => syntaxMode.GetChunks (style, line, line.Offset, line.Length).ToList ());
			}
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:25,代码来源:WebFormsSyntaxModeTests.cs


示例2: CompareWindow

        /// <summary>
        /// Initializes a new instance of the <see cref="Trilogic.CompareWindow"/> class.
        /// </summary>
        /// <param name="parent">The parent window.</param>
        /// <param name="compareName">Compare name.</param>
        /// <param name="fileSide">File side.</param>
        /// <param name="databaseSide">Database side.</param>
        public CompareWindow(MainWindow parent, string compareName, SchemaData fileSide, SchemaData databaseSide)
            : base(Gtk.WindowType.Toplevel)
        {
            this.Build();
            this.parent = parent;

            this.docLocal = new TextDocument();
            this.docDB = new TextDocument();

            this.editorLocal = new TextEditor(this.docLocal);
            this.editorDB = new TextEditor(this.docDB);

            Gtk.ScrolledWindow scrollLocal = new Gtk.ScrolledWindow();
            Gtk.ScrolledWindow scrollDB = new Gtk.ScrolledWindow();
            scrollLocal.Add(this.editorLocal);
            scrollDB.Add(this.editorDB);

            this.hbox1.Add(scrollDB);
            this.hbox1.Add(scrollLocal);

            Gtk.Box.BoxChild childLocal = (Gtk.Box.BoxChild)this.hbox1[scrollLocal];
            childLocal.Position = 2;

            Gtk.Box.BoxChild childDB = (Gtk.Box.BoxChild)this.hbox1[scrollDB];
            childDB.Position = 0;

            this.ShowAll();

            this.Title += " - " + compareName;

            this.fileSide = fileSide;
            this.databaseSide = databaseSide;

            this.ShowSchema();
        }
开发者ID:Etersoul,项目名称:trilogic-data,代码行数:42,代码来源:CompareWindow.cs


示例3: Run

		protected override void Run (object dataItem)
		{
			base.Run (dataItem);

			if (IdeApp.Workspace == null) return;
			if (IdeApp.Workbench.ActiveDocument == null || IdeApp.Workbench.ActiveDocument.FileName == FilePath.Null) return;

			var document = IdeApp.Workbench.ActiveDocument;

			ResolveResult resolveResult = null;
			object item = CurrentRefactoryOperationsHandler.GetItem (document, out resolveResult);

			IMethod method = item as IMethod;
			if (method == null)
				return;

			ISearchProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetSearchProgressMonitor(true, true);
			ThreadPool.QueueUserWorkItem((data) => 
			{
				try
				{
					ImplementationsFinder.Find(method, implementation =>
					{
						FileProvider fileProvider = new FileProvider(implementation.Region.FileName);
						TextDocument doc = new TextDocument();
						doc.Text = fileProvider.ReadString();
						int offset = doc.LocationToOffset(implementation.Region.BeginLine, implementation.Region.BeginColumn);
						while ((offset + implementation.Name.Length) < doc.TextLength)
						{
							if (doc.GetTextAt(offset, implementation.Name.Length) == implementation.Name)
							{
								break;
							}
							offset++;
						}

						monitor.ReportResult (new MonoDevelop.Ide.FindInFiles.SearchResult(fileProvider, offset, implementation.Name.Length));
					});
				}
				catch (Exception exception)
				{
					if (monitor != null)
					{
						monitor.ReportError("Error finding references", exception);
					}
					else
					{
						LoggingService.LogError("Error finding references", exception);
					}
				}
				finally
				{
					if (monitor != null)
					{
						monitor.Dispose();
					}
				}
			});
		}
开发者ID:nixxa,项目名称:MonoDevelop.AddIns,代码行数:59,代码来源:FindImplementationsHandler.cs


示例4: SourceEditorPrintOperation

		public SourceEditorPrintOperation (TextDocument doc, FilePath filename)
		{
			this.doc = doc;
			this.filename = filename;
			this.settings = SourceEditorPrintSettings.Load ();
			
			this.Unit = Unit.Mm;
		}
开发者ID:nocache,项目名称:monodevelop,代码行数:8,代码来源:SourceEditorPrintOperation.cs


示例5: GetPrevOffset

		static int GetPrevOffset (TextDocument document, int lineNumber)
		{
			int startLineNumber = lineNumber - 1;
			if (startLineNumber < 0) 
				startLineNumber =  document.TextLength - 1;
			var line = document.GetLinesReverseStartingAt (startLineNumber - 1).FirstOrDefault (l => l.IsBookmarked);
			return line != null ? line.Offset : -1;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:8,代码来源:BookmarkActions.cs


示例6: GetNextOffset

		static int GetNextOffset (TextDocument document, int lineNumber)
		{
			int startLineNumber = lineNumber + 1;
			if (startLineNumber > document.TextLength) 
				startLineNumber = 0;
			var line = document.GetLinesStartingAt (startLineNumber).FirstOrDefault (l => l.IsBookmarked);
			return line != null ? line.Offset : -1;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:8,代码来源:BookmarkActions.cs


示例7: GetList

		static List<string> GetList (TextDocument document, string name)
		{
			var mode = document.SyntaxMode as SyntaxMode;
			if (mode != null) {
				if (mode.Properties.ContainsKey(name)) 
					return mode.Properties[name];
			}
			return new List<string> ();
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:9,代码来源:IBracketMatcher.cs


示例8: UrlMarker

		public UrlMarker (TextDocument doc, DocumentLine line, string url, UrlType urlType, string style, int startColumn, int endColumn)
		{
			this.doc = doc;
			this.line = line;
			this.url = url;
			this.urlType = urlType;
			this.style = style;
			this.startColumn = startColumn;
			this.endColumn = endColumn;
			doc.LineChanged += HandleDocLineChanged;
		}
开发者ID:xiexin36,项目名称:monodevelop,代码行数:11,代码来源:UrlMarker.cs


示例9: StartsWithListMember

		static int StartsWithListMember (TextDocument document, List<string> list, int offset)
		{
			for (int i = 0; i < list.Count; i++) {
				string item = list[i];
				if (offset + item.Length < document.TextLength) {
					if (document.GetTextAt (offset, item.Length) == item) 
						return i;
				}
			}
			return -1;
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:11,代码来源:IBracketMatcher.cs


示例10: TextDocumentWrapper

		public TextDocumentWrapper (TextDocument document)
		{
			if (document == null)
				throw new ArgumentNullException (nameof (document));
			this.document = document;
			this.document.TextReplaced += HandleTextReplaced;
			this.document.TextReplacing += HandleTextReplacing;
			this.document.LineChanged += Document_LineChanged; 
			this.document.LineInserted += Document_LineInserted;
			this.document.LineRemoved += Document_LineRemoved;
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:11,代码来源:ITextDocumentWrapper.cs


示例11: MatchingBracketTests

		public void MatchingBracketTests (string text, int offset, int expectedOffsetMatch)
		{
			var editor = TextEditorFactory.CreateNewEditor ();
			editor.MimeType = "text/x-csharp";
			editor.Text = text;
			var document = new TextDocument (text);

			int actualOffset = SimpleBracketMatcher.GetMatchingBracketOffset (editor, offset);
			int actualOffset2 = document.GetMatchingBracketOffset (offset);

			Assert.AreEqual (actualOffset2, actualOffset);
			Assert.AreEqual (expectedOffsetMatch, actualOffset);
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:13,代码来源:SimpleBracketMatcherTests.cs


示例12: FindPrevWordOffset

		int FindPrevWordOffset (TextDocument doc, int offset, bool subword)
		{
			int lineNumber = doc.OffsetToLineNumber (offset);
			DocumentLine line = doc.GetLine (lineNumber);
			if (line == null)
				return offset;
			
			int result = offset;
			if (result == line.Offset) {
				line = doc.GetLine (lineNumber - 1);
				if (line != null)
					result = line.Offset + line.Length;
				return result;
			}
			
			CharacterClass current = GetCharacterClass (doc.GetCharAt (result - 1), subword, false);
			
			if (current == CharacterClass.Whitespace && result - 1 > line.Offset) {
				result--;
				current = GetCharacterClass (doc.GetCharAt (result - 2), subword, false);
			}
			
			while (result > line.Offset) {
				CharacterClass prev = GetCharacterClass (doc.GetCharAt (result - 1), subword, false);
				if (prev != current) {
					
					// camelCase and PascalCase handling
					bool camelSkip = false;
					if (prev == CharacterClass.UppercaseLetter && current == CharacterClass.LowercaseLetter) {
						if (result-2 > line.Offset) {
							CharacterClass back2 = GetCharacterClass (doc.GetCharAt (result-2), subword, false);
							if (back2 == CharacterClass.UppercaseLetter)
								result--;
							else
								camelSkip = true;
						}
					}
					
					if (!camelSkip)
						break;
				}
				
				current = prev;
				result--;
			}
			
			return result;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:48,代码来源:SharpDevelopWordFindStrategy.cs


示例13: JaySyntaxMode

		public JaySyntaxMode (TextDocument doc) : base (doc)
		{
			ResourceXmlProvider provider = new ResourceXmlProvider (typeof(IXmlProvider).Assembly, typeof(IXmlProvider).Assembly.GetManifestResourceNames ().First (s => s.Contains ("JaySyntaxMode")));
			using (XmlReader reader = provider.Open ()) {
				SyntaxMode baseMode = SyntaxMode.Read (reader);
				this.rules = new List<Rule> (baseMode.Rules);
				this.keywords = new List<Keywords> (baseMode.Keywords);
				this.spans = new List<Span> (baseMode.Spans).ToArray ();
				this.matches = baseMode.Matches;
				this.prevMarker = baseMode.PrevMarker;
				this.SemanticRules = new List<SemanticRule> (baseMode.SemanticRules);
				this.keywordTable = baseMode.keywordTable;
				this.keywordTableIgnoreCase = baseMode.keywordTableIgnoreCase;
				this.properties = baseMode.Properties;
			}
		}
开发者ID:nocache,项目名称:monodevelop,代码行数:16,代码来源:JaySyntaxMode.cs


示例14: FindNextWordOffset

		int FindNextWordOffset (TextDocument doc, int offset, bool subword)
		{
			int lineNumber   = doc.OffsetToLineNumber (offset);
			DocumentLine line = doc.GetLine (lineNumber);
			if (line == null)
				return offset;
			
			int result    = offset;
			int endOffset = line.Offset + line.Length;
			if (result == endOffset) {
				line = doc.GetLine (lineNumber + 1);
				if (line != null)
					result = line.Offset;
				return result;
			}
			
			CharacterClass current = GetCharacterClass (doc.GetCharAt (result), subword, false);
			while (result < endOffset) {
				CharacterClass next = GetCharacterClass (doc.GetCharAt (result), subword, false);
				if (next != current) {
					
					// camelCase and PascalCase handling
					bool camelSkip = false;
					if (next == CharacterClass.LowercaseLetter && current == CharacterClass.UppercaseLetter) {
						if (result-2 > line.Offset) {
							CharacterClass previous = GetCharacterClass (doc.GetCharAt (result-2), subword, false);
							if (previous == CharacterClass.UppercaseLetter && result-2 > offset)
								result--;
							else
								camelSkip = true;
						}
					}
					
					if (!camelSkip)
						break;
				}
				
				current = next;		
				result++;
			}
			while (result < endOffset && GetCharacterClass (doc.GetCharAt (result), subword, false) == CharacterClass.Whitespace) {
				result++;
			}
			return result;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:45,代码来源:SharpDevelopWordFindStrategy.cs


示例15: FindNextWordOffset

		int FindNextWordOffset (TextDocument doc, int offset, bool subword)
		{
			if (offset + 1 >= doc.TextLength)
				return doc.TextLength;
			int result = offset + 1;
			CC previous = SW.GetCharacterClass (doc.GetCharAt (result), subword, includeUnderscore);
			bool inIndentifier = previous != CC.Unknown && previous != CC.Whitespace;			
			while (result < doc.TextLength) {
				char ch = doc.GetCharAt (result);
				CC current = SW.GetCharacterClass (ch, subword, includeUnderscore);
				
				//camelCase / PascalCase splitting
				if (subword) {
					if (current == CC.Digit && (previous != CC.Digit || (result-1 == offset && !Char.IsDigit (doc.GetCharAt (result-1))))) {
						break;
					} else if (previous == CC.Digit && current != CC.Digit) {
						break;
					} else if (current == CC.UppercaseLetter && previous != CC.UppercaseLetter) {
						break;
					} else if (current == CC.LowercaseLetter && previous == CC.UppercaseLetter && result - 2 > 0
					           && SW.GetCharacterClass (doc.GetCharAt (result - 2), subword, includeUnderscore) != CC.LowercaseLetter)
					{
						result--;
						break;
					}
				}
				
				//else break at end of identifiers
				if (previous != CC.Unknown && previous != CC.Whitespace) {
					inIndentifier = true;
				} else if (inIndentifier) {
					result--;
					break;
				}
				previous = current;
				result++;
			}
			foreach (FoldSegment segment in doc.GetFoldingsFromOffset (result)) {
				if (segment.IsFolded)
					result = System.Math.Max (result, segment.EndLine.Offset + segment.EndColumn);
			}
			return result;
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:43,代码来源:EmacsWordFindStrategy.cs


示例16: Analyze

		public override void Analyze (TextDocument doc, DocumentLine line, Chunk startChunk, int startOffset, int endOffset)
		{
			if (endOffset <= startOffset || startOffset >= doc.TextLength || inUpdate)
				return;
			inUpdate = true;
			try {
				string text = doc.GetTextAt (startOffset, endOffset - startOffset);
				int startColumn = startOffset - line.Offset;
				var markers = new List <UrlMarker> (line.Markers.Where (m => m is UrlMarker).Cast<UrlMarker> ());
				markers.ForEach (m => doc.RemoveMarker (m, false));
				foreach (System.Text.RegularExpressions.Match m in UrlRegex.Matches (text)) {
					doc.AddMarker (line, new UrlMarker (doc, line, m.Value, UrlType.Url, syntax, startColumn + m.Index, startColumn + m.Index + m.Length), false);
				}
				foreach (System.Text.RegularExpressions.Match m in MailRegex.Matches (text)) {
					doc.AddMarker (line, new UrlMarker (doc, line, m.Value, UrlType.Email, syntax, startColumn + m.Index, startColumn + m.Index + m.Length), false);
				}
			} finally {
				inUpdate = false;
			}
		}
开发者ID:nocache,项目名称:monodevelop,代码行数:20,代码来源:SemanticRule.cs


示例17: Analyze

			public override void Analyze(TextDocument doc, DocumentLine line, Chunk startChunk, int startOffset, int endOffset)
			{
				// Check line start
				int o = line.Offset;
				char c = '\0';
				for (; o < line.EndOffset && char.IsWhiteSpace(c = doc.GetCharAt(o)); o++) ;

				if (c != '-' && c != '#')
					return;

				DSyntax.Document = doc;
				var spanParser = new SpanParser(DSyntax, new CloneableStack<Span>());
				var chunkP = new ChunkParser(DSyntax, spanParser, Ide.IdeApp.Workbench.ActiveDocument.Editor.ColorStyle, line);

				var n = chunkP.GetChunks(startOffset, endOffset - startOffset);
				if (n == null)
					return;
				startChunk.Next = n;
				startChunk.Length = n.Offset - startChunk.Offset;
			}
开发者ID:DinrusGroup,项目名称:Mono-D,代码行数:20,代码来源:DietTemplateSyntaxMode.cs


示例18: Analyze

		public override void Analyze (TextDocument doc, DocumentLine line, Chunk startChunk, int startOffset, int endOffset)
		{
			if (endOffset <= startOffset || startOffset >= doc.TextLength || inUpdate)
				return;
			if (startChunk.Style != Highlighting.ColorScheme.CommentsSingleLineKey && startChunk.Style != Highlighting.ColorScheme.CommentsBlockKey)
				return;
			inUpdate = true;
			try {
				string text = doc.GetTextAt (startOffset, System.Math.Min (endOffset, doc.TextLength) - startOffset);
				int startColumn = startOffset - line.Offset;
				var markers = new List <UrlMarker> (line.Markers.OfType<UrlMarker> ());
				markers.ForEach (m => doc.RemoveMarker (m, false));
				foreach (System.Text.RegularExpressions.Match m in UrlRegex.Matches (text)) {
					doc.AddMarker (line, new UrlMarker (doc, line, m.Value, UrlType.Url, syntax, startColumn + m.Index, startColumn + m.Index + m.Length), false);
				}
				foreach (System.Text.RegularExpressions.Match m in MailRegex.Matches (text)) {
					doc.AddMarker (line, new UrlMarker (doc, line, m.Value, UrlType.Email, syntax, startColumn + m.Index, startColumn + m.Index + m.Length), false);
				}
			} finally {
				inUpdate = false;
			}
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:22,代码来源:SemanticRule.cs


示例19: CreateFileContent

			public override System.IO.Stream CreateFileContent(SolutionItem policyParent, Project project, string language, string fileName, string identifier)
			{
				if (Outer.FormatCode)
				{
					return base.CreateFileContent(policyParent, project, language, fileName, identifier);
				}

				var model = GetTagModel (policyParent, project, language, identifier, fileName);
				string text = CreateContent (project, model.OverrideTags, language);

				text = ProcessContent (text, model);
				var memoryStream = new MemoryStream ();
				byte[] preamble = Encoding.UTF8.GetPreamble ();
				memoryStream.Write (preamble, 0, preamble.Length);
				if (AddStandardHeader) {
					string header = StandardHeaderService.GetHeader (policyParent, fileName, true);
					byte[] bytes = Encoding.UTF8.GetBytes (header);
					memoryStream.Write (bytes, 0, bytes.Length);
				}

				var textDocument = new TextDocument ();
				textDocument.Text = text;
				var textStylePolicy = (policyParent == null) ? PolicyService.GetDefaultPolicy<TextStylePolicy> ("text/plain") : policyParent.Policies.Get<TextStylePolicy> ("text/plain");
				string eolMarker = TextStylePolicy.GetEolMarker (textStylePolicy.EolMarker);
				byte[] eol = Encoding.UTF8.GetBytes (eolMarker);
				string indent = (!textStylePolicy.TabsToSpaces) ? null : new string (' ', textStylePolicy.TabWidth);
				foreach (DocumentLine current in textDocument.Lines) {
					string line = textDocument.GetTextAt (current.Offset, current.Length);
					if (indent != null) {
						line = line.Replace ("	", indent);
					}
					byte[] bytes = Encoding.UTF8.GetBytes (line);
					memoryStream.Write (bytes, 0, bytes.Length);
					memoryStream.Write (eol, 0, eol.Length);
				}
				memoryStream.Position = 0;
				return memoryStream;				
			}
开发者ID:mhusen,项目名称:Eto,代码行数:38,代码来源:EnhancedFile.cs


示例20: FindNextSubwordEndOffset

        public static int FindNextSubwordEndOffset(TextDocument doc, int offset)
        {
            int myoffset = offset + 1;

            if (!OffsetIsWithinBounds (doc, myoffset)) {
                return myoffset;
            }

            char c = doc.GetCharAt (myoffset);
            // skip whitespace
            while (char.IsWhiteSpace (c)) {
                if (OffsetIsWithinBounds (doc, ++myoffset)) {
                    c = doc.GetCharAt (myoffset);
                } else {
                    return offset;
                }
            }
            var initialClass = ViWordFindStrategy.GetCharacterClass (c);
            while (ViWordFindStrategy.GetCharacterClass (c) == initialClass && 0 <= myoffset && doc.TextLength-1 > myoffset) {
                c = doc.GetCharAt (++myoffset);
            }

            return System.Math.Max (offset, myoffset - 1);
        }
开发者ID:csammis,项目名称:VimAddin,代码行数:24,代码来源:ViWordFindStrategy.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TextEditor.TextEditorData类代码示例发布时间:2022-05-26
下一篇:
C# TextEditor.ReplaceEventArgs类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap