From 2cafba248ce5714bf21a0f115d80f6cf5d688e0c Mon Sep 17 00:00:00 2001 From: Dave de Fijter Date: Sun, 22 Feb 2015 16:09:40 +0100 Subject: [PATCH] added new commands for quitting, opening tabs and added argument functionality for commands --- lib/command.coffee | 5 +++-- lib/ex.coffee | 29 +++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/lib/command.coffee b/lib/command.coffee index 38d5765..393b295 100644 --- a/lib/command.coffee +++ b/lib/command.coffee @@ -11,10 +11,11 @@ class Command execute: (input) -> return unless input.characters.length > 0 + [command, args...] = input.characters.split(" ") - func = (new Ex)[input.characters] + func = (new Ex)[command] if func? - func() + func(args) else throw new CommandError("#{input.characters}") diff --git a/lib/ex.coffee b/lib/ex.coffee index 9e61de4..f5e066c 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -1,9 +1,30 @@ class Ex - write: -> - if atom.workspace.getActiveTextEditor().getPath() isnt undefined - atom.workspace.getActiveEditor().save() + quit: -> + atom.workspace.getActivePane().destroyActiveItem() + q: => + @quit() + tabedit: (filenames) -> + if filenames? and filenames.length > 0 + atom.open(pathsToOpen: filenames) 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() + wq: => + @write(close=true) module.exports = Ex