4
// Mike Krüger <mkrueger@novell.com>
6
// Copyright (c) 2008 Novell, Inc (http://www.novell.com)
8
// Permission is hereby granted, free of charge, to any person obtaining a copy
9
// of this software and associated documentation files (the "Software"), to deal
10
// in the Software without restriction, including without limitation the rights
11
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
// copies of the Software, and to permit persons to whom the Software is
13
// furnished to do so, subject to the following conditions:
15
// The above copyright notice and this permission notice shall be included in
16
// all copies or substantial portions of the Software.
18
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
namespace MonoDevelop.Projects.Dom.Output
32
public class OutputSettings
34
public OutputFlags OutputFlags {
39
public OutputSettings (OutputFlags outputFlags)
41
this.OutputFlags = outputFlags;
44
public string Markup (string text)
46
if (MarkupCallback != null)
47
return MarkupCallback (text);
48
return IncludeMarkup ? PangoFormat (text) : text;
51
public string EmitName (IDomVisitable domVisitable, string text)
53
if (EmitNameCallback != null) {
54
EmitNameCallback (domVisitable, ref text);
60
public string EmitModifiers (string text)
62
if (!IncludeModifiers)
64
if (EmitModifiersCallback != null)
65
return EmitModifiersCallback (text + " ");
67
return "<b>" + PangoFormat (text) + "</b> ";
71
public string EmitKeyword (string text)
73
if (EmitKeywordCallback != null)
74
return EmitKeywordCallback (text);
78
return "<b>" + PangoFormat (text) + "</b> ";
82
public string Highlight (string text)
84
if (HighlightCallback != null)
85
return HighlightCallback (text);
87
return "<b>" + PangoFormat (text) + "</b> ";
91
public void PostProcess (IDomVisitable domVisitable, ref string outString)
93
if (PostProcessCallback != null)
94
PostProcessCallback (domVisitable, ref outString);
97
static string PangoFormat (string input)
99
StringBuilder result = new StringBuilder ();
100
foreach (char ch in input) {
103
result.Append ("<");
106
result.Append (">");
109
result.Append ("&");
116
return result.ToString ();
119
public bool IncludeMarkup {
121
return (OutputFlags & OutputFlags.IncludeMarkup) == OutputFlags.IncludeMarkup;
125
public bool IncludeKeywords {
127
return (OutputFlags & OutputFlags.IncludeKeywords) == OutputFlags.IncludeKeywords;
131
public bool IncludeModifiers {
133
return (OutputFlags & OutputFlags.IncludeModifiers) == OutputFlags.IncludeModifiers;
137
public bool UseFullName {
139
return (OutputFlags & OutputFlags.UseFullName) == OutputFlags.UseFullName;
143
public bool IncludeParameters {
145
return (OutputFlags & OutputFlags.IncludeParameters) == OutputFlags.IncludeParameters;
149
public bool IncludeReturnType {
151
return (OutputFlags & OutputFlags.IncludeReturnType) == OutputFlags.IncludeReturnType;
155
public bool IncludeParameterName {
157
return (OutputFlags & OutputFlags.IncludeParameterName) == OutputFlags.IncludeParameterName;
161
public bool IncludeBaseTypes {
163
return (OutputFlags & OutputFlags.IncludeBaseTypes) == OutputFlags.IncludeBaseTypes;
167
public bool IncludeGenerics {
169
return (OutputFlags & OutputFlags.IncludeGenerics) == OutputFlags.IncludeGenerics;
173
public bool HighlightName {
175
return (OutputFlags & OutputFlags.HighlightName) == OutputFlags.HighlightName;
179
public bool HideExtensionsParameter {
181
return (OutputFlags & OutputFlags.HideExtensionsParameter) == OutputFlags.HideExtensionsParameter;
185
public MarkupText EmitModifiersCallback;
186
public MarkupText EmitKeywordCallback;
187
public MarkupText MarkupCallback;
188
public MarkupText HighlightCallback;
189
public ProcessString EmitNameCallback;
191
public delegate string MarkupText (string text);
193
public ProcessString PostProcessCallback;
194
public delegate void ProcessString (IDomVisitable domVisitable, ref string outString);