Sublime Forum

Can we please get context support for mousemap files?

#1

I can’t find anything more recent than Mousemap & File-Specific commands 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 (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: Can I make double click do normal behaviour + my own

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. =:(

2 Likes

Dev Build 3067
#2

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.

1 Like

#3

Hey FichteFoll!

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

[code]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)

[/code]

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

[code]{
{
// 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”
}

}
[/code]

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

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

[code]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:

[/code]

Is this a similar approach to what you were talking about?

1 Like

#4

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.

1 Like

#5

Bump. I’m struggling with this at the moment, with two plugins with double-click support, but one of them gets the double-click.

1 Like

#6

bump? Feels only natural that this should be supported. Was clueless why my context wouldn’t work…

1 Like

#7

one can also vote-up this issue here:

2 Likes