Home Download Buy Blog Forum Support

log_commands is great, but....(question)

log_commands is great, but....(question)

Postby CaptainPalapa on Thu Aug 15, 2013 7:48 pm

So, I completely love log_commands(True). Enough that I wanted to map some keys to turn it on! Seen a lot of discussion about using it, but not how to map it!

I've tried various things, my last is:
, { "keys": ["ctrl+alt+f12"], "command": "sublime.log_commands", "args": { "setting": "True" } }
, { "keys": ["ctrl+alt+f11"], "command": "sublime.log_commands", "args": { "setting" : "False" } }

The problem here is that I have no idea what the ARGUMENT key name is! I've guessed at 50 things, and "setting" isn't the right value. I've even tried this:

, { "keys": ["ctrl+alt+f12"], "command": "sublime.log_commands(True) }
, { "keys": ["ctrl+alt+f11"], "command": "sublime.log_commands(False) }

...and while it shows in the console, kicking it to False doesn't actually turn off the feature. My next mousec click shows up or anything I type.

Any ideas? I tried to see if there was a setting value I could toggle, but could not find a definitely list of all Sublime 2 settings. (Other than the settings file, which has nothing for log_commands.)

I had actually thought this would be simple and straightforward. (Loving Sublime, by the way!)
CaptainPalapa
 
Posts: 2
Joined: Thu Aug 15, 2013 7:41 pm

Re: log_commands is great, but....(question)

Postby skuroda on Thu Aug 15, 2013 10:11 pm

Don't know if you can do it like that. Though you can wrap the command in a plugin pretty easily.

Code: Select all
import sublime
import sublime_plugin

class ToggleLogCommandsCommand(sublime_plugin.ApplicationCommand):
    log_command_state = False
    def run(self):
        self.log_command_state = not self.log_command_state
        sublime.status_message("log_commands set to %s" % self.log_command_state)
        sublime.log_commands(self.log_command_state)


Bind "toggle_log_commands" to the key binding of your choosing. This also has the benefit of only using one key binding instead of two. :)
skuroda
 
Posts: 676
Joined: Fri Oct 05, 2012 8:11 am

Re: log_commands is great, but....(question)

Postby CaptainPalapa on Thu Aug 15, 2013 11:27 pm

@skuroda : Very cool, man. Exactly what I wanted. Of course, my initial reaction was: "There's no way toggle_log_command is going to work, that text isn't anywhere!" (Then I went and read about how to build a Sublime plugin and realized you clearly knew what you were doing.)

Thanks for the help. Once I figure out the HOW part, I'll throw that up as a package that can be grabbed like others I've seen. With credit-from-the-rookie to you!
CaptainPalapa
 
Posts: 2
Joined: Thu Aug 15, 2013 7:41 pm


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot], gtsublime and 26 guests