added new commands for quitting, opening tabs and added argument functionality for commands
This commit is contained in:
parent
4a547e64fd
commit
2cafba248c
2 changed files with 28 additions and 6 deletions
|
|
@ -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}")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,30 @@
|
||||||
class Ex
|
class Ex
|
||||||
write: ->
|
quit: ->
|
||||||
if atom.workspace.getActiveTextEditor().getPath() isnt undefined
|
atom.workspace.getActivePane().destroyActiveItem()
|
||||||
atom.workspace.getActiveEditor().save()
|
q: =>
|
||||||
|
@quit()
|
||||||
|
tabedit: (filenames) ->
|
||||||
|
if filenames? and filenames.length > 0
|
||||||
|
atom.open(pathsToOpen: filenames)
|
||||||
else
|
else
|
||||||
atom.workspace.getActivePane().saveActiveItemAs()
|
atom.open()
|
||||||
|
tabe: (filenames) =>
|
||||||
|
@tabedit(filenames)
|
||||||
|
write: (close=false) =>
|
||||||
|
if close
|
||||||
|
nextAction = ->
|
||||||
|
atom.notifications.addSuccess("Saved and closed")
|
||||||
|
atom.workspace.getActivePane().destroyActiveItem()
|
||||||
|
else
|
||||||
|
nextAction = ->
|
||||||
|
atom.notifications.addSuccess("Saved")
|
||||||
|
|
||||||
|
if atom.workspace.getActiveTextEditor().getPath() isnt undefined
|
||||||
|
atom.workspace.getActivePane().saveItem(atom.workspace.getActivePane().getActiveItem(), nextAction)
|
||||||
|
else
|
||||||
|
atom.workspace.getActivePane().saveActiveItemAs(nextAction)
|
||||||
w: => @write()
|
w: => @write()
|
||||||
|
wq: =>
|
||||||
|
@write(close=true)
|
||||||
|
|
||||||
module.exports = Ex
|
module.exports = Ex
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue