Beispiel #1
0
        public void SetSheme(ColorScheme style)
        {
            if (style == null)
            {
                throw new ArgumentNullException("style");
            }
            this.fileName                     = Mono.TextEditor.Highlighting.SyntaxModeService.GetFileNameForStyle(style);
            this.colorSheme                   = style;
            this.entryName.Text               = style.Name;
            this.entryDescription.Text        = style.Description;
            this.textEditor.Document.MimeType = "text/x-csharp";
            this.textEditor.GetTextEditorData().ColorStyle = style;
            this.textEditor.Text = @"using System;

// This is an example
class Example
{
	public static void Main (string[] args)
	{
		Console.WriteLine (""Hello World"");
	}
}";
            foreach (var data in metaData)
            {
                colorStore.AppendValues(data.Description, style.GetChunkStyle(data.Name), data);
            }
            Stylechanged(null, null);
        }
Beispiel #2
0
        public override string DCodeToMarkup(string code)
        {
            //TODO: Semantic highlighting
            var sb         = new StringBuilder();
            var textDoc    = markupDummyTextDoc;
            var syntaxMode = markupDummySyntaxMode;

            textDoc.Text = code;
            if (syntaxMode.Document == null)
            {
                syntaxMode.Document = textDoc;
            }

            var plainText = st.PlainText;

            var lineCount = textDoc.LineCount;

            for (int i = 1; i <= lineCount; i++)
            {
                var line = textDoc.GetLine(i);

                foreach (var chunk in syntaxMode.GetChunks(st, line, line.Offset, line.Length))
                {
                    var s = st.GetChunkStyle(chunk);

                    // Avoid unnecessary non-highlighting
                    if (s == plainText)
                    {
                        sb.Append(textDoc.GetTextAt(chunk.Offset, chunk.Length));
                        continue;
                    }

                    var col = st.GetForeground(s);
                    // TODO: Have other format flags applied?
                    AppendFormat(textDoc.GetTextAt(chunk.Offset, chunk.Length), sb, FormatFlags.Color, col.R, col.G, col.B);
                }

                if (i < lineCount)
                {
                    sb.AppendLine();
                }
            }

            return(sb.ToString());
        }