Beispiel #1
0
        // FIXME: Mutability bugs.  multiple Links on the same line
        // aren't getting renamed.
        public bool MoveNext()
        {
            Gtk.TextIter iter = buffer.GetIterAtMark(mark);

            if (iter.Equal(buffer.EndIter))
            {
                range.Destroy();
                buffer.DeleteMark(mark);
                return(false);
            }

            if (!iter.ForwardToTagToggle(tag))
            {
                range.Destroy();
                buffer.DeleteMark(mark);
                return(false);
            }

            if (!iter.BeginsTag(tag))
            {
                buffer.MoveMark(mark, iter);
                return(MoveNext());
            }

            range.Start = iter;

            if (!iter.ForwardToTagToggle(tag))
            {
                range.Destroy();
                buffer.DeleteMark(mark);
                return(false);
            }

            if (!iter.EndsTag(tag))
            {
                buffer.MoveMark(mark, iter);
                return(MoveNext());
            }

            range.End = iter;

            buffer.MoveMark(mark, iter);

            return(true);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        public void Split(Gtk.TextIter iter,
                          Gtk.TextBuffer buffer)
        {
            foreach (Gtk.TextTag tag in iter.Tags)
            {
                NoteTag noteTag = tag as NoteTag;
                if (noteTag != null && !noteTag.CanSplit)
                {
                    Gtk.TextIter start = iter;
                    Gtk.TextIter end   = iter;

                    // We only care about enclosing tags
                    if (start.TogglesTag(tag) || end.TogglesTag(tag))
                    {
                        continue;
                    }

                    start.BackwardToTagToggle(tag);
                    end.ForwardToTagToggle(tag);
                    AddSplitTag(start, end, tag);
                    buffer.RemoveTag(tag, start, end);
                }
            }
        }
        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);
        }