no need to track the cursor manually anymore

This commit is contained in:
Fabian Jakobs 2011-02-11 11:51:01 +01:00
commit 4cc5bf9a7b
11 changed files with 13 additions and 36 deletions

View file

@ -576,7 +576,6 @@ var EditSession = function(text, mode) {
for (var row=startRow; row<=endRow; row++) {
this.insert({row: row, column:0}, indentString);
}
return indentString.length;
};
this.outdentRows = function (range) {
@ -599,13 +598,8 @@ var EditSession = function(text, mode) {
deleteRange.start.column = 0;
deleteRange.end.column = j;
}
if (i == range.start.row)
range.start.column -= deleteRange.end.column - deleteRange.start.column;
if (i == range.end.row)
range.end.column -= deleteRange.end.column - deleteRange.start.column;
this.remove(deleteRange);
}
return range;
};
this.moveLinesUp = function(firstRow, lastRow) {

View file

@ -397,14 +397,6 @@ var Editor =function(renderer, session) {
var lineIndent = this.mode.getNextLineIndent(lineState, line.slice(0, cursor.column), this.session.getTabString());
var end = this.session.insert(cursor, text);
/* TODO: This shortcut is somehow broken
if (!shouldOutdent && line != this.session.getLine(row) && text != "\n") {
this.moveCursorToPosition(end);
this.renderer.scrollCursorIntoView();
return;
}
*/
var lineState = this.bgTokenizer.getState(cursor.row);
// multi line insert
if (cursor.row !== end.row) {
@ -437,15 +429,12 @@ var Editor =function(renderer, session) {
outdent -= 1;
this.session.replace(new Range(row, 0, row, line.length), line.substr(i));
}
end.column += this.session.indentRows(cursor.row + 1, end.row, lineIndent);
this.session.indentRows(cursor.row + 1, end.row, lineIndent);
} else {
if (shouldOutdent) {
end.column += this.mode.autoOutdent(lineState, this.session, cursor.row);
this.mode.autoOutdent(lineState, this.session, cursor.row);
}
}
this.moveCursorToPosition(end);
this.renderer.scrollCursorIntoView();
}
this.onTextInput = function(text) {
@ -577,8 +566,7 @@ var Editor =function(renderer, session) {
if (range.start.row < range.end.row || range.start.column < range.end.column) {
var rows = this.$getSelectedRows();
var count = session.indentRows(rows.first, rows.last, "\t");
// TODO remove count from indent
session.indentRows(rows.first, rows.last, "\t");
} else {
var indentString;
@ -600,9 +588,7 @@ var Editor =function(renderer, session) {
return;
var selection = this.session.getSelection();
var range = this.session.outdentRows(selection.getRange());
// TODO remove range from outdent
//selection.setSelectionRange(range, selection.isBackwards());
this.session.outdentRows(selection.getRange());
};
this.toggleCommentLines = function() {
@ -611,8 +597,7 @@ var Editor =function(renderer, session) {
var state = this.bgTokenizer.getState(this.getCursorPosition().row);
var rows = this.$getSelectedRows()
var addedColumns = this.mode.toggleCommentLines(state, this.session, rows.first, rows.last);
// TODO remove addedColumns
this.mode.toggleCommentLines(state, this.session, rows.first, rows.last);
};
this.removeLines = function() {

View file

@ -119,7 +119,7 @@ oop.inherits(Mode, TextMode);
};
this.autoOutdent = function(state, doc, row) {
return this.$outdent.autoOutdent(doc, row);
this.$outdent.autoOutdent(doc, row);
};
}).call(Mode.prototype);

View file

@ -91,7 +91,7 @@ proto.checkOutdent = function(state, line, input) {
};
proto.autoOutdent = function(state, doc, row) {
return this.$outdent.autoOutdent(doc, row);
this.$outdent.autoOutdent(doc, row);
};
exports.Mode = CoffeeMode;

View file

@ -73,7 +73,7 @@ oop.inherits(Mode, TextMode);
};
this.autoOutdent = function(state, doc, row) {
return this.$outdent.autoOutdent(doc, row);
this.$outdent.autoOutdent(doc, row);
};
}).call(Mode.prototype);

View file

@ -74,7 +74,7 @@ oop.inherits(Mode, TextMode);
};
this.autoOutdent = function(state, doc, row) {
return this.$delegate("autoOutdent", arguments);
this.$delegate("autoOutdent", arguments);
};
this.$delegate = function(method, args, defaultHandler) {

View file

@ -119,7 +119,7 @@ oop.inherits(Mode, TextMode);
};
this.autoOutdent = function(state, doc, row) {
return this.$outdent.autoOutdent(doc, row);
this.$outdent.autoOutdent(doc, row);
};
this.createWorker = function(session) {

View file

@ -63,8 +63,6 @@ var MatchingBraceOutdent = function() {};
var indent = this.$getIndent(doc.getLine(openBracePos.row));
doc.replace(new Range(row, 0, row, column-1), indent);
return indent.length - (column-1);
};
this.$getIndent = function(line) {

View file

@ -107,7 +107,7 @@ oop.inherits(Mode, TextMode);
};
this.autoOutdent = function(state, doc, row) {
return this.$outdent.autoOutdent(doc, row);
this.$outdent.autoOutdent(doc, row);
};
}).call(Mode.prototype);

View file

@ -108,7 +108,7 @@ oop.inherits(Mode, TextMode);
};
this.autoOutdent = function(state, doc, row) {
return this.$outdent.autoOutdent(doc, row);
this.$outdent.autoOutdent(doc, row);
};
}).call(Mode.prototype);

View file

@ -108,7 +108,7 @@ oop.inherits(Mode, TextMode);
};
this.autoOutdent = function(state, doc, row) {
return this.$outdent.autoOutdent(doc, row);
this.$outdent.autoOutdent(doc, row);
};
}).call(Mode.prototype);