Home Download Buy Blog Forum Support

Can we please get context support for mousemap files?

Can we please get context support for mousemap files?

Postby vanRijn on Wed Mar 20, 2013 1:44 am

I can't find anything more recent than viewtopic.php?f=6&t=3311 that talks about mousemap files and contexts, but can this please be added to Sublime Text 3 if not Sublime Text 2? There are two plugins that I use regularly (CscopeSublime and Git) and I'd really like to be able to to add double-click-to-navigate functionality to both of them. In fact, I've already added it to CscopeSublime and I tried adding it to the Git plugin today, but discovered that doing so broke the double-click functionality of CscopeSublime. I ended up having to back out the mousemap addition (https://github.com/dacap/sublime-text-2-git/pull/1), but this makes me very sad.

jps, can you please comment on this?

If mousemaps aren't going to have context support, I'm thinking I might try my hand at making a generic SublimeTextDoubleClickHandler plugin that allows users to configure a list of contexts, view names, or something to limit scope and then a corresponding Command to execute, and then have my plugin try to do the right thing based on context or view name, and then if it can't find the right context, just pass the double-click event back to the default plugin like this thread discusses: viewtopic.php?f=6&t=8823

But it would REALLY be great to be able to just have context support in mousemap files. At this point, it looks like users are only allowed to install a single plugin, other than the Default plugin, that handles double-click events. =:(
vanRijn
 
Posts: 9
Joined: Tue Feb 05, 2013 6:55 pm

Re: Can we please get context support for mousemap files?

Postby FichteFoll on Wed Mar 20, 2013 11:51 pm

The workaround idea is quite interesting.

I didn't really think about it but you could actually create a wrapper like sublime_plugin does for EventListeners but for mouse events.
Of course, you'd have to have this extension installed but when it works like I think it could then you just need to define a "on_mouse_event(self, view, button, modifiers, ...)" method and do some handling there. This needs some thoughts but having some experience with the sublime API and sublime_plugin handling I think this might work.
FichteFoll
 
Posts: 408
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: Can we please get context support for mousemap files?

Postby vanRijn on Thu Mar 21, 2013 12:56 am

Hey FichteFoll!

My initial idea was to do basically something as simple as this:

Code: Select all
class DoubleClickHandler(sublime_plugin.TextCommand):
    def __init__(self,view):
        self.view = view

    def run_(self, args):
        # Iterate through all of the user-provided key/value pairs for "context" or "view name", etc., and if the current view matches any of them,
        # call whatever command the user provides that matches. If we can't find any matches, pass the event on through to the default plugin:
        else:
            self.view.run_command("drag_select", {'event': args['event']})
            self.view.run_command("drag_select", args)


I was thinking the user-supplied config file could look something like this:

Code: Select all
{
    {
        // configuration for a view context
        "configType": "context",
        "identifier": "text.find-in-files",
        "command": "cscope_visiter"
    },
    {
        // configuration for a view name
        "configType": "name",
        "identifier": "Git Diff",
        "command": "git_goto_diff"
    },
    {
        // configuration for a view syntax
        "configType": "syntax",
        "identifier": "Packages/CscopeSublime/Lookup Results.hidden-tmLanguage",
        "command": "cscope_visiter"
    }

}


Here's what these two plugins do currently to make sure they're in the right view before doing anything with the command:

Code: Select all
class GitGotoDiff(sublime_plugin.TextCommand):
    def run(self, edit):
        v = self.view
        if v.name() != "Git Diff":
            return


Code: Select all
class CscopeVisiter(sublime_plugin.TextCommand):
    def __init__(self,view):
        self.view = view

    def run_(self, args):
        if self.view.settings().get('syntax') == CSCOPE_SYNTAX_FILE:


Is this a similar approach to what you were talking about?
vanRijn
 
Posts: 9
Joined: Tue Feb 05, 2013 6:55 pm

Re: Can we please get context support for mousemap files?

Postby FichteFoll on Thu Mar 21, 2013 5:15 pm

Yes, that't what I understood from your post but my idea was kinda different. I'd really like to write some code for that but apparently I have 0 time to spare atm.
FichteFoll
 
Posts: 408
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany


Return to Plugin Development

Who is online

Users browsing this forum: Alexa [Bot], Google [Bot] and 5 guests