From cb83a974b4c7bda53b53cfcdca81c861abd58142 Mon Sep 17 00:00:00 2001 From: xixixao Date: Wed, 18 Mar 2015 21:09:45 +0000 Subject: [PATCH] Add configuration option for block select --- lib/ace/mouse/multi_select_handler.js | 4 ++-- lib/ace/multi_select.js | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/ace/mouse/multi_select_handler.js b/lib/ace/mouse/multi_select_handler.js index 9b52e237..45704b39 100644 --- a/lib/ace/mouse/multi_select_handler.js +++ b/lib/ace/mouse/multi_select_handler.js @@ -84,14 +84,14 @@ function onMouseDown(e) { if (editor.$mouseHandler.$enableJumpToDef) { if (ctrl && alt || accel && alt) selectionMode = "add"; - else if (alt) + else if (alt && editor.$blockSelectEnabled) selectionMode = "block"; } else { if (accel && !alt) { selectionMode = "add"; if (!isMultiSelect && shift) return; - } else if (alt) { + } else if (alt && editor.$blockSelectEnabled) { selectionMode = "block"; } } diff --git a/lib/ace/multi_select.js b/lib/ace/multi_select.js index 0635afc2..85611a33 100644 --- a/lib/ace/multi_select.js +++ b/lib/ace/multi_select.js @@ -924,7 +924,8 @@ function addAltCursorListeners(editor){ var el = editor.textInput.getElement(); var altCursor = false; event.addListener(el, "keydown", function(e) { - if (e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey)) { + var altDown = e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey); + if (editor.$blockSelectEnabled && altDown) { if (!altCursor) { editor.renderer.setMouseCursor("crosshair"); altCursor = true; @@ -962,6 +963,12 @@ require("./config").defineOptions(Editor.prototype, "editor", { } }, value: true + }, + enableBlockSelect: { + set: function(val) { + this.$blockSelectEnabled = val; + }, + value: true } });