From 3952ef9afdc657571b108864a052f1b12270cfb1 Mon Sep 17 00:00:00 2001 From: DanyaPostfactum Date: Thu, 24 Jan 2013 19:22:30 +1000 Subject: [PATCH] BlockIndent command ( Ctrl-[ and Ctrl-] ) --- lib/ace/commands/default_commands.js | 10 ++++++++++ lib/ace/editor.js | 15 ++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/ace/commands/default_commands.js b/lib/ace/commands/default_commands.js index b8583c06..94f68d76 100644 --- a/lib/ace/commands/default_commands.js +++ b/lib/ace/commands/default_commands.js @@ -414,6 +414,16 @@ exports.commands = [{ bindKey: bindKey("Tab", "Tab"), exec: function(editor) { editor.indent(); }, multiSelectAction: "forEach" +},{ + name: "blockoutdent", + bindKey: bindKey("Ctrl-[", "Ctrl-["), + exec: function(editor) { editor.blockOutdent(); }, + multiSelectAction: "forEach" +},{ + name: "blockindent", + bindKey: bindKey("Ctrl-]", "Ctrl-]"), + exec: function(editor) { editor.blockIndent(); }, + multiSelectAction: "forEach" }, { name: "insertstring", exec: function(editor, str) { editor.insert(str); }, diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 5b5552d9..f87ad128 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -1245,8 +1245,8 @@ var Editor = function(renderer, session) { this.selection.setSelectionRange(originalRange); }; - /** - * Indents the current line. + /** + * Inserts an indentation into the current cursor position or indents the selected lines. * * @related EditSession.indentRows **/ @@ -1273,7 +1273,16 @@ var Editor = function(renderer, session) { } }; - /** + /** + * Indents the current line. + * @related EditSession.indentRows + **/ + this.blockIndent = function() { + var rows = this.$getSelectedRows(); + this.session.indentRows(rows.first, rows.last, "\t"); + }; + + /** * Outdents the current line. * @related EditSession.outdentRows **/