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


C# TextEditorData类代码示例

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


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

示例1: Create

		public static TextEditorData Create (string content)
		{
			int caretIndex = content.IndexOf ("$");
			if (caretIndex >= 0)
				content = content.Substring (0, caretIndex) + content.Substring (caretIndex + 1);

			int selection1 = content.IndexOf ("<-");
			int selection2 = content.IndexOf ("->");
			
			int selectionStart = 0;
			int selectionEnd = 0;
			if (0 <= selection1 && selection1 < selection2) {
				content = content.Substring (0, selection2) + content.Substring (selection2 + 2);
				content = content.Substring (0, selection1) + content.Substring (selection1 + 2);
				selectionStart = selection1;
				selectionEnd = selection2 - 2;
				caretIndex = selectionEnd;
			}

			var data = new TextEditorData ();
			data.Text = content;
			if (caretIndex >= 0)
				data.Caret.Offset = caretIndex;
			if (selection1 >= 0) {
				if (caretIndex == selectionStart) {
					data.SetSelection (selectionEnd, selectionStart);
				} else {
					data.SetSelection (selectionStart, selectionEnd);
				}
			}
			return data;
		}
开发者ID:nocache,项目名称:monodevelop,代码行数:32,代码来源:FoldingTests.cs

示例2: CreateData

		TextEditorData CreateData ()
		{
			var data = new TextEditorData ();
			data.IndentationTracker = IndentTracker;
			data.Options.IndentStyle = IndentStyle.Smart;
			return data;
		}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:7,代码来源:SmartIndentModeTests.cs

示例3: CreateData

		TextEditorData CreateData (string content)
		{
			var data = new TextEditorData (new TextDocument (content));
			data.IndentationTracker = IndentTracker;
			data.Options.IndentStyle = IndentStyle.Smart;
			return data;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:7,代码来源:SmartIndentModeTests.cs

示例4: CreateData

		public static TextEditorData CreateData (string content)
		{
			var data = new TextEditorData (new TextDocument (content));
			data.IndentationTracker = SmartIndentModeTests.IndentTracker;
			data.Options.IndentStyle = IndentStyle.Virtual;
			return data;
		}
开发者ID:llucenic,项目名称:monodevelop,代码行数:7,代码来源:VirtualIndentModeTests.cs

示例5: GetMarkup

		public static string GetMarkup (string input, string syntaxMode)
		{
			var data = new TextEditorData (new TextDocument (input));
			data.Document.SyntaxMode = SyntaxModeService.GetSyntaxMode (data.Document, syntaxMode);
			data.ColorStyle = SyntaxModeService.GetColorStyle ("TangoLight");
			return data.GetMarkup (0, data.Length, false);
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:7,代码来源:SyntaxHighlightingTests.cs

示例6: CreateData

		TextEditorData CreateData ()
		{
			var data = new TextEditorData ();
			data.IndentationTracker = SmartIndentModeTests.IndentTracker;
			data.Options.IndentStyle = IndentStyle.Virtual;
			return data;
		}
开发者ID:dodev,项目名称:monodevelop,代码行数:7,代码来源:VirtualIndentModeTests.cs

示例7: Join

		public static void Join (TextEditorData data)
		{
			int startLine, endLine, startOffset, length;
			
			if (data.IsSomethingSelected) {
				startLine = data.Document.OffsetToLineNumber (data.SelectionRange.Offset);
				endLine = data.Document.OffsetToLineNumber (data.SelectionRange.EndOffset - 1);
			} else {
				startLine = endLine = data.Caret.Line;
			}
			
			//single-line joins
			if (endLine == startLine)
				endLine++;
			
			if (endLine > data.Document.LineCount)
				return;
			
			DocumentLine seg = data.Document.GetLine (startLine);
			startOffset = seg.Offset;
			StringBuilder sb = new StringBuilder (data.Document.GetTextAt (seg).TrimEnd ());
			//lastSpaceOffset = startOffset + sb.Length;
			
			for (int i = startLine + 1; i <= endLine; i++) {
				seg = data.Document.GetLine (i);
				//lastSpaceOffset = startOffset + sb.Length;
				sb.Append (" ");
				sb.Append (data.Document.GetTextAt (seg).Trim ());
			}
			length = (seg.Offset - startOffset) + seg.Length;
			// TODO: handle conversion issues ? 
			data.Replace (startOffset, length, sb.ToString ());
		}
开发者ID:mikeraimondi,项目名称:monodevelop,代码行数:33,代码来源:ViCommands.cs

示例8: TestBug14716

		public void TestBug14716 ()
		{
			var data = new TextEditorData ();
			data.Document.Text = "using System;\nusing System.Linq;\nusing System.Collections.Generic;\n";
			data.SearchEngine = new RegexSearchEngine ();
			data.SearchEngine.SearchRequest.SearchPattern = "u.i.g";
			data.SearchReplaceAll ("bar");
			Assert.AreEqual ("bar System;\nbar System.Linq;\nbar System.Collections.Generic;\n", data.Document.Text );
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:9,代码来源:SearchAndReplaceTests.cs

示例9: CreateInsertionPoint

		string CreateInsertionPoint (string input, string text, NewLineInsertion before, NewLineInsertion after)
		{
			int idx = input.IndexOf ('$');
			Assert.Greater (idx, -1);
			TextEditorData data = new TextEditorData (new TextDocument (input.Substring (0, idx) + input.Substring (idx + 1)));
			InsertionPoint point = new InsertionPoint (data.Document.OffsetToLocation (idx), before, after);
			point.Insert (data, text);
			return data.Document.Text;
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:9,代码来源:InsertionModeTests.cs

示例10: OnRemovedFromEditor

		protected override void OnRemovedFromEditor (TextEditorData data)
		{
			SetCaretMode (CaretMode.Insert, data);

			if (viTextEditor != null) {
				statusArea.RemoveFromParentAndDestroy ();
				statusArea = null;
				viTextEditor = null;
			}
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:10,代码来源:NewViEditMode.cs

示例11: Check

		public static void Check (TextEditorData data, string output, bool reverse)
		{
			int offset1 = output.IndexOf ('[');
			int offset2 = output.IndexOf (']');
			string expected = output.Substring (0, offset1) + output.Substring (offset1 + 1, (offset2 - offset1) - 1) + output.Substring (offset2 + 1);
			offset2--;
			Assert.AreEqual (expected, data.Text);
			Assert.AreEqual (data.OffsetToLocation (reverse ? offset2 : offset1), data.MainSelection.Anchor);
			Assert.AreEqual (data.OffsetToLocation (reverse ? offset1 : offset2), data.MainSelection.Lead);
		}
开发者ID:ischyrus,项目名称:monodevelop,代码行数:10,代码来源:InsertTabTests.cs

示例12: TestSimpleYToLineNumber

		public void TestSimpleYToLineNumber ()
		{
			var editor = new TextEditorData ();
			editor.Text = "1\n2\n3\n4\n5\n6\n7";
			HeightTree heightTree = new HeightTree (editor);
			heightTree.Rebuild ();
			for (int i = 1; i <= editor.LineCount; i++) {
				Assert.AreEqual (i, heightTree.YToLineNumber ((i - 1) * editor.LineHeight));
			}
		}
开发者ID:Poiros,项目名称:monodevelop,代码行数:10,代码来源:HeightTreeTests.cs

示例13: LoadMark

		public void LoadMark (TextEditorData data) {
			int x = base.LineSegment.LineNumber;
			data.Caret.Line = x;
			int len = base.LineSegment.LengthIncludingDelimiter;
			if (ColumnNumber >= len) {
				// Check if the line has been truncated after the setting the mark
				data.Caret.Column = len - 1;
			} else {
				data.Caret.Column = ColumnNumber;
			}
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:11,代码来源:ViMark.cs

示例14: OnAddedToEditor

		protected override void OnAddedToEditor (TextEditorData data)
		{
			ViEditor.SetMode (ViEditorMode.Normal);
			SetCaretMode (CaretMode.Block, data);
			ViActions.RetreatFromLineEnd (data);

			viTextEditor = data.Parent;
			if (viTextEditor != null) {
				statusArea = new ViStatusArea (viTextEditor);
			}
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:11,代码来源:NewViEditMode.cs

示例15: NewLineAbove

		public static void NewLineAbove (TextEditorData data)
		{
			if (data.Caret.Line == DocumentLocation.MinLine ) {
				data.Caret.Offset = 0;
				MiscActions.InsertNewLine (data);
				data.Caret.Offset = 0;
				return;
			}
			
			DocumentLine currentLine = data.Document.GetLine (data.Caret.Line - 1);
			data.Caret.Offset = currentLine.Offset + currentLine.Length;
			MiscActions.InsertNewLine (data);
		}
开发者ID:mikeraimondi,项目名称:monodevelop,代码行数:13,代码来源:ViCommands.cs


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