Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to customize status bar help message #129

Open
kentliau opened this issue Sep 30, 2016 · 9 comments
Open

Ability to customize status bar help message #129

kentliau opened this issue Sep 30, 2016 · 9 comments

Comments

@kentliau
Copy link

I use different shortcut for rename mode to commit and discard changes due to I want esc to clear out multiple cursors not to undo.

I do by adding these shortcut to my user key binding

/* the command with "noop" is to disable the default behavior*/
  {
    "keys" : ["enter"],
    "command": "noop",
    "context": [
        { "key": "selector", "operator": "equal", "operand": "text.dired" },
        { "key": "setting.dired_rename_mode", "operand": true }
    ]
  },
  {
    "keys" : ["escape"],
    "command": "noop",
    "context": [
        { "key": "selector", "operator": "equal", "operand": "text.dired" },
        { "key": "setting.dired_rename_mode", "operand": true }
    ]
  },
  {
    "keys" : ["escape"],
    "command": "single_selection",
    "context": [
        { "key": "selector", "operator": "equal", "operand": "text.dired" },
        { "key": "setting.dired_rename_mode", "operand": true },
        { "key": "num_selections", "operator": "not_equal", "operand": 1 }
    ]
  },
  {
    "keys" : ["ctrl+x"],
    "command": "dired_rename_commit",
    "context": [
        { "key": "selector", "operator": "equal", "operand": "text.dired" },
        { "key": "setting.dired_rename_mode", "operand": true }
    ]
  },
  {
    "keys" : ["ctrl+z"],
    "command": "dired_rename_cancel",
    "context": [
        { "key": "selector", "operator": "equal", "operand": "text.dired" },
        { "key": "setting.dired_rename_mode", "operand": true }
    ]
  },

So now I want to customize the help file when press ? and the status bar help message down it the bottom of the windows. Can it like have another setting field to specify the custom shortcuts.md?

@aziz
Copy link
Owner

aziz commented Sep 30, 2016

I don't think it's possible in an easy and elegant way using the current API.
We need an API to be able to read keybindings programmatically to find the bound keys, which as far as I know is not provided by SublimeText. You can ask SublimeHQ to add this feature.

@vovkkk
Copy link
Collaborator

vovkkk commented Sep 30, 2016

If you install via Package Control on ST3 you can create Packages/FileBrowser/shortcuts.md with your own content.

I think we should at least set correct keybindings in status-bar when renaming dynamically.

@aziz
Copy link
Owner

aziz commented Sep 30, 2016

I think we should at least set correct keybindings in status-bar when renaming dynamically.

The Question is, can we?

@kentliau
Copy link
Author

kentliau commented Sep 30, 2016

@vovkkk thanks, just learned this.

@aziz reading dynamically from the key binding file is cool, for the time being I am good for just having a customized shortcuts.md in my user package dir, and I just learned that I can do that. But why not read from the shortcuts.md as well for the status bar message?

@aziz
Copy link
Owner

aziz commented Sep 30, 2016

It feels very hacky. I want a more robust and reliable solution, not just a hack!

@kentliau kentliau changed the title Ability to customize the shortcuts.md and status bar help message Ability to customize status bar help message Sep 30, 2016
@kentliau
Copy link
Author

i stumble upon this FindKeyConflicts, it go through all the binding files. But for a specific package, is it only have to go through the package's default and user's key binding file right?

@vovkkk
Copy link
Collaborator

vovkkk commented Sep 30, 2016

only have to go through the package's default and user's key binding file right?

No, keybinding can be anywhere.

I thought command has info about keybinding since ST show keys in menus dynamically, but apparently it does not.

@kentliau
Copy link
Author

some of the commands in command palette show the key binding even third party one

screen shot 2016-10-01 at 12 27 59 am

@vovkkk
Copy link
Collaborator

vovkkk commented Sep 30, 2016

That is what I meant menu and command palette, but this info is not available programmatically it seems.

You can get all text command as list with sublime_plugin.text_command_classes
you can init command with c = sublime_plugin.text_command_classes[105](view) (105 is an index i.e. the 106th command in the list)
you can print attributes of command pprint.pprint([(a, getattr(c, a)) for a in dir(c)])
All these steps can be done in console ViewShow Consoleimport sublime_plugin, pprint

You can look at sublime.py and sublime_plugin.py in the same directory as ST executable.

You will see that there is no any way in API to get keys for command.

You can create menu Packages/User/Main.sublime-menu:

[
  {
    "id": "filebrowser",
    "caption": "FileBrowser",
    "children":
    [
      { "command": "dired_rename_commit" },
      { "command": "dired_rename_cancel" },
      { "command": "dired_expand" }
    ]
  }
]

2016-10-01_05-44-07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants