本文整理汇总了C#中ITextEditorOptions类的典型用法代码示例。如果您正苦于以下问题:C# ITextEditorOptions类的具体用法?C# ITextEditorOptions怎么用?C# ITextEditorOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITextEditorOptions类属于命名空间,在下文中一共展示了ITextEditorOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 (" ");
break;
case '\t':
for (int i2 = 0; i2 < options.TabSize; i2++)
htmlText.Append (" ");
break;
case '<':
htmlText.Append ("<");
break;
case '>':
htmlText.Append (">");
break;
case '&':
htmlText.Append ("&");
break;
case '"':
htmlText.Append (""");
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 ("&");
break;
case '<':
result.Append ("<");
break;
case '>':
result.Append (">");
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: CodeEditorFormattingOptionsAdapter
public CodeEditorFormattingOptionsAdapter(ITextEditorOptions globalOptions, CSharpFormattingOptionsContainer container)
{
if (globalOptions == null)
throw new ArgumentNullException("globalOptions");
if (container == null)
throw new ArgumentNullException("container");
this.globalOptions = globalOptions;
this.globalCodeEditorOptions = globalOptions as ICodeEditorOptions;
this.container = container;
CSharpFormattingPolicies.Instance.FormattingPolicyUpdated += OnFormattingPolicyUpdated;
globalOptions.PropertyChanged += OnGlobalOptionsPropertyChanged;
}
开发者ID:dgrunwald,项目名称:SharpDevelop,代码行数:14,代码来源:CSharpLanguageBinding.cs
示例14: Create
public static TextEditorData Create(string content, ITextEditorOptions options = null)
{
var data = new TextEditorData ();
data.Options.DefaultEolMarker = eolMarker;
data.Options.IndentStyle = IndentStyle.Smart;
if (options != null)
data.Options = options;
var sb = new StringBuilder ();
int caretIndex = -1, selectionStart = -1, selectionEnd = -1;
var foldSegments = new List<FoldSegment> ();
var foldStack = new Stack<FoldSegment> ();
for (int i = 0; i < content.Length; i++) {
var ch = content [i];
switch (ch) {
case '$':
caretIndex = sb.Length;
break;
case '<':
if (i + 1 < content.Length) {
if (content [i + 1] == '-') {
selectionStart = sb.Length;
i++;
break;
}
}
goto default;
case '-':
if (i + 1 < content.Length) {
var next = content [i + 1];
if (next == '>') {
selectionEnd = sb.Length;
i++;
break;
}
if (next == '[') {
var segment = new FoldSegment (data.Document, "...", sb.Length, 0, FoldingType.None);
segment.IsFolded = false;
foldStack.Push (segment);
i++;
break;
}
}
goto default;
case '+':
if (i + 1 < content.Length) {
var next = content [i + 1];
if (next == '[') {
var segment = new FoldSegment (data.Document, "...", sb.Length, 0, FoldingType.None);
segment.IsFolded = true;
foldStack.Push (segment);
i++;
break;
}
}
goto default;
case ']':
if (foldStack.Count > 0) {
FoldSegment segment = foldStack.Pop ();
segment.Length = sb.Length - segment.Offset;
foldSegments.Add (segment);
break;
}
goto default;
default:
sb.Append (ch);
break;
}
}
data.Text = sb.ToString ();
if (caretIndex >= 0)
data.Caret.Offset = caretIndex;
if (selectionStart >= 0) {
if (caretIndex == selectionStart) {
data.SetSelection (selectionEnd, selectionStart);
} else {
data.SetSelection (selectionStart, selectionEnd);
if (caretIndex < 0)
data.Caret.Offset = selectionEnd;
}
}
if (foldSegments.Count > 0)
data.Document.UpdateFoldSegments (foldSegments);
return data;
}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:87,代码来源:CSharpTextEditorIndentationTests.cs
示例15: GenerateRtf
static string GenerateRtf (TextDocument doc, Mono.TextEditor.Highlighting.ISyntaxMode mode, Mono.TextEditor.Highlighting.ColorScheme style, ITextEditorOptions options)
{
StringBuilder rtfText = new StringBuilder ();
List<Gdk.Color> colorList = new List<Gdk.Color> ();
var selection = new TextSegment (0, doc.TextLength);
int startLineNumber = doc.OffsetToLineNumber (selection.Offset);
int endLineNumber = doc.OffsetToLineNumber (selection.EndOffset);
bool isItalic = false;
bool isBold = false;
int curColor = -1;
foreach (var line in doc.GetLinesBetween (startLineNumber, endLineNumber)) {
bool appendSpace = false;
foreach (Chunk 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);
ChunkStyle chunkStyle = style.GetChunkStyle (chunk);
if (start < end) {
if (isBold != chunkStyle.Bold) {
rtfText.Append (chunkStyle.Bold ? @"\b" : @"\b0");
isBold = chunkStyle.Bold;
appendSpace = true;
}
if (isItalic != chunkStyle.Italic) {
rtfText.Append (chunkStyle.Italic ? @"\i" : @"\i0");
isItalic = chunkStyle.Italic;
appendSpace = true;
}
if (!colorList.Contains (chunkStyle.Color))
colorList.Add (chunkStyle.Color);
int color = colorList.IndexOf (chunkStyle.Color);
if (curColor != color) {
curColor = color;
rtfText.Append (@"\cf" + (curColor + 1));
appendSpace = true;
}
for (int i = start; i < end; i++) {
char ch = doc.GetCharAt (i);
switch (ch) {
case '\\':
rtfText.Append (@"\\");
break;
case '{':
rtfText.Append (@"\{");
break;
case '}':
rtfText.Append (@"\}");
break;
case '\t':
rtfText.Append (@"\tab");
appendSpace = true;
break;
default:
if (appendSpace) {
rtfText.Append (' ');
appendSpace = false;
}
rtfText.Append (ch);
break;
}
}
}
}
rtfText.Append (@"\par");
rtfText.AppendLine ();
}
// color table
StringBuilder colorTable = new StringBuilder ();
colorTable.Append (@"{\colortbl ;");
for (int i = 0; i < colorList.Count; i++) {
Gdk.Color color = colorList[i];
colorTable.Append (@"\red");
colorTable.Append (color.Red / 256);
colorTable.Append (@"\green");
colorTable.Append (color.Green / 256);
colorTable.Append (@"\blue");
colorTable.Append (color.Blue / 256);
colorTable.Append (";");
}
colorTable.Append ("}");
StringBuilder rtf = new StringBuilder();
rtf.Append (@"{\rtf1\ansi\deff0\adeflang1025");
// font table
rtf.Append (@"{\fonttbl");
rtf.Append (@"{\f0\fnil\fprq1\fcharset128 " + options.Font.Family + ";}");
rtf.Append ("}");
rtf.Append (colorTable.ToString ());
rtf.Append (@"\viewkind4\uc1\pard");
//.........这里部分代码省略.........
开发者ID:gary-b,项目名称:monodevelop,代码行数:101,代码来源:ClipboardActions.cs
示例16: GenerateRtf
public static string GenerateRtf (TextDocument doc, Mono.TextEditor.Highlighting.ISyntaxMode mode, Mono.TextEditor.Highlighting.ColorScheme style, ITextEditorOptions options)
{
var rtfText = new StringBuilder ();
var colorList = new List<Cairo.Color> ();
var selection = new TextSegment (0, doc.TextLength);
int startLineNumber = doc.OffsetToLineNumber (selection.Offset);
int endLineNumber = doc.OffsetToLineNumber (selection.EndOffset);
bool isItalic = false;
bool isBold = false;
int curColor = -1;
foreach (var line in doc.GetLinesBetween (startLineNumber, endLineNumber)) {
bool appendSpace = false;
if (mode == null) {
AppendRtfText (rtfText, doc, System.Math.Max (selection.Offset, line.Offset), System.Math.Min (line.EndOffset, selection.EndOffset), ref appendSpace);
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) {
if (isBold != (chunkStyle.FontWeight == Xwt.Drawing.FontWeight.Bold)) {
isBold = chunkStyle.FontWeight == Xwt.Drawing.FontWeight.Bold;
rtfText.Append (isBold ? @"\b" : @"\b0");
appendSpace = true;
}
if (isItalic != (chunkStyle.FontStyle == Xwt.Drawing.FontStyle.Italic)) {
isItalic = chunkStyle.FontStyle == Xwt.Drawing.FontStyle.Italic;
rtfText.Append (isItalic ? @"\i" : @"\i0");
appendSpace = true;
}
var foreground = style.GetForeground (chunkStyle);
if (!colorList.Contains (foreground))
colorList.Add (foreground);
int color = colorList.IndexOf (foreground);
if (curColor != color) {
curColor = color;
rtfText.Append (@"\cf" + (curColor + 1));
appendSpace = true;
}
AppendRtfText (rtfText, doc, start, end, ref appendSpace);
}
}
rtfText.Append (@"\par");
rtfText.AppendLine ();
}
var rtf = new StringBuilder();
rtf.Append (@"{\rtf1\ansi\deff0\adeflang1025");
// font table
rtf.Append (@"{\fonttbl");
rtf.Append (@"{\f0\fnil\fprq1\fcharset128 " + options.Font.Family + ";}");
rtf.Append ("}");
rtf.Append (CreateColorTable (colorList));
rtf.Append (@"\viewkind4\uc1\pard");
rtf.Append (@"\f0");
try {
string fontName = options.Font.ToString ();
double fontSize = Double.Parse (fontName.Substring (fontName.LastIndexOf (' ') + 1), System.Globalization.CultureInfo.InvariantCulture) * 2;
rtf.Append (@"\fs");
rtf.Append (fontSize);
} catch (Exception) {};
rtf.Append (@"\cf1");
rtf.Append (rtfText.ToString ());
rtf.Append("}");
return rtf.ToString ();
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:76,代码来源:RtfWriter.cs
示例17: 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
示例18: 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
示例19: 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
示例20: Init
public static void Init ()
{
if (inited)
return;
inited = true;
var policy = MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy<TextStylePolicy> ("text/plain");
instance = new DefaultSourceEditorOptions (policy);
MonoDevelop.Projects.Policies.PolicyService.DefaultPolicies.PolicyChanged += instance.HandlePolicyChanged;
PlainEditor = new PlainEditorOptions ();
}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:12,代码来源:DefaultSourceEditorOptions.cs
注:本文中的ITextEditorOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论