GetChunkStyle() public method

public GetChunkStyle ( Chunk chunk ) : ChunkStyle
chunk Chunk
return ChunkStyle
Ejemplo n.º 1
0
        public static ColorScheme LoadFrom(XmlReader reader)
        {
            var result = new ColorScheme();

            XmlReadHelper.ReadList(reader, "EditorStyle", delegate()
            {
                switch (reader.LocalName)
                {
                case "EditorStyle":
                    result.Name        = reader.GetAttribute(NameAttribute);
                    result.Description = reader.GetAttribute("_description");
                    return(true);

                case "Color":
                    result.customPalette [reader.GetAttribute("name")] = reader.GetAttribute("value");
                    return(true);

                case "Style":
                    ReadStyleTree(reader, result, null, null, null, null);
                    return(true);
                }
                return(false);
            });
            result.GetChunkStyle(DefaultString).ChunkProperties |= ChunkProperties.TransparentBackground;
            return(result);
        }
Ejemplo n.º 2
0
		public virtual bool GetIsValid (ColorScheme style)
		{
			if (style.GetChunkStyle (Color) == null) {
				System.Console.WriteLine("color:" + Color + " not found.");
				return false;
			}
			return true;
		}
Ejemplo n.º 3
0
 public virtual bool GetIsValid(ColorScheme style)
 {
     if (style.GetChunkStyle(Color) == null)
     {
         System.Console.WriteLine("color:" + Color + " not found.");
         return(false);
     }
     return(true);
 }
Ejemplo n.º 4
0
        internal static string GenerateHtml(List <List <ColoredSegment> > chunks, 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>");

            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>");
            htmlText.AppendLine("</BODY></HTML>");

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

            return(htmlText.ToString());
        }
Ejemplo n.º 5
0
 public virtual bool GetIsValid(ColorScheme style)
 {
     return((string.IsNullOrEmpty(Color) || style.GetChunkStyle(Color) != null) &&
            (string.IsNullOrEmpty(TagColor) || style.GetChunkStyle(TagColor) != null) &&
            (string.IsNullOrEmpty(NextColor) || style.GetChunkStyle(NextColor) != null));
 }
Ejemplo n.º 6
0
 public virtual bool GetIsValid(ColorScheme style)
 {
     return(style.GetChunkStyle(Color) != null);
 }
Ejemplo n.º 7
0
		public virtual bool GetIsValid (ColorScheme style)
		{
			return (string.IsNullOrEmpty (Color) || style.GetChunkStyle (Color) != null) &&
			        (string.IsNullOrEmpty (TagColor) || style.GetChunkStyle (TagColor) != null) &&
			        (string.IsNullOrEmpty (NextColor) || style.GetChunkStyle (NextColor) != null);
		}
Ejemplo n.º 8
0
		public virtual bool GetIsValid (ColorScheme style)
		{
			return style.GetChunkStyle (Color) != null;
		}
Ejemplo n.º 9
0
        internal static string GenerateRtf(List <List <ColoredSegment> > chunks, Mono.TextEditor.Highlighting.ColorScheme style, ITextEditorOptions options)
        {
            var rtfText   = new StringBuilder();
            var colorList = new List <Color>();

            bool isItalic = false;
            bool isBold   = false;
            int  curColor = -1;

            foreach (var line in chunks)
            {
                bool appendSpace = false;
                foreach (var chunk in line)
                {
                    var chunkStyle = style.GetChunkStyle(chunk.Style);
                    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, chunk.Text, ref appendSpace);
                }
                rtfText.AppendLine(@"\line");
            }

            var rtf = new StringBuilder();

            rtf.AppendLine(@"{\rtf1\ansi\deff0\adeflang1025");
            rtf.AppendLine(@"{\fonttbl");
            rtf.AppendLine(@"{\f0\fnil\fprq1\fcharset128 " + options.Font.Family + ";}");
            rtf.AppendLine("}");
            rtf.Append(CreateColorTable(colorList));
            rtf.AppendLine(@"\viewkind4\uc1\pard");
            rtf.AppendLine(@"\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 e) { System.Diagnostics.Debug.WriteLine(e); }
            rtf.AppendLine(@"\cf1");
            rtf.Append(rtfText.ToString());
            rtf.Append("}");
            return(rtf.ToString());
        }
Ejemplo n.º 10
0
		public static ColorScheme LoadFrom (XmlReader reader)
		{
			var result = new ColorScheme ();
			XmlReadHelper.ReadList (reader, "EditorStyle", delegate () {
				switch (reader.LocalName) {
				case "EditorStyle":
					result.Name = reader.GetAttribute (NameAttribute);
					result.Description = reader.GetAttribute ("_description");
					return true;
				case "Color":
					result.customPalette [reader.GetAttribute ("name")] = reader.GetAttribute ("value");
					return true;
				case "Style":
					ReadStyleTree (reader, result, null, null, null, null);
					return true;
				}
				return false;
			});
			result.GetChunkStyle (DefaultString).ChunkProperties |= ChunkProperties.TransparentBackground;
			return result;
		}