commit
5718f2dc5f
22 changed files with 567 additions and 124 deletions
|
|
@ -421,6 +421,14 @@ var Editor =function(renderer, session) {
|
|||
var mode = session.getMode();
|
||||
|
||||
var cursor = this.getCursorPosition();
|
||||
|
||||
if (this.getBehavioursEnabled()) {
|
||||
// Get a transform if the current mode wants one.
|
||||
var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text);
|
||||
if (transform)
|
||||
text = transform.text;
|
||||
}
|
||||
|
||||
text = text.replace("\t", this.session.getTabString());
|
||||
|
||||
// remove selected text
|
||||
|
|
@ -436,12 +444,27 @@ var Editor =function(renderer, session) {
|
|||
|
||||
this.clearSelection();
|
||||
|
||||
var start = cursor.column;
|
||||
var lineState = session.getState(cursor.row);
|
||||
var shouldOutdent = mode.checkOutdent(lineState, session.getLine(cursor.row), text);
|
||||
var line = session.getLine(cursor.row);
|
||||
var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
|
||||
var end = session.insert(cursor, text);
|
||||
|
||||
|
||||
if (transform && transform.selection) {
|
||||
if (transform.selection.length == 2) { // Transform relative to the current column
|
||||
this.selection.setSelectionRange(
|
||||
new Range(cursor.row, start + transform.selection[0],
|
||||
cursor.row, start + transform.selection[1]));
|
||||
} else { // Transform relative to the current row.
|
||||
this.selection.setSelectionRange(
|
||||
new Range(cursor.row + transform.selection[0],
|
||||
transform.selection[1],
|
||||
cursor.row + transform.selection[2],
|
||||
transform.selection[3]));
|
||||
}
|
||||
}
|
||||
|
||||
var lineState = session.getState(cursor.row);
|
||||
|
||||
// TODO disabled multiline auto indent
|
||||
|
|
@ -591,6 +614,15 @@ var Editor =function(renderer, session) {
|
|||
this.getReadOnly = function() {
|
||||
return this.$readOnly;
|
||||
};
|
||||
|
||||
this.$modeBehaviours = false;
|
||||
this.setBehavioursEnabled = function (enabled) {
|
||||
this.$modeBehaviours = enabled;
|
||||
}
|
||||
|
||||
this.getBehavioursEnabled = function () {
|
||||
return this.$modeBehaviours;
|
||||
}
|
||||
|
||||
this.removeRight = function() {
|
||||
if (this.$readOnly)
|
||||
|
|
@ -609,8 +641,18 @@ var Editor =function(renderer, session) {
|
|||
|
||||
if (this.selection.isEmpty())
|
||||
this.selection.selectLeft();
|
||||
|
||||
var range = this.getSelectionRange();
|
||||
if (this.getBehavioursEnabled()) {
|
||||
var session = this.session;
|
||||
var state = session.getState(range.start.row);
|
||||
var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
|
||||
if (new_range !== false) {
|
||||
range = new_range;
|
||||
}
|
||||
}
|
||||
|
||||
this.session.remove(this.getSelectionRange());
|
||||
this.session.remove(range);
|
||||
this.clearSelection();
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue