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


C# ITextEditorOptions类代码示例

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


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

示例1: AppendHtmlText

		static void AppendHtmlText (StringBuilder htmlText, TextDocument doc, ITextEditorOptions options, int start, int end)
		{
			for (int i = start; i < end; i++) {
				char ch = doc.GetCharAt (i);
				switch (ch) {
				case ' ':
					htmlText.Append ("&nbsp;");
					break;
				case '\t':
					for (int i2 = 0; i2 < options.TabSize; i2++)
						htmlText.Append ("&nbsp;");
					break;
				case '<':
					htmlText.Append ("&lt;");
					break;
				case '>':
					htmlText.Append ("&gt;");
					break;
				case '&':
					htmlText.Append ("&amp;");
					break;
				case '"':
					htmlText.Append ("&quot;");
					break;
				default:
					htmlText.Append (ch);
					break;
				}
			}
		}
开发者ID:kekekeks,项目名称:monodevelop,代码行数:30,代码来源:HtmlWriter.cs

示例2: GenerateHtml

		public static string GenerateHtml (TextDocument doc, Mono.TextEditor.Highlighting.ISyntaxMode mode, Mono.TextEditor.Highlighting.ColorScheme style, ITextEditorOptions options)
		{

			var htmlText = new StringBuilder ();
			htmlText.AppendLine (@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">");
			htmlText.AppendLine ("<HTML>");
			htmlText.AppendLine ("<HEAD>");
			htmlText.AppendLine ("<META HTTP-EQUIV=\"CONTENT-TYPE\" CONTENT=\"text/html; charset=utf-8\">");
			htmlText.AppendLine ("<META NAME=\"GENERATOR\" CONTENT=\"Mono Text Editor\">");
			htmlText.AppendLine ("</HEAD>");
			htmlText.AppendLine ("<BODY>"); 

			var selection = new TextSegment (0, doc.TextLength);
			int startLineNumber = doc.OffsetToLineNumber (selection.Offset);
			int endLineNumber = doc.OffsetToLineNumber (selection.EndOffset);
			htmlText.AppendLine ("<FONT face = '" + options.Font.Family + "'>");
			bool first = true;
			if (mode is SyntaxMode) {
				SyntaxModeService.StartUpdate (doc, (SyntaxMode)mode, selection.Offset, selection.EndOffset);
				SyntaxModeService.WaitUpdate (doc);
			}

			foreach (var line in doc.GetLinesBetween (startLineNumber, endLineNumber)) {
				if (!first) {
					htmlText.AppendLine ("<BR>");
				} else {
					first = false;
				}

				if (mode == null) {
					AppendHtmlText (htmlText, doc, options, System.Math.Max (selection.Offset, line.Offset), System.Math.Min (line.EndOffset, selection.EndOffset));
					continue;
				}
				int curSpaces = 0;

				foreach (var chunk in mode.GetChunks (style, line, line.Offset, line.Length)) {
					int start = System.Math.Max (selection.Offset, chunk.Offset);
					int end = System.Math.Min (chunk.EndOffset, selection.EndOffset);
					var chunkStyle = style.GetChunkStyle (chunk);
					if (start < end) {
						htmlText.Append ("<SPAN style='");
						if (chunkStyle.FontWeight != Xwt.Drawing.FontWeight.Normal)
							htmlText.Append ("font-weight:" + ((int)chunkStyle.FontWeight) + ";");
						if (chunkStyle.FontStyle != Xwt.Drawing.FontStyle.Normal)
							htmlText.Append ("font-style:" + chunkStyle.FontStyle.ToString ().ToLower () + ";");
						htmlText.Append ("color:" + ((HslColor)chunkStyle.Foreground).ToPangoString () + ";");
						htmlText.Append ("'>");
						AppendHtmlText (htmlText, doc, options, start, end);
						htmlText.Append ("</SPAN>");
					}
				}
			}
			htmlText.AppendLine ("</FONT>");
            htmlText.AppendLine ("</BODY></HTML>");

			if (Platform.IsWindows)
                return GenerateCFHtml (htmlText.ToString ());

			return htmlText.ToString ();
		}
开发者ID:handless,项目名称:monodevelop,代码行数:60,代码来源:HtmlWriter.cs

示例3: WriteNode

		public static IReadOnlyDictionary<AstNode, ISegment> WriteNode(StringWriter writer, AstNode node, CSharpFormattingOptions policy, ITextEditorOptions editorOptions)
		{
			var formatter = new SegmentTrackingOutputFormatter(writer);
			formatter.IndentationString = editorOptions.IndentationString;
			var visitor = new CSharpOutputVisitor(formatter, policy);
			node.AcceptVisitor(visitor);
			return formatter.Segments;
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:8,代码来源:SegmentTrackingOutputFormatter.cs

示例4: CorrectIndent

		public static void CorrectIndent(TextReader code, int startOffset, int endOffset, Action<int, int, string> documentReplace, DFormattingOptions options = null, ITextEditorOptions textStyle = null, bool formatLastLine = true)
		{
			textStyle = textStyle ?? TextEditorOptions.Default;
			
			var eng = new IndentEngine(options ?? DFormattingOptions.CreateDStandard(), textStyle.TabsToSpaces, textStyle.IndentSize, textStyle.KeepAlignmentSpaces);
			var replaceActions = new List<DFormattingVisitor.TextReplaceAction>();
			
			int originalIndent = 0;
			bool hadLineBreak = true;
			
			int n = 0;
			for (int i = 0; i <= endOffset && (n = code.Read()) != -1; i++)
			{
				if(n == '\r' || n == '\n')
				{
					if (i >= startOffset && !eng.LineBeganInsideString)
						replaceActions.Add(new DFormattingVisitor.TextReplaceAction(eng.Position - eng.LineOffset, originalIndent, eng.ThisLineIndent));
					
					hadLineBreak = true;
					originalIndent = 0;

					if (code.Peek() == '\n')
					{
						eng.Push((char)code.Read());
						i++;
					}
				}
				else if(hadLineBreak)
				{
					if(n == ' ' || n== '\t')
						originalIndent++;
					else
						hadLineBreak = false;

					// If there's code left, format the last line of the selection either
					if (i == endOffset && formatLastLine)
						endOffset++;
				}

				eng.Push((char)n);
			}

			// Also indent the last line if we're at the EOF.
			if (code.Peek() == -1 || (formatLastLine && n != '\r' && n != '\n'))
			{
				if(!eng.LineBeganInsideString)
					replaceActions.Add(new DFormattingVisitor.TextReplaceAction(eng.Position - eng.LineOffset, originalIndent, eng.ThisLineIndent));
			}
			
			// Perform replacements from the back of the document to the front - to ensure offset consistency
			for(int k = replaceActions.Count - 1; k>=0; k--)
			{
				var rep = replaceActions[k];
				if(rep.RemovalLength > 0 || rep.NewText.Length != 0)
					documentReplace(rep.Offset, rep.RemovalLength, rep.NewText);
			}
		}
开发者ID:DinrusGroup,项目名称:DinrusIDE,代码行数:57,代码来源:IndentEngineWrapper.cs

示例5: CreateSecondaryViewContent

		public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent, ITextEditorOptions textEditorOptions)
		{
			foreach (IViewContent existingView in viewContent.SecondaryViewContents) {
				if (existingView.GetType() == typeof(FormsDesignerViewContent)) {
					return new IViewContent[0];
				}
			}
			
			IDesignerLoaderProvider loader = new RubyDesignerLoaderProvider();
			IDesignerGenerator generator = new RubyDesignerGenerator(textEditorOptions);
			return new IViewContent[] { new FormsDesignerViewContent(viewContent, loader, generator) };
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:12,代码来源:RubyFormsDesignerDisplayBinding.cs

示例6: GenerateHtml

		public static string GenerateHtml (List<List<ColoredSegment>> chunks, Mono.TextEditor.Highlighting.ColorScheme style, ITextEditorOptions options, bool includeBoilerplate = true)
		{
			var htmlText = new StringBuilder ();
			if (includeBoilerplate) {
				htmlText.AppendLine (@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">");
				htmlText.AppendLine ("<HTML>");
				htmlText.AppendLine ("<HEAD>");
				htmlText.AppendLine ("<META HTTP-EQUIV=\"CONTENT-TYPE\" CONTENT=\"text/html; charset=utf-8\">");
				htmlText.AppendLine ("<META NAME=\"GENERATOR\" CONTENT=\"Mono Text Editor\">");
				htmlText.AppendLine ("</HEAD>");
				htmlText.AppendLine ("<BODY>"); 
			}

			htmlText.AppendLine ("<FONT face = '" + options.Font.Family + "'>");
			bool first = true;

			foreach (var line in chunks) {
				if (!first) {
					htmlText.AppendLine ("<BR>");
				} else {
					first = false;
				}

				foreach (var chunk in line) {
					var chunkStyle = style.GetChunkStyle (chunk.Style);
					htmlText.Append ("<SPAN style='");
					if (chunkStyle.FontWeight != Xwt.Drawing.FontWeight.Normal)
						htmlText.Append ("font-weight:" + ((int)chunkStyle.FontWeight) + ";");
					if (chunkStyle.FontStyle != Xwt.Drawing.FontStyle.Normal)
						htmlText.Append ("font-style:" + chunkStyle.FontStyle.ToString ().ToLower () + ";");
					htmlText.Append ("color:" + ((HslColor)chunkStyle.Foreground).ToPangoString () + ";");
					htmlText.Append ("'>");
					AppendHtmlText (htmlText, chunk.Text, options);
					htmlText.Append ("</SPAN>");
				}
			}
			htmlText.AppendLine ("</FONT>");

			if (includeBoilerplate) {
				htmlText.AppendLine ("</BODY></HTML>");
			}

			if (Platform.IsWindows)
                return GenerateCFHtml (htmlText.ToString ());

			return htmlText.ToString ();
		}
开发者ID:sushihangover,项目名称:monodevelop,代码行数:47,代码来源:HtmlWriter.cs

示例7: GenerateHtml

		public static string GenerateHtml (TextDocument doc, Mono.TextEditor.Highlighting.ISyntaxMode mode, Mono.TextEditor.Highlighting.ColorScheme style, ITextEditorOptions options)
		{
			var htmlText = new StringBuilder ();

			htmlText.Append (@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN""><HTML><BODY>");

			var selection = new TextSegment (0, doc.TextLength);
			int startLineNumber = doc.OffsetToLineNumber (selection.Offset);
			int endLineNumber = doc.OffsetToLineNumber (selection.EndOffset);
			htmlText.Append ("<FONT face = '" + options.Font.Family + "'>");
			bool first = true;
			foreach (var line in doc.GetLinesBetween (startLineNumber, endLineNumber)) {
				if (!first) {
					htmlText.Append ("<BR/>");
				} else {
					first = false;
				}

				if (mode == null) {
					AppendHtmlText (htmlText, doc, options, System.Math.Max (selection.Offset, line.Offset), System.Math.Min (line.EndOffset, selection.EndOffset));
					continue;
				}

				foreach (var chunk in mode.GetChunks (style, line, line.Offset, line.Length)) {
					int start = System.Math.Max (selection.Offset, chunk.Offset);
					int end = System.Math.Min (chunk.EndOffset, selection.EndOffset);
					var chunkStyle = style.GetChunkStyle (chunk);
					if (start < end) {
						htmlText.Append ("<SPAN style = '");
						if (chunkStyle.Bold)
							htmlText.Append ("font-weight:bold;");
						if (chunkStyle.Italic)
							htmlText.Append ("font-style:italic;");
						htmlText.Append ("color:" + ((HslColor)chunkStyle.Foreground).ToPangoString () + ";");
						htmlText.Append ("' >");
						AppendHtmlText (htmlText, doc, options, start, end);
						htmlText.Append ("</SPAN>");
					}
				}
			}
			htmlText.Append ("</FONT>");
			htmlText.Append ("</BODY></HTML>");
			return htmlText.ToString ();
		}
开发者ID:kekekeks,项目名称:monodevelop,代码行数:44,代码来源:HtmlWriter.cs

示例8: FormatCode

        public static string FormatCode(string code, DModule ast = null, IDocumentAdapter document = null, DFormattingOptions options = null, ITextEditorOptions textStyle = null)
        {
            options = options ?? DFormattingOptions.CreateDStandard();
            textStyle = textStyle ?? TextEditorOptions.Default;
            ast = ast ?? DParser.ParseString(code) as DModule;

            var formattingVisitor = new DFormattingVisitor(options, document ?? new TextDocument{ Text = code }, ast, textStyle);

            formattingVisitor.WalkThroughAst();

            var sb = new StringBuilder(code);

            formattingVisitor.ApplyChanges((int start, int length, string insertedText) => {
                                           	sb.Remove(start,length);
                                           	sb.Insert(start,insertedText);
                                           });

            return sb.ToString();
        }
开发者ID:DinrusGroup,项目名称:DRC,代码行数:19,代码来源:Formatter.cs

示例9: TextEditorFontSizeProperty

 public TextEditorFontSizeProperty(ITextEditorOptions textEditorOptions)
     : base("FontSize")
 {
     this.textEditorOptions = textEditorOptions;
 }
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:5,代码来源:TextEditorFontSizeProperty.cs

示例10: CustomEditorOptions

		public CustomEditorOptions (ITextEditorOptions initializeFrom)
		{
			if (initializeFrom == null)
				throw new ArgumentNullException (nameof (initializeFrom));
			WordFindStrategy = initializeFrom.WordFindStrategy;
			TabsToSpaces = initializeFrom.TabsToSpaces;
			IndentationSize = initializeFrom.IndentationSize;
			TabSize = initializeFrom.TabSize;
			ShowIconMargin = initializeFrom.ShowIconMargin;
			ShowLineNumberMargin = initializeFrom.ShowLineNumberMargin;
			ShowFoldMargin = initializeFrom.ShowFoldMargin;
			HighlightCaretLine = initializeFrom.HighlightCaretLine;
			RulerColumn = initializeFrom.RulerColumn;
			ShowRuler = initializeFrom.ShowRuler;
			IndentStyle = initializeFrom.IndentStyle;
			OverrideDocumentEolMarker = initializeFrom.OverrideDocumentEolMarker;
			EnableSyntaxHighlighting = initializeFrom.EnableSyntaxHighlighting;
			RemoveTrailingWhitespaces = initializeFrom.RemoveTrailingWhitespaces;
			WrapLines = initializeFrom.WrapLines;
			FontName = initializeFrom.FontName;
			GutterFontName = initializeFrom.GutterFontName;
			ColorScheme = initializeFrom.ColorScheme;
			DefaultEolMarker = initializeFrom.DefaultEolMarker;
			GenerateFormattingUndoStep = initializeFrom.GenerateFormattingUndoStep;
			EnableSelectionWrappingKeys = initializeFrom.EnableSelectionWrappingKeys;
			ShowWhitespaces = initializeFrom.ShowWhitespaces;
			IncludeWhitespaces = initializeFrom.IncludeWhitespaces;
			SmartBackspace = initializeFrom.SmartBackspace;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:29,代码来源:CustomEditorOptions.cs

示例11: GetMarkup

		public string GetMarkup (Document doc, ITextEditorOptions options, ColorSheme style, int offset, int length, bool removeIndent, bool useColors, bool replaceTabs)
		{
			int indentLength = GetIndentLength (doc, offset, length, false);
			int curOffset = offset;

			StringBuilder result = new StringBuilder ();
			while (curOffset < offset + length && curOffset < doc.Length) {
				LineSegment line = doc.GetLineByOffset (curOffset);
				int toOffset = System.Math.Min (line.Offset + line.EditableLength, offset + length);
				Stack<ChunkStyle> styleStack = new Stack<ChunkStyle> ();
				for (Chunk chunk = GetChunks (doc, style, line, curOffset, toOffset - curOffset); chunk != null; chunk = chunk.Next) {

					ChunkStyle chunkStyle = chunk.GetChunkStyle (style);
					bool setBold = chunkStyle.Bold && (styleStack.Count == 0 || !styleStack.Peek ().Bold) ||
						!chunkStyle.Bold && (styleStack.Count == 0 || styleStack.Peek ().Bold);
					bool setItalic = chunkStyle.Italic && (styleStack.Count == 0 || !styleStack.Peek ().Italic) ||
						!chunkStyle.Italic && (styleStack.Count == 0 || styleStack.Peek ().Italic);
					bool setUnderline = chunkStyle.Underline && (styleStack.Count == 0 || !styleStack.Peek ().Underline) ||
						!chunkStyle.Underline && (styleStack.Count == 0 || styleStack.Peek ().Underline);
					bool setColor = styleStack.Count == 0 || TextViewMargin.GetPixel (styleStack.Peek ().Color) != TextViewMargin.GetPixel (chunkStyle.Color);
					if (setColor || setBold || setItalic || setUnderline) {
						if (styleStack.Count > 0) {
							result.Append("</span>");
							styleStack.Pop ();
						}
						result.Append("<span");
						if (useColors) {
							result.Append(" foreground=\"");
							result.Append(ColorToPangoMarkup (chunkStyle.Color));
							result.Append("\"");
						}
						if (chunkStyle.Bold)
							result.Append(" weight=\"bold\"");
						if (chunkStyle.Italic)
							result.Append(" style=\"italic\"");
						if (chunkStyle.Underline)
							result.Append(" underline=\"single\"");
						result.Append(">");
						styleStack.Push (chunkStyle);
					}

					for (int i = 0; i < chunk.Length && chunk.Offset + i < doc.Length; i++) {
						char ch = chunk.GetCharAt (doc, chunk.Offset + i);
						switch (ch) {
						case '&':
							result.Append ("&amp;");
							break;
						case '<':
							result.Append ("&lt;");
							break;
						case '>':
							result.Append ("&gt;");
							break;
						case '\t':
							if (replaceTabs) {
								result.Append (new string (' ', options.TabSize));
							} else {
								result.Append ('\t');
							}
							break;
						default:
							result.Append (ch);
							break;
						}
					}
				}
				while (styleStack.Count > 0) {
					result.Append("</span>");
					styleStack.Pop ();
				}

				curOffset = line.EndOffset;
				if (removeIndent)
					curOffset += indentLength;
				if (result.Length > 0 && curOffset < offset + length)
					result.AppendLine ();
			}
			return result.ToString ();
		}
开发者ID:nieve,项目名称:monodevelop,代码行数:79,代码来源:SyntaxMode.cs

示例12: DerivedPythonDesignerGenerator

		public DerivedPythonDesignerGenerator(ITextEditorOptions textEditorOptions) 
			: base(textEditorOptions)
		{
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:4,代码来源:DerivedPythonDesignerGenerator.cs

示例13: Init

		void Init(IViewContent view)
		{
			this.view = view;
			editable = view.GetService<IEditable>();
			textEditor = view.GetService<ITextEditor>();
			textEditorOptions = textEditor.Options;
		}
开发者ID:kristjan84,项目名称:SharpDevelop,代码行数:7,代码来源:ScriptingTextEditorViewContent.cs

示例14: CodeEditorAdapter

		public CodeEditorAdapter(CodeEditor codeEditor, CodeEditorView textEditor) : base(textEditor)
		{
			if (codeEditor == null)
				throw new ArgumentNullException("codeEditor");
			this.codeEditor = codeEditor;
			options = CodeEditorOptions.Instance;
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:7,代码来源:CodeEditorAdapter.cs

示例15: Init

		void Init(IViewContent view)
		{
			this.view = view;
			editable = view as IEditable;
			textEditorProvider = view as ITextEditorProvider;
			textEditor = textEditorProvider.TextEditor;
			textEditorOptions = textEditor.Options;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:8,代码来源:ScriptingTextEditorViewContent.cs


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