public override ChunkStyle GetStyle (ChunkStyle baseStyle)
		{
			ChunkStyle st = new ChunkStyle (baseStyle);
			st.CairoColor = new Cairo.Color (125, 125, 125);
			return st;
		}
Example #2
0
		public virtual ChunkStyle GetStyle (ChunkStyle baseStyle)
		{
			return baseStyle;
		}
Example #3
0
 public virtual ChunkStyle GetStyle(ChunkStyle baseStyle)
 {
     return(baseStyle);
 }
Example #4
0
		public ChunkStyle (ChunkStyle style)
		{
			CairoColor           = style.CairoColor;
			if (!style.backColorIsZero)
				CairoBackgroundColor = style.CairoBackgroundColor;
			ChunkProperties      = style.ChunkProperties;
		}
Example #5
0
		public override ChunkStyle GetStyle (ChunkStyle baseStyle)
		{
			if (includedStyles == StyleFlag.None)
				return baseStyle;
			
			ChunkStyle style = new ChunkStyle (baseStyle);
			if ((includedStyles & StyleFlag.Color) != 0)
				style.Color = Mono.TextEditor.Highlighting.Style.ToGdkColor (Color);
		
			if ((includedStyles & StyleFlag.BackgroundColor) != 0) {
				style.ChunkProperties &= ~ChunkProperties.TransparentBackground;
				style.BackgroundColor = Mono.TextEditor.Highlighting.Style.ToGdkColor (BackgroundColor);
			}
			
			if ((includedStyles & StyleFlag.Bold) != 0)
				style.ChunkProperties |= ChunkProperties.Bold;
			
			if ((includedStyles & StyleFlag.Italic) != 0)
				style.ChunkProperties |= ChunkProperties.Italic;
			return style;
		}
Example #6
0
        public override bool Equals(object o)
        {
            ChunkStyle c = o as ChunkStyle;

            return(c != null && Bold == c.Bold && Italic == c.Italic && CairoColor.GetHashCode() == c.CairoColor.GetHashCode());
        }
Example #7
0
		public ChunkStyle (ChunkStyle style)
		{
			Color                = style.Color;
			BackgroundColor      = style.BackgroundColor;
			ChunkProperties      = style.ChunkProperties;
		}
		public override ChunkStyle GetStyle (ChunkStyle baseStyle)
		{
			if (includedStyles == StyleFlag.None)
				return baseStyle;
			
			ChunkStyle style = new ChunkStyle (baseStyle);
			if ((includedStyles & StyleFlag.Color) != 0)
				style.Color = Color;
		
			if ((includedStyles & StyleFlag.BackgroundColor) != 0) {
				style.ChunkProperties &= ~ChunkProperties.TransparentBackground;
				style.BackgroundColor = BackgroundColor;
			}
			
			if ((includedStyles & StyleFlag.Bold) != 0)
				style.ChunkProperties |= ChunkProperties.Bold;
			
			if ((includedStyles & StyleFlag.Italic) != 0)
				style.ChunkProperties |= ChunkProperties.Italic;
			return style;
		}
Example #9
0
            static string GenerateRtf(Document doc, Mono.TextEditor.Highlighting.SyntaxMode mode, Mono.TextEditor.Highlighting.Style style, ITextEditorOptions options)
            {
                StringBuilder    rtfText   = new StringBuilder();
                List <Gdk.Color> colorList = new List <Gdk.Color> ();

                ISegment selection       = new Segment(0, doc.Length);
                int      startLineNumber = doc.OffsetToLineNumber(selection.Offset);
                int      endLineNumber   = doc.OffsetToLineNumber(selection.EndOffset);

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

                foreach (var line in doc.GetLinesBetween(startLineNumber, endLineNumber))
                {
                    bool appendSpace = false;
                    for (Chunk chunk = mode.GetChunks(doc, style, line, line.Offset, line.EditableLength); chunk != null; chunk = chunk.Next)
                    {
                        int        start      = System.Math.Max(selection.Offset, chunk.Offset);
                        int        end        = System.Math.Min(chunk.EndOffset, selection.EndOffset);
                        ChunkStyle chunkStyle = chunk.GetChunkStyle(style);
                        if (start < end)
                        {
                            if (isBold != chunkStyle.Bold)
                            {
                                rtfText.Append(chunkStyle.Bold ? @"\b" : @"\b0");
                                isBold      = chunkStyle.Bold;
                                appendSpace = true;
                            }
                            if (isItalic != chunkStyle.Italic)
                            {
                                rtfText.Append(chunkStyle.Italic ? @"\i" : @"\i0");
                                isItalic    = chunkStyle.Italic;
                                appendSpace = true;
                            }
                            if (!colorList.Contains(chunkStyle.Color))
                            {
                                colorList.Add(chunkStyle.Color);
                            }
                            int color = colorList.IndexOf(chunkStyle.Color);
                            if (curColor != color)
                            {
                                curColor = color;
                                rtfText.Append(@"\cf" + (curColor + 1));
                                appendSpace = true;
                            }
                            for (int i = start; i < end; i++)
                            {
                                char ch = chunk.GetCharAt(doc, i);

                                switch (ch)
                                {
                                case '\\':
                                    rtfText.Append(@"\\");
                                    break;

                                case '{':
                                    rtfText.Append(@"\{");
                                    break;

                                case '}':
                                    rtfText.Append(@"\}");
                                    break;

                                case '\t':
                                    rtfText.Append(@"\tab");
                                    appendSpace = true;
                                    break;

                                default:
                                    if (appendSpace)
                                    {
                                        rtfText.Append(' ');
                                        appendSpace = false;
                                    }
                                    rtfText.Append(ch);
                                    break;
                                }
                            }
                        }
                    }
                    rtfText.Append(@"\par");
                    rtfText.AppendLine();
                }

                // color table

                StringBuilder colorTable = new StringBuilder();

                colorTable.Append(@"{\colortbl ;");
                for (int i = 0; i < colorList.Count; i++)
                {
                    Gdk.Color color = colorList[i];
                    colorTable.Append(@"\red");
                    colorTable.Append(color.Red / 256);
                    colorTable.Append(@"\green");
                    colorTable.Append(color.Green / 256);
                    colorTable.Append(@"\blue");
                    colorTable.Append(color.Blue / 256);
                    colorTable.Append(";");
                }
                colorTable.Append("}");

                StringBuilder rtf = new StringBuilder();

                rtf.Append(@"{\rtf1\ansi\deff0\adeflang1025");

                // font table
                rtf.Append(@"{\fonttbl");

                rtf.Append(@"{\f0\fnil\fprq1\fcharset128 " + options.Font.Family + ";}");

                rtf.Append("}");

                rtf.Append(colorTable.ToString());

                rtf.Append(@"\viewkind4\uc1\pard");

                rtf.Append(@"\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) {};
                rtf.Append(@"\cf1");
                rtf.Append(rtfText.ToString());
                rtf.Append("}");
//				System.Console.WriteLine(rtf);
                return(rtf.ToString());
            }
Example #10
0
		public override ChunkStyle GetStyle (ChunkStyle baseStyle)
		{
			if (baseStyle == null || IncludedStyles == StyleFlag.None)
				return baseStyle;
			
			return CreateStyle (baseStyle, Color, BackgroundColor);
		}
Example #11
0
		protected virtual ChunkStyle CreateStyle (ChunkStyle baseStyle, Cairo.Color color, Cairo.Color bgColor)
		{
			ChunkStyle style = new ChunkStyle (baseStyle);
			if ((IncludedStyles & StyleFlag.Color) != 0)
				style.CairoColor = color;
			
			if ((IncludedStyles & StyleFlag.BackgroundColor) != 0) {
				style.ChunkProperties &= ~ChunkProperties.TransparentBackground;
				style.CairoBackgroundColor = bgColor;
			}
			
			if ((IncludedStyles & StyleFlag.Bold) != 0)
				style.ChunkProperties |= ChunkProperties.Bold;
			
			if ((IncludedStyles & StyleFlag.Italic) != 0)
				style.ChunkProperties |= ChunkProperties.Italic;
			return style;
		}
Example #12
0
 public ChunkStyle(ChunkStyle style)
 {
     Color           = style.Color;
     BackgroundColor = style.BackgroundColor;
     ChunkProperties = style.ChunkProperties;
 }