From e0ce741f5b99f51c98f676bbfcdfcd04fa404b30 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 14 Jul 2013 07:44:50 +0400 Subject: [PATCH] convert multi_select to an option --- lib/ace/multi_select.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/ace/multi_select.js b/lib/ace/multi_select.js index 41ca9b89..ea4b3198 100644 --- a/lib/ace/multi_select.js +++ b/lib/ace/multi_select.js @@ -867,13 +867,16 @@ exports.onSessionChange = function(e) { // adds multiple selection support to the editor // (note: should be called only once for each editor instance) function MultiSelect(editor) { + if (editor.$multiselectOnSessionChange) + return; editor.$onAddRange = editor.$onAddRange.bind(editor); editor.$onRemoveRange = editor.$onRemoveRange.bind(editor); editor.$onMultiSelect = editor.$onMultiSelect.bind(editor); editor.$onSingleSelect = editor.$onSingleSelect.bind(editor); + editor.$multiselectOnSessionChange = exports.onSessionChange.bind(editor); - exports.onSessionChange.call(editor, editor); - editor.on("changeSession", exports.onSessionChange.bind(editor)); + editor.$multiselectOnSessionChange(editor); + editor.on("changeSession", editor.$multiselectOnSessionChange); editor.on("mousedown", onMouseDown); editor.commands.addCommands(commands.defaultCommands); @@ -908,4 +911,23 @@ function addAltCursorListeners(editor){ exports.MultiSelect = MultiSelect; + +require("./config").defineOptions(Editor.prototype, "editor", { + enableMultiselect: { + set: function(val) { + MultiSelect(this); + if (val) { + this.on("changeSession", this.$multiselectOnSessionChange); + this.on("mousedown", onMouseDown); + } else { + this.off("changeSession", this.$multiselectOnSessionChange); + this.off("mousedown", onMouseDown); + } + }, + value: true + } +}) + + + });