public static void GetBlockExtents (ref Gtk.TextIter start, ref Gtk.TextIter end, int threshold, Gtk.TextTag avoid_tag) { // Move start and end to the beginning or end of their // respective paragraphs, bounded by some threshold. start.LineOffset = Math.Max (0, start.LineOffset - threshold); // FIXME: Sometimes I need to access this before it // returns real values. int bug = end.CharsInLine; if (end.CharsInLine - end.LineOffset > threshold + 1 /* newline */) end.LineOffset += threshold; else end.ForwardToLineEnd (); if (avoid_tag != null) { if (start.HasTag (avoid_tag)) start.BackwardToTagToggle (avoid_tag); if (end.HasTag (avoid_tag)) end.ForwardToTagToggle (avoid_tag); } }
public void GetExtents (Gtk.TextIter iter, out Gtk.TextIter start, out Gtk.TextIter end) { start = iter; if (!start.BeginsTag (this)) start.BackwardToTagToggle (this); end = iter; end.ForwardToTagToggle (this); }
private IEnumerable<Pango.Attribute> GetParagraphAttributes ( Pango.Layout layout, double dpiX, out int indentation, ref Gtk.TextIter position, Gtk.TextIter limit) { IList<Pango.Attribute> attributes = new List<Pango.Attribute> (); indentation = 0; Gtk.TextTag [] tags = position.Tags; position.ForwardToTagToggle (null); if (position.Compare (limit) > 0) position = limit; double screen_dpiX = Note.Window.Screen.WidthMm * 254d / Note.Window.Screen.Width; foreach (Gtk.TextTag tag in tags) { if (tag.BackgroundSet) { Gdk.Color color = tag.BackgroundGdk; attributes.Add (new Pango.AttrBackground ( color.Red, color.Green, color.Blue)); } if (tag.ForegroundSet) { Gdk.Color color = tag.ForegroundGdk; attributes.Add (new Pango.AttrForeground ( color.Red, color.Green, color.Blue)); } if (tag.IndentSet) { layout.Indent = tag.Indent; } if (tag.LeftMarginSet) { indentation = (int) (tag.LeftMargin / screen_dpiX * dpiX); } if (tag.RightMarginSet) { indentation = (int) (tag.RightMargin / screen_dpiX * dpiX); } if (tag.FontDesc != null) { attributes.Add (new Pango.AttrFontDesc (tag.FontDesc)); } if (tag.FamilySet) { attributes.Add (new Pango.AttrFamily (tag.Family)); } if (tag.SizeSet) { attributes.Add (new Pango.AttrSize (tag.Size)); } if (tag.StyleSet) { attributes.Add (new Pango.AttrStyle (tag.Style)); } if (tag.UnderlineSet && tag.Underline != Pango.Underline.Error) { attributes.Add (new Pango.AttrUnderline (tag.Underline)); } if (tag.WeightSet) { attributes.Add (new Pango.AttrWeight (tag.Weight)); } if (tag.StrikethroughSet) { attributes.Add (new Pango.AttrStrikethrough (tag.Strikethrough)); } if (tag.RiseSet) { attributes.Add (new Pango.AttrRise (tag.Rise)); } if (tag.ScaleSet) { attributes.Add (new Pango.AttrScale (tag.Scale)); } if (tag.StretchSet) { attributes.Add (new Pango.AttrStretch (tag.Stretch)); } } return attributes; }