示例#1
0
        static ChunkStyle GetChunkStyle(ColorSheme style, IEnumerable <Tag> tagStack)
        {
            ChunkStyle result = new ChunkStyle();

            if (style == null)
            {
                style = new DefaultStyle(null);
            }
            result.CairoColor = style.Default.CairoColor;

            foreach (Tag tag in tagStack)
            {
                //System.Console.WriteLine("'" + tag.Command + "'");
                switch (tag.Command)
                {
                case "B":
                    result.ChunkProperties |= ChunkProperties.Bold;
                    break;

                case "SPAN":
                    string val;
                    if (tag.Arguments.TryGetValue("style", out val))
                    {
                        ChunkStyle chunkStyle = style.GetChunkStyle(val);
                        if (chunkStyle != null)
                        {
                            result.CairoColor       = chunkStyle.CairoColor;
                            result.ChunkProperties |= chunkStyle.ChunkProperties;
                        }
                        else
                        {
                            throw new Exception("Style " + val + " not found.");
                        }
                    }
                    if (tag.Arguments.TryGetValue("foreground", out val))
                    {
                        result.CairoColor = style.GetColorFromString(val);
                    }
                    if (tag.Arguments.TryGetValue("background", out val))
                    {
                        result.CairoBackgroundColor = style.GetColorFromString(val);
                    }
                    break;

                case "A":
                    result.Link = tag.Arguments["ref"];
                    break;

                case "I":
                    result.ChunkProperties |= ChunkProperties.Italic;
                    break;

                case "U":
                    result.ChunkProperties |= ChunkProperties.Underline;
                    break;
                }
            }
            return(result);
        }
		Mono.TextEditor.Highlighting.Style LoadStyle (string styleName, bool showException = true)
		{
			try {
				return Mono.TextEditor.Highlighting.SyntaxModeService.GetColorStyle (Style, styleName);
			} catch (Exception e) {
				if (showException)
					MessageService.ShowError ("Error while importing color style.", e.InnerException.Message);
				var result = new Mono.TextEditor.Highlighting.DefaultStyle (Style);
				result.Name = styleName;
				result.Description = "Error";
				return result;
			}
		
		}
 Mono.TextEditor.Highlighting.Style LoadStyle(string styleName, bool showException = true)
 {
     try {
         return(Mono.TextEditor.Highlighting.SyntaxModeService.GetColorStyle(Style, styleName));
     } catch (Exception e) {
         if (showException)
         {
             MessageService.ShowError("Error while importing color style.", e.InnerException.Message);
         }
         var result = new Mono.TextEditor.Highlighting.DefaultStyle(Style);
         result.Name        = styleName;
         result.Description = "Error";
         return(result);
     }
 }
		static Cairo.Color[,,,,] CreateColorMatrix (TextEditor editor, bool isError)
		{
			string typeString = isError ? "error" : "warning";
			Cairo.Color[,,,,] colorMatrix = new Cairo.Color[2, 2, 3, 2, 2];
			
			ColorSheme style = editor.ColorStyle;
			if (style == null)
				style = new DefaultStyle (editor.Style);
			
			var baseColor = style.GetChunkStyle ("bubble." + typeString + "").CairoBackgroundColor;
			
			AdjustColorMatrix (colorMatrix, 0, baseColor);
			
			var hsl = (HslColor)baseColor;
			hsl.S *= 0.6;
			baseColor = hsl;
			AdjustColorMatrix (colorMatrix, 1, hsl);
			
			double factor = 1.03;
			for (int i = 0; i < 2; i++) {
				for (int j = 0; j < 2; j++) {
					for (int k = 0; k < 3; k++) {
						HslColor color = colorMatrix [i, j, k, 0, 0];
						color.L *= factor;
						colorMatrix [i, j, k, 1, 0] = color;
					}
				}
			}
			var selectionColor = ColorSheme.ToCairoColor (style.Selection.BackgroundColor);
			for (int i = 0; i < 2; i++) {
				for (int j = 0; j < 2; j++) {
					for (int k = 0; k < 3; k++) {
						for (int l = 0; l < 2; l++) {
							var color = colorMatrix [i, j, k, l, 0];
							colorMatrix [i, j, k, l, 1] = new Cairo.Color ((color.R + selectionColor.R * 1.5) / 2.5, (color.G + selectionColor.G * 1.5) / 2.5, (color.B + selectionColor.B * 1.5) / 2.5);
						}
					}
				}
			}
			return colorMatrix;
		}
		void SetColors ()
		{
			ColorSheme style = editor.ColorStyle;
			if (style == null)
				style = new DefaultStyle (editor.Style);
			errorGc = (HslColor)(style.GetChunkStyle ("bubble.error").Color);
			warningGc = (HslColor)(style.GetChunkStyle ("bubble.warning").Color);
			errorMatrix = CreateColorMatrix (editor, true);
			warningMatrix = CreateColorMatrix (editor, false);
			
			gcSelected = (HslColor)style.Selection.Color;
			gcLight = new Cairo.Color (1, 1, 1);
		}
示例#6
0
		static ChunkStyle GetChunkStyle (Style style, IEnumerable<Tag> tagStack)
		{
			ChunkStyle result = new ChunkStyle ();
			if (style == null)
				style = new DefaultStyle (null);
			result.Color = style.Default.Color;
			
			foreach (Tag tag in tagStack) {
				//System.Console.WriteLine("'" + tag.Command + "'");
				switch (tag.Command) {
				case "B":
					result.ChunkProperties |= ChunkProperties.Bold;
					break;
				case "SPAN":
					string val;
					if (tag.Arguments.TryGetValue ("style", out val)) {
						ChunkStyle chunkStyle = style.GetChunkStyle (val);
						if (chunkStyle != null) {
							result.Color = chunkStyle.Color;
							result.ChunkProperties |= chunkStyle.ChunkProperties;
						} else {
							throw new Exception ("Style " + val + " not found.");
						}
					}
					if (tag.Arguments.TryGetValue ("foreground", out val))
						result.Color = style.GetColorFromString (val);
					if (tag.Arguments.TryGetValue ("background", out val))
						result.BackgroundColor = style.GetColorFromString (val);
					break;
				case "A":
					result.Link = tag.Arguments["ref"];
					break;
				case "I":
					result.ChunkProperties |= ChunkProperties.Italic;
					break;
				case "U":
					result.ChunkProperties |= ChunkProperties.Underline;
					break;
				}
			}
			return result;
		}