* Added active line highlighting for the gutter

This commit is contained in:
Ruben Daniels 2012-04-08 13:17:03 +02:00 • committed by Fabian Jakobs
commit d6c3e006b6
3 changed files with 25 additions and 13 deletions

View file

@ -189,6 +189,10 @@
z-index: 2; z-index: 2;
} }
.ace_gutter .ace_gutter_active_line{
background-color : #dcdcdc;
}
.ace_marker-layer .ace_selected_word { .ace_marker-layer .ace_selected_word {
position: absolute; position: absolute;
z-index: 6; z-index: 6;

View file

@ -334,21 +334,29 @@ var Editor = function(renderer, session) {
this.$updateHighlightActiveLine = function() { this.$updateHighlightActiveLine = function() {
var session = this.getSession(); var session = this.getSession();
if (session.$highlightLineMarker) { if (session.$highlightLineMarker)
session.removeMarker(session.$highlightLineMarker); session.removeMarker(session.$highlightLineMarker);
} if (typeof this.$lastrow == "number")
session.$highlightLineMarker = null; this.renderer.removeGutterDecoration(this.$lastrow, "ace_gutter_active_line");
if (this.getHighlightActiveLine() && (this.getSelectionStyle() != "line" || !this.selection.isMultiLine())) { session.$highlightLineMarker = null;
this.$lastrow = null;
if (this.getHighlightActiveLine()) {
var cursor = this.getCursorPosition(), var cursor = this.getCursorPosition(),
foldLine = this.session.getFoldLine(cursor.row); foldLine = this.session.getFoldLine(cursor.row);
var range;
if (foldLine) { if ((this.getSelectionStyle() != "line" || !this.selection.isMultiLine())) {
range = new Range(foldLine.start.row, 0, foldLine.end.row + 1, 0); var range;
} else { if (foldLine) {
range = new Range(cursor.row, 0, cursor.row+1, 0); range = new Range(foldLine.start.row, 0, foldLine.end.row + 1, 0);
} else {
range = new Range(cursor.row, 0, cursor.row+1, 0);
}
session.$highlightLineMarker = session.addMarker(range, "ace_active_line", "background");
} }
session.$highlightLineMarker = session.addMarker(range, "ace_active_line", "background");
this.renderer.addGutterDecoration(this.$lastrow = cursor.row, "ace_gutter_active_line");
} }
}; };

View file

@ -68,11 +68,11 @@ var Gutter = function(parentEl) {
this.addGutterDecoration = function(row, className){ this.addGutterDecoration = function(row, className){
if (!this.$decorations[row]) if (!this.$decorations[row])
this.$decorations[row] = ""; this.$decorations[row] = "";
this.$decorations[row] += " ace_" + className; this.$decorations[row] += " " + className;
}; };
this.removeGutterDecoration = function(row, className){ this.removeGutterDecoration = function(row, className){
this.$decorations[row] = this.$decorations[row].replace(" ace_" + className, ""); this.$decorations[row] = this.$decorations[row].replace(" " + className, "");
}; };
this.setBreakpoints = function(rows) { this.setBreakpoints = function(rows) {