Exemple #1
0
        void TagApplied(object sender, Gtk.TagAppliedArgs args)
        {
            bool remove = false;

            if (args.Tag.Name == "gtkspell-misspelled")
            {
                // Remove misspelled tag for links & title
                foreach (Gtk.TextTag tag in args.StartChar.Tags)
                {
                    if (tag != args.Tag &&
                        !NoteTagTable.TagIsSpellCheckable(tag))
                    {
                        remove = true;
                        break;
                    }
                }
            }
            else if (!NoteTagTable.TagIsSpellCheckable(args.Tag))
            {
                remove = true;
            }

            if (remove)
            {
                Buffer.RemoveTag("gtkspell-misspelled",
                                 args.StartChar,
                                 args.EndChar);
            }
        }
Exemple #2
0
 void OnTagApplied(object sender, Gtk.TagAppliedArgs args)
 {
     if (frozen_cnt == 0)
     {
         if (NoteTagTable.TagIsUndoable(args.Tag))
         {
             AddUndoAction(new TagApplyAction(args.Tag,
                                              args.StartChar,
                                              args.EndChar));
         }
     }
 }
Exemple #3
0
        void OnTagRemoved(object sender, Gtk.TagRemovedArgs args)
        {
            if (frozen_cnt == 0)
            {
                if (NoteTagTable.TagIsUndoable(args.Tag))
                {
                    // FIXME: Gtk# bug. StartChar and EndChar are not
                    //        mapped, so grab them from the Args iter.
                    Gtk.TextIter start, end;
                    start = (Gtk.TextIter)args.Args[1];
                    end   = (Gtk.TextIter)args.Args[2];

                    AddUndoAction(new TagRemoveAction(args.Tag, start, end));
                }
            }
        }
Exemple #4
0
        void TagApplied(object sender, Gtk.TagAppliedArgs args)
        {
            bool remove = false;

            if (args.Tag.Name == "gtkspell-misspelled")
            {
                // Remove misspelled tag for links & title
                foreach (Gtk.TextTag tag in args.StartChar.Tags)
                {
                    if (tag != args.Tag &&
                        !NoteTagTable.TagIsSpellCheckable(tag))
                    {
                        remove = true;
                        break;
                    }
                }
                // Remove misspelled tag for acronyms (in all caps)
                if (!args.StartChar.EndsWord() && System.Char.IsUpper(args.StartChar.Char, 0))
                {
                    Gtk.TextIter char_iter = args.StartChar;
                    remove = true;
                    while (!char_iter.EndsWord())
                    {
                        if (Char.IsLower(char_iter.Char, 0))
                        {
                            remove = false;
                            break;
                        }
                        else
                        {
                            char_iter.ForwardChar();
                        }
                    }
                }
            }
            else if (!NoteTagTable.TagIsSpellCheckable(args.Tag))
            {
                remove = true;
            }

            if (remove)
            {
                Buffer.RemoveTag("gtkspell-misspelled",
                                 args.StartChar,
                                 args.EndChar);
            }
        }
Exemple #5
0
        void OnEditorMotion(object sender, Gtk.MotionNotifyEventArgs args)
        {
            bool hovering = false;

            // Figure out if we're on a link by getting the text
            // iter at the mouse point, and checking for tags that
            // start with "link:"...

            int buffer_x, buffer_y;

            Window.Editor.WindowToBufferCoords(Gtk.TextWindowType.Widget,
                                               (int)args.Event.X,
                                               (int)args.Event.Y,
                                               out buffer_x,
                                               out buffer_y);

            Gtk.TextIter iter = Window.Editor.GetIterAtLocation(buffer_x, buffer_y);

            foreach (Gtk.TextTag tag in iter.Tags)
            {
                if (NoteTagTable.TagIsActivatable(tag))
                {
                    hovering = true;
                    break;
                }
            }

            // Don't show hand if Shift or Control is pressed
            bool avoid_hand = (args.Event.State & (Gdk.ModifierType.ShiftMask |
                                                   Gdk.ModifierType.ControlMask)) != 0;

            if (hovering != hovering_on_link)
            {
                hovering_on_link = hovering;

                Gdk.Window win = Window.Editor.GetWindow(Gtk.TextWindowType.Text);
                if (hovering && !avoid_hand)
                {
                    win.Cursor = hand_cursor;
                }
                else
                {
                    win.Cursor = normal_cursor;
                }
            }
        }
Exemple #6
0
        void OnEditorKeyPress(object sender, Gtk.KeyPressEventArgs args)
        {
            switch (args.Event.Key)
            {
            case Gdk.Key.Shift_L:
            case Gdk.Key.Shift_R:
            case Gdk.Key.Control_L:
            case Gdk.Key.Control_R:
                // Control or Shift when hovering over a link
                // swiches to a bar cursor...

                if (!hovering_on_link)
                {
                    break;
                }

                Gdk.Window win = Window.Editor.GetWindow(Gtk.TextWindowType.Text);
                win.Cursor = normal_cursor;
                break;

            case Gdk.Key.Return:
            case Gdk.Key.KP_Enter:
                Gtk.TextIter iter = Buffer.GetIterAtMark(Buffer.InsertMark);

                foreach (Gtk.TextTag tag in iter.Tags)
                {
                    if (NoteTagTable.TagIsActivatable(tag))
                    {
                        args.RetVal = tag.ProcessEvent(Window.Editor,
                                                       args.Event,
                                                       iter);
                        if ((bool)args.RetVal)
                        {
                            break;
                        }
                    }
                }
                break;
            }
        }