Example #1
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;
                }
            }
        }
Example #2
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;
            }
        }