Merge pull request #15 from Germanika/master

add split, vsplit, sp, and vsp commands
This commit is contained in:
Loic Nageleisen 2015-02-23 09:27:53 +01:00
commit c4771a9b85
2 changed files with 28 additions and 2 deletions

View file

@ -11,10 +11,11 @@ class Command
execute: (input) -> execute: (input) ->
return unless input.characters.length > 0 return unless input.characters.length > 0
[command, args...] = input.characters.split(" ")
func = (new Ex)[input.characters] func = (new Ex)[command]
if func? if func?
func() func(args)
else else
throw new CommandError("#{input.characters}") throw new CommandError("#{input.characters}")

View file

@ -4,6 +4,31 @@ class Ex
atom.workspace.getActiveEditor().save() atom.workspace.getActiveEditor().save()
else else
atom.workspace.getActivePane().saveActiveItemAs() atom.workspace.getActivePane().saveActiveItemAs()
w: => @write() w: => @write()
split: (filePaths) ->
pane = atom.workspace.getActivePane()
if filePaths? and filePaths.length > 0
newPane = pane.splitUp()
for file in filePaths
do ->
atom.workspace.openURIInPane file, newPane
else
pane.splitUp(copyActiveItem: true)
sp: (filePaths) => @split(filePaths)
vsplit: (filePaths) ->
pane = atom.workspace.getActivePane()
if filePaths? and filePaths.length > 0
newPane = pane.splitLeft()
for file in filePaths
do ->
atom.workspace.openURIInPane file, newPane
else
pane.splitLeft(copyActiveItem: true)
vsp: (filePaths) => @vsplit(filePaths)
module.exports = Ex module.exports = Ex