Script package and key binding



I’m trying to add some new key binding to the keymap.cson
I don’t really know how to find the right widget and I don’t really know what are the available commands for that package.

I would like to control the toggle mode (icon beside the close cross)

Any link that can help me find out what I’m looking for ?


from the developer Tools, I managed to track to the atom-panel-container and the icon is heading-fold inline-block icon-fold with a toggle mode

but when clicking that icon it highlights something else and go back and forth between:

<div class="heading-summary inline-block" style="display: inline-block;"></div>
<div class="heading-summary inline-block" style="display: none;"></div>

but I have no idea how to use that :confused:


Hit ctrl-shift-p to open the Command Palette. You can then type “script” to pull up every command with that in its name, and the ones that start with Script: are from the script package (most likely; there’s not actually a requirement to that extent, but package authors are generally good about naming their commands well). There is not a “toggle visible” or “toggle folded” command. However, since Atom is all unprotected JavaScript, you can make it do what you want. Through investigating script, we can see that its view is based on atom-message-panel. atom-message-panel has a toggle() function, which is what the onclick attribute refers to. You can tell Atom to toggle the view by running this in the dev tools console:



How can this be transformed in coffeeScript for the key binding ?
From what you’ve linked I came up with the following code but I don’t think it is correct

  'alt-a': 'script-view:toggle'

Any direction ?


No, because you haven’t defined a command (and, as I said, the first part of the command name is usually the package; if you aren’t developing a package, you shouldn’t use a name that could be confused for one, like script-view). You want to use the CommandRegistry API.

atom.commands.add 'atom-workspace', 'custom:toggle-script-view', ->
  return unless pkg = atom.packages.getActivePackage('script')


Hi @DamnedScholar

Thank you for your patience :slight_smile:
I can’t try it right now since I don’t have Atom on my machine but once that command is created in the, The key binding would be as follow

   'alt-a': 'custom:toggle-script-view'

right ?


Yes indeed.