本文整理汇总了C#中Mono.TextEditor.Highlighting.SyntaxMode类的典型用法代码示例。如果您正苦于以下问题:C# SyntaxMode类的具体用法?C# SyntaxMode怎么用?C# SyntaxMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SyntaxMode类属于Mono.TextEditor.Highlighting命名空间,在下文中一共展示了SyntaxMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DietTemplateSyntaxMode
public DietTemplateSyntaxMode ()
{
var matches = new List<Match>();
if (baseMode == null)
{
var provider = new ResourceStreamProvider(
typeof(DietTemplateSyntaxMode).Assembly,
typeof(DietTemplateSyntaxMode).Assembly.GetManifestResourceNames().First(s => s.Contains("DietTemplateSyntaxDefinition")));
using (var s = provider.Open())
baseMode = SyntaxMode.Read(s);
}
this.rules = new List<Rule>(baseMode.Rules);
this.keywords = new List<Keywords>(baseMode.Keywords);
this.spans = new List<Span>(baseMode.Spans.Where(span => span.Begin.Pattern != "#")).ToArray();
matches.AddRange(baseMode.Matches);
this.prevMarker = baseMode.PrevMarker;
this.SemanticRules = new List<SemanticRule>(baseMode.SemanticRules);
SemanticRules.Add(InlineDHighlighting.Instance);
this.keywordTable = baseMode.keywordTable;
this.keywordTableIgnoreCase = baseMode.keywordTableIgnoreCase;
this.properties = baseMode.Properties;
// D Number literals
matches.Add(DSyntaxMode.workaroundMatchCtor(
"Number"
, @" (?<!\w)(0((x|X)[0-9a-fA-F_]+|(b|B)[0-1_]+)|([0-9]+[_0-9]*)[L|U|u|f|i]*)"));
this.matches = matches.ToArray();
}
示例2: GetProvider
public static IStreamProvider GetProvider (SyntaxMode mode)
{
foreach (string mimeType in mode.MimeType.Split (';')) {
if (syntaxModeLookup.ContainsKey (mimeType))
return syntaxModeLookup[mimeType];
}
return null;
}
示例3: DSyntaxMode
public DSyntaxMode()
{
var matches = new List<Mono.TextEditor.Highlighting.Match>();
if (baseMode == null)
{
#if STABLE
var provider = new ResourceXmlProvider(typeof(DSyntaxMode).Assembly,
typeof(DSyntaxMode).Assembly.GetManifestResourceNames().First(s => s.Contains("MonoDevelop.D.DSyntaxHighlightingMode")));
using (XmlReader reader = provider.Open())
baseMode = SyntaxMode.Read(reader);
#else
var provider = new ResourceStreamProvider(
typeof(DSyntaxMode).Assembly,
typeof(DSyntaxMode).Assembly.GetManifestResourceNames().First(s => s.Contains("DSyntaxHighlightingMode")));
using (Stream s = provider.Open())
baseMode = SyntaxMode.Read(s);
#endif
}
this.rules = new List<Rule>(baseMode.Rules);
this.keywords = new List<Keywords>(baseMode.Keywords);
this.spans = new List<Span>(baseMode.Spans.Where(span => span.Begin.Pattern != "#")).ToArray();
matches.AddRange(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;
// D Number literals
matches.Add(workaroundMatchCtor(
#if STABLE
"constant.digit"
#else
"Number"
#endif
, @"(?<!\w)(0((x|X)[0-9a-fA-F_]+|(b|B)[0-1_]+)|([0-9]+[_0-9]*)[L|U|u|f|i]*)"));
// extern linkages attributes
//matches.Add(workaroundMatchCtor("constant.digit", "(?<=extern[\\s]*\\()[\\s]*(C(\\+\\+)?|D|Windows|System|Pascal|Java)[\\s]*(?=\\))"));
// version checks
//matches.Add(workaroundMatchCtor("constant.digit", @"(?<=version[\s]*\()[\s]*(DigitalMars|GNU|LDC|Windows|OSX|linux|FreeBSD|OpenBSD|BSD|Solaris|Posix|D_Version2)[\s]*(?=\))"));
// type declaration names
//matches.Add(workaroundMatchCtor("keyword.semantic.type", @"(?<=(class|struct|union|interface|template)[\s]+)[\w]+"));
this.matches = matches.ToArray();
}
示例4: GetDelimiter
public string GetDelimiter (SyntaxMode mode)
{
if (mode == null)
return delimiter;
return !delimiterSet ? mode.GetDelimiter (null) : delimiter;
}
示例5: CSharpSpanParser
// Span preprocessorSpan;
// Rule preprocessorRule;
public CSharpSpanParser (Mono.TextEditor.Document doc, SyntaxMode mode, CloneableStack<Span> spanStack) : base (doc, mode, spanStack)
{
// foreach (Span span in mode.Spans) {
// if (span.Rule == "text.preprocessor") {
// preprocessorSpan = span;
// preprocessorRule = GetRule (span);
// }
// }
}
示例6: UpdateWorker
public UpdateWorker (TextDocument doc, SyntaxMode mode, int startOffset, int endOffset)
{
this.doc = doc;
this.mode = mode;
this.startOffset = startOffset;
this.endOffset = endOffset;
IsFinished = false;
ManualResetEvent = new ManualResetEvent (false);
}
示例7: StartUpdate
public static void StartUpdate (TextDocument doc, SyntaxMode mode, int startOffset, int endOffset)
{
lock (updateQueue) {
updateQueue.Enqueue (new UpdateWorker (doc, mode, startOffset, endOffset));
}
queueSignal.Set ();
}
示例8: ChunkParser
public ChunkParser (SpanParser spanParser, Document doc, ColorSheme style, SyntaxMode mode, LineSegment line)
{
this.mode = mode;
this.doc = doc;
this.line = line;
this.lineOffset = line.Offset;
this.spanParser = spanParser;
spanParser.FoundSpanBegin = FoundSpanBegin;
spanParser.FoundSpanEnd = FoundSpanEnd;
spanParser.FoundSpanExit = FoundSpanExit;
spanParser.ParseChar += ParseChar;
if (line == null)
throw new ArgumentNullException ("line");
}
示例9: Remove
public static void Remove (SyntaxMode mode)
{
foreach (string mimeType in mode.MimeType.Split (';')) {
if (syntaxModes.ContainsKey (mimeType))
syntaxModes.Remove (mimeType);
if (syntaxModeLookup.ContainsKey (mimeType))
syntaxModeLookup.Remove (mimeType);
}
}
示例10: ProtoTypeSyntaxModeProvider
public ProtoTypeSyntaxModeProvider (SyntaxMode prototype)
{
this.prototype = prototype;
}
示例11: CreateChunkParser
public virtual ChunkParser CreateChunkParser (SpanParser spanParser, Document doc, ColorSheme style, SyntaxMode mode, LineSegment line)
{
return new ChunkParser (spanParser, doc, style, mode, line);
}
示例12: CSharpChunkParser
public CSharpChunkParser (SpanParser spanParser, Mono.TextEditor.Document doc, Style style, SyntaxMode mode, LineSegment line) : base (spanParser, doc, style, mode, line)
{
foreach (var tag in ProjectDomService.SpecialCommentTags) {
tags.Add (tag.Tag);
}
}
示例13: ChunkParser
public ChunkParser (SyntaxMode mode, SpanParser spanParser, ColorScheme style, DocumentLine line)
{
this.mode = mode;
this.doc = mode.Document;
this.line = line;
this.lineOffset = line.Offset;
this.spanParser = spanParser;
spanParser.FoundSpanBegin = FoundSpanBegin;
spanParser.FoundSpanEnd = FoundSpanEnd;
spanParser.FoundSpanExit = FoundSpanExit;
spanParser.ParseChar += ParseChar;
spanParser.IsAtWordStart = () => wordbuilder.Length == 0;
if (line == null)
throw new ArgumentNullException ("line");
}
示例14: GetCachedChunks
Chunk GetCachedChunks (SyntaxMode mode, Document doc, Mono.TextEditor.Highlighting.Style style, LineSegment line, int offset, int length)
{
// return mode.GetChunks (doc, style, line, offset, length);
ChunkDescriptor descriptor;
if (chunkDict.TryGetValue (line, out descriptor)) {
bool isInvalid;
if (descriptor.Equals (line, offset, length, out isInvalid))
return descriptor.Chunk;
chunkDict.Remove (line);
}
Chunk chunk = mode.GetChunks (doc, style, line, offset, length);
descriptor = new ChunkDescriptor (line, offset, length, chunk);
chunkDict.Add (line, descriptor);
return chunk;
}
示例15: CreateLinePartLayout
public LayoutWrapper CreateLinePartLayout (SyntaxMode mode, LineSegment line, int offset, int length, int selectionStart, int selectionEnd)
{
return GetCachedLayout (line, offset, length, selectionStart, selectionEnd, delegate (LayoutWrapper wrapper) {
var atts = new FastPangoAttrList ();
wrapper.Layout.Alignment = Pango.Alignment.Left;
wrapper.Layout.FontDescription = textEditor.Options.Font;
wrapper.Layout.Tabs = tabArray;
StringBuilder textBuilder = new StringBuilder ();
Chunk startChunk = GetCachedChunks (mode, Document, textEditor.ColorStyle, line, offset, length);
for (Chunk chunk = startChunk; chunk != null; chunk = chunk != null ? chunk.Next : null) {
try {
textBuilder.Append (chunk.GetText (Document));
} catch {
Console.WriteLine (chunk);
}
}
string lineText = textBuilder.ToString ();
bool containsPreedit = offset <= textEditor.preeditOffset && textEditor.preeditOffset <= offset + length;
uint preeditLength = 0;
if (containsPreedit) {
lineText = lineText.Insert (textEditor.preeditOffset - offset, textEditor.preeditString);
preeditLength = (uint)textEditor.preeditString.Length;
}
char[] lineChars = lineText.ToCharArray ();
int startOffset = offset, endOffset = offset + length;
uint curIndex = 0, byteIndex = 0;
uint curChunkIndex = 0, byteChunkIndex = 0;
uint oldEndIndex = 0;
for (Chunk chunk = startChunk; chunk != null; chunk = chunk != null ? chunk.Next : null) {
ChunkStyle chunkStyle = chunk != null ? chunk.GetChunkStyle (textEditor.ColorStyle) : null;
foreach (TextMarker marker in line.Markers)
chunkStyle = marker.GetStyle (chunkStyle);
if (chunkStyle != null) {
startOffset = chunk.Offset;
endOffset = chunk.EndOffset;
uint startIndex = (uint)(oldEndIndex);
uint endIndex = (uint)(startIndex + chunk.Length);
oldEndIndex = endIndex;
if (containsPreedit) {
if (textEditor.preeditOffset < startOffset)
startIndex += preeditLength;
if (textEditor.preeditOffset < endOffset)
endIndex += preeditLength;
}
HandleSelection (line, selectionStart, selectionEnd, chunk.Offset, chunk.EndOffset, delegate(int start, int end) {
var si = TranslateToUTF8Index (lineChars, (uint)(startIndex + start - chunk.Offset), ref curIndex, ref byteIndex);
var ei = TranslateToUTF8Index (lineChars, (uint)(startIndex + end - chunk.Offset), ref curIndex, ref byteIndex);
atts.AddForegroundAttribute (chunkStyle.Color, si, ei);
if (!chunkStyle.TransparentBackround && GetPixel (ColorStyle.Default.BackgroundColor) != GetPixel (chunkStyle.BackgroundColor)) {
atts.AddBackgroundAttribute (chunkStyle.BackgroundColor, si, ei);
}
}, delegate(int start, int end) {
var si = TranslateToUTF8Index (lineChars, (uint)(startIndex + start - chunk.Offset), ref curIndex, ref byteIndex);
var ei = TranslateToUTF8Index (lineChars, (uint)(startIndex + end - chunk.Offset), ref curIndex, ref byteIndex);
atts.AddForegroundAttribute (SelectionColor.Color, si, ei);
if (!wrapper.StartSet)
wrapper.SelectionStartIndex = (int)si;
wrapper.SelectionEndIndex = (int)ei;
});
var translatedStartIndex = TranslateToUTF8Index (lineChars, (uint)startIndex, ref curChunkIndex, ref byteChunkIndex);
var translatedEndIndex = TranslateToUTF8Index (lineChars, (uint)endIndex, ref curChunkIndex, ref byteChunkIndex);
if (chunkStyle.Bold)
atts.AddWeightAttribute (Pango.Weight.Bold, translatedStartIndex, translatedEndIndex);
if (chunkStyle.Italic)
atts.AddStyleAttribute (Pango.Style.Italic, translatedStartIndex, translatedEndIndex);
if (chunkStyle.Underline)
atts.AddUnderlineAttribute (Pango.Underline.Single, translatedStartIndex, translatedEndIndex);
}
}
if (containsPreedit) {
var si = TranslateToUTF8Index (lineChars, (uint)(textEditor.preeditOffset - offset), ref curIndex, ref byteIndex);
var ei = TranslateToUTF8Index (lineChars, (uint)(si + preeditLength), ref curIndex, ref byteIndex);
atts.AddUnderlineAttribute (Pango.Underline.Single, si, ei);
}
wrapper.LineChars = lineChars;
wrapper.Layout.SetText (lineText);
atts.AssignTo (wrapper.Layout);
atts.Dispose ();
int w, h;
wrapper.Layout.GetSize (out w, out h);
wrapper.PangoWidth = w;
});
}