Giter Site home page Giter Site logo

chainofcommand's Introduction

Chain of Command

Sublime text plugin to run a chain of commands


Usage

To run a chain of commands you run the chain window commands and pass it a list of commands to run. Each command is defined as a list where the first argument is the name of the command to run and any additional arguments will be passed directly to the command.

For example, to run the select_all command and then run the copy command you would call:

window.run_command("chain",{"commands":[["select_all"],["copy"]]})

Or if you wanted to focus the first group in a window:

 window.run_command("chain",{"commands":[["focus_group",{"group":0}]]})

The point is to be able to build custom key bindings to run a sequence of commands. Lets say you wanted a key binding to duplicate the current file. You could set this key binding:

{
  "keys": ["super+shift+option+d"], 
  "command": "chain", 
  "args": {
    "commands": [
      ["select_all"],
      ["copy"],
      ["new_file"],
      ["paste"],
      ["save"]
    ]
  }
}

This would select all the text, copy it, create a new file, paste the text, then open the save file dialog.

chainofcommand's People

Contributors

jisaacks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

chainofcommand's Issues

Can I apply this to mouse actions?

In Default (Windows).sublime-mousemap:

`{
         "button": "button1", "count": 1,
	  "command": "chain", 
	  "args":
	  {
	    "press_commands":
	    [
	    	[
	    	  "drag_select",
	    	],
	    	[
	    	  "hide_overlay",
	    	],
	    ],
	},
},`

I tried the above with press_command (the usual syntax in .sublime-mousemap), instead of command, still didn't work. Is there any way to modify the .py file to include mouse support?

Compatibility with `run_macro_file`

Since "Chain of Command" overlaps in functionality with run_macro_file, I occasionally find myself converting macros to "chain" hotkeys. You can't just copy-paste the macro commands into the "command" argument because the format is different: macro commands are dicts, whereas "chain" commands are lists.

I think it would be better if CoC accepted the macro command format. For backwards compatibility, we can detect and support both the list and the dict formats.

Thoughts?

Not working in Debian

Hello there I install the plugin and try to use it but it seems not to do anything. these are my commands so far:
{ "keys": ["ctrl+alt+shift+d"], "command": "duplicate_file", "args": { "commands": [ ["select_all"], ["copy"], ["new_file"], ["paste"], ["save"] ] } }, { "keys": ["ctrl+alt+f"], "command": "autoindent_file", "args": { "commands": [ ["select_all"], ["reindent"] ] } }

Issue with Sublime text chain of command plugin

I am trying to set a shortcut key which performs two tasks: close the current file in current panel and move the cursor to first panel,i'have written following code in key map :

[ { "keys": ["ctrl+alt+z"], "command": "chain", "args": { "commands": [ ["close_file"], ["focus_group",{"group": 0}] ] } } ]
but it does not works if only one file is open in current panel. It actually closes that file but does not moves cursor to first panel.

Pause command until new window opens

I am trying to implement this and if I do it then it works fine which centers the definition at the top of the current buffer window. But if I use the chain of command it seems to not register I think because the window hasn't opened because sometimes the center commands run on the previous window.

{
    "keys": ["alt+."],
    // Force ability to bring up context menu
    "command": "chain",
    // "context": [ { "key": "selection_empty", "operator": "equal", "operand": true } ],
    "args": {
        "commands": [
             ["goto_definition"],
            ["sbp_center_view"],
            ["sbp_center_view"],
     ] 
    }},

Doesn't work with the Golang Build package

Hello!

I've installed the both of ChainOfCommand and Golang build. I'd like to save and build a file by one hotkey.
To build a file, I use this:

    {
        "keys": ["f5"],
        "command": "golang_build",
        "args": {
            "task": "run",
        }
    }

Now, i want to save and to build. I'm trying to use this code:

{
    "keys": ["f5"],
    "command": "chain",
    "args": {
        "commands": [
            ["save"],
            ["golang_build", {
                "args": {
                "task": "run",
                }
            }],
        ]
    }
}

But it's only saves my file without building. Can you help me with this? Thanks.

hide_auto_complete prevents moving cursor down

I was trying to prevent the arrow keys from being used to navigate the auto-completion menu. When I press the down arrow it should close the auto-complete menu and move down a line. The problem is that using the 'hide_auto_complete' command prevents subsequent commands from moving the cursor down by a line.

Intuitively I think this should work. It doesn't for me currently

{ "keys": ["down"], "command": "chain",
  "args": {
    "commands": [
      // hides the auto-complete popup
      [ "hide_auto_complete" ],

      // moves the cursor down
      [ "move", { "by": "lines", "forward": true } ]
    ]
  },
  "context": [{ "key": "auto_complete_visible" }]
},

However the following does work

{ "keys": ["down"], "command": "chain",
  "args": {
    "commands": [
      // make the auto-complete menu hide by moving the cursor a character forward
      [ "move", { "by": "characters", "forward": true } ],

      // undo the cursor move used to hide the auto-complete window
      [ "move", { "by": "characters", "forward": false } ],

      // moves the cursor down
      [ "move", { "by": "lines", "forward": true } ]
    ]
  },
  "context": [{ "key": "auto_complete_visible" }]
},

How to undo the whole chain?

Hello! Thanks for the great package.

Given the following:

  {
     "keys": ["ctrl+shift+up"],
     "command": "chain",
     "args": {
       "commands": [
         ["swap_line_up"],
         ["reindent", {"single_line": true}]
       ],
     },
   },
  {
    "keys": ["ctrl+shift+down"],
    "command": "chain",
    "args": {
      "commands": [
        ["swap_line_down"],
        ["reindent", {"single_line": true}]
      ],
    },
  },

I'd love sublime to understand that one "shortcut" should be undoable "as a whole action". Currently to undo the whole chain, i have to hit ctrl+z multiple times (sometimes only once if the "reindent" action didn't do anything.

Is anyone aware of any solution to make Sublime Text understand I want to wrap this whole "chain" (and whatever it does to the buffer) as one single atomic action?

Run command according to syntax.

is it possible to add specific syntax like (html,css,etc..) to a command so the command only runs when the currently active file is that declared syntax?, like

{
  "keys": ["super+s"], 
  "command": "chain", 
  "args": {
    "commands": [
      ["save_all"]
    ],
    "scope": (source.html),
    "commands": [
      ["html_beautify"]
    ],
    "scope": (source.css, source.less),
    "commands": [
      ["css_comb"]
    ]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.