Example #1
0
        public static string ConvertEditCategorieToDatabse(Gtk.TextBuffer buffer)
        {
            StringBuilder dbBuilder = new StringBuilder(buffer.Text);

            // Replace tags of the textBuffer and save them as HTML-Tags
            int buildOffset = 0;

            for (Gtk.TextIter iter = buffer.StartIter; !iter.IsEnd; iter.ForwardChar())
            {
                if (iter.BeginsTag(boldTag))
                {
                    dbBuilder.Insert(iter.Offset + buildOffset, "<b>", 1);
                    buildOffset += 3;
                }
                else
                if (iter.BeginsTag(italicTag))
                {
                    dbBuilder.Insert(iter.Offset + buildOffset, "<i>", 1);
                    buildOffset += 3;
                }
                if (iter.EndsTag(boldTag))
                {
                    dbBuilder.Insert(iter.Offset + buildOffset, "</b>", 1);
                    buildOffset += 4;
                }
                if (iter.EndsTag(italicTag))
                {
                    dbBuilder.Insert(iter.Offset + buildOffset, "</i>", 1);
                    buildOffset += 4;
                }
            }
            dbBuilder.Replace("\n", "<br>");
            return(dbBuilder.ToString());
        }
Example #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);
        }
Example #3
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);
        }