Exemplo n.º 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());
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        void OnPopulatePopup(object sender, Gtk.PopulatePopupArgs args)
        {
            Gtk.TextIter click_iter = Buffer.GetIterAtMark(click_mark);
            NoteTag      url_tag    = Note.TagTable.UrlTag;

            if (click_iter.HasTag(url_tag) || click_iter.EndsTag(url_tag))
            {
                Gtk.MenuItem item;

                item = new Gtk.SeparatorMenuItem();
                item.Show();
                args.Menu.Prepend(item);

                item            = new Gtk.MenuItem(Catalog.GetString("_Copy Link Address"));
                item.Activated += CopyLinkActivate;
                item.Show();
                args.Menu.Prepend(item);

                item            = new Gtk.MenuItem(Catalog.GetString("_Open Link"));
                item.Activated += OpenLinkActivate;
                item.Show();
                args.Menu.Prepend(item);
            }
        }