Allow mode behaviours to be disabled at the editor level
This commit is contained in:
parent
138ec94f53
commit
8e7f4f2716
1 changed files with 21 additions and 8 deletions
|
|
@ -413,10 +413,12 @@ var Editor =function(renderer, session) {
|
||||||
|
|
||||||
var cursor = this.getCursorPosition();
|
var cursor = this.getCursorPosition();
|
||||||
|
|
||||||
// Get a transform if the current mode wants one.
|
if (this.getBehavioursEnabled()) {
|
||||||
var transform = mode.transformInsert(session.getState(cursor.row), this, session, text);
|
// Get a transform if the current mode wants one.
|
||||||
if (transform)
|
var transform = mode.transformInsert(session.getState(cursor.row), this, session, text);
|
||||||
text = transform.text;
|
if (transform)
|
||||||
|
text = transform.text;
|
||||||
|
}
|
||||||
|
|
||||||
text = text.replace("\t", this.session.getTabString());
|
text = text.replace("\t", this.session.getTabString());
|
||||||
|
|
||||||
|
|
@ -603,6 +605,15 @@ var Editor =function(renderer, session) {
|
||||||
this.getReadOnly = function() {
|
this.getReadOnly = function() {
|
||||||
return this.$readOnly;
|
return this.$readOnly;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.$modeBehaviours = true;
|
||||||
|
this.setBehavioursEnabled = function (enabled) {
|
||||||
|
this.$modeBehaviours = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getBehavioursEnabled = function () {
|
||||||
|
return this.$modeBehaviours;
|
||||||
|
}
|
||||||
|
|
||||||
this.removeRight = function() {
|
this.removeRight = function() {
|
||||||
if (this.$readOnly)
|
if (this.$readOnly)
|
||||||
|
|
@ -622,10 +633,12 @@ var Editor =function(renderer, session) {
|
||||||
if (this.selection.isEmpty())
|
if (this.selection.isEmpty())
|
||||||
this.selection.selectLeft();
|
this.selection.selectLeft();
|
||||||
|
|
||||||
var session = this.session;
|
var range = this.getSelectionRange();
|
||||||
var selection = this.getSelectionRange();
|
if (this.getBehavioursEnabled()) {
|
||||||
var state = session.getState(selection.start.row);
|
var session = this.session;
|
||||||
var range = session.getMode().transformRemove(state, this, session, selection);
|
var state = session.getState(range.start.row);
|
||||||
|
range = session.getMode().transformRemove(state, this, session, range);
|
||||||
|
}
|
||||||
|
|
||||||
this.session.remove(range);
|
this.session.remove(range);
|
||||||
this.clearSelection();
|
this.clearSelection();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue