add indent/outdent support
This commit is contained in:
parent
f5a61599cf
commit
879539f32a
3 changed files with 117 additions and 1 deletions
|
|
@ -181,4 +181,28 @@ ace.TextDocument.prototype.replace = function(range, text) {
|
|||
: undefined);
|
||||
|
||||
return end;
|
||||
};
|
||||
|
||||
ace.TextDocument.prototype.indentRows = function(range, indentString) {
|
||||
for (var i=range.start.row; i<= range.end.row; i++) {
|
||||
this.lines[i] = indentString + this.getLine(i);
|
||||
}
|
||||
this.fireChangeEvent(range.start.row, range.end.row);
|
||||
};
|
||||
|
||||
ace.TextDocument.prototype.outdentRows = function(range, indentString) {
|
||||
outdentLength = indentString.length;
|
||||
|
||||
for (var i=range.start.row; i<= range.end.row; i++) {
|
||||
if (this.getLine(i).substr(0, outdentLength) !== indentString) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (var i=range.start.row; i<= range.end.row; i++) {
|
||||
this.lines[i] = this.getLine(i).substring(outdentLength);
|
||||
}
|
||||
|
||||
this.fireChangeEvent(range.start.row, range.end.row);
|
||||
return outdentLength;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue