示例#1
0
        void OnInsertText(object sender, Gtk.InsertTextArgs args)
        {
            Gtk.TextIter start = args.Pos;
            start.BackwardChars(args.Length);

            ApplyUrlToBlock(start, args.Pos);
        }
示例#2
0
        void OnInsertText(object sender, Gtk.InsertTextArgs args)
        {
            Gtk.TextIter start = args.Pos;
            start.BackwardChars(args.Length);

            Gtk.TextIter end = args.Pos;

            NoteBuffer.GetBlockExtents(ref start,
                                       ref end,
                                       Manager.TitleTrie.MaxLength,
                                       Note.TagTable.LinkTag);

            UnhighlightInBlock(start, end);
            HighlightInBlock(start, end);
        }
        void OnInsertText(object sender, Gtk.InsertTextArgs args)
        {
            Gtk.TextIter start;
            Gtk.TextIter end = args.Pos;
            end.BackwardChars(2);
            Gtk.TextIter iter = end;
            string       id;

            switch (end.Char)
            {
            case bold_id:
                id = bold_id;
                break;

            case italic_id:
                id = italic_id;
                break;

            case underlined_id:
                id = underlined_id;
                break;

            case highlight_id:
                id = highlight_id;
                break;

            case strikethrough_id:
                id = strikethrough_id;
                break;

            default:
                return;
            }

            /* TODO: Catch double "id" characters. ** should not be
             * detected
             */
            while (iter.LineOffset != 0)
            {
                iter.BackwardChar();
                if (iter.Char == id)
                {
                    start = iter;
                    iter.ForwardChar();
                    string text = Buffer.GetText(iter, end, false);
                    end.ForwardChar();
                    Gtk.TextTag tags;
                    switch (id)
                    {
                    case bold_id:
                        tags = (Gtk.TextTag)bold_tag;
                        break;

                    case italic_id:
                        tags = italic_tag;
                        break;

                    case underlined_id:
                        tags = underline_tag;
                        break;

                    case highlight_id:
                        tags = highlight_tag;
                        break;

                    case strikethrough_id:
                        tags = strikethrough_tag;
                        break;

                    default:
                        return;
                    }

                    Buffer.Delete(ref start, ref end);
                    Buffer.InsertWithTags(ref start, text, tags);
                    break;
                }
            }
        }