From ba4f7e3765999b0a9265b9a9745aa9a898d9b3a0 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Sun, 22 Apr 2012 17:00:25 -0700 Subject: [PATCH] * added highlightgutterline setting --- lib/ace/editor.js | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/lib/ace/editor.js b/lib/ace/editor.js index f8998bb6..15d2052a 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -325,6 +325,7 @@ var Editor = function(renderer, session) { this.$highlightBrackets(); this.$updateHighlightActiveLine(); + this.$updateHighlightGutterLine(); }; this.$updateHighlightActiveLine = function() { @@ -332,13 +333,10 @@ var Editor = function(renderer, session) { if (session.$highlightLineMarker) session.removeMarker(session.$highlightLineMarker); - if (typeof this.$lastrow == "number") - this.renderer.removeGutterDecoration(this.$lastrow, "ace_gutter_active_line"); session.$highlightLineMarker = null; - this.$lastrow = null; - if (this.getHighlightActiveLine()) { + if (this.$highlightActiveLine) { var cursor = this.getCursorPosition(), foldLine = this.session.getFoldLine(cursor.row); @@ -351,10 +349,19 @@ var Editor = function(renderer, session) { } session.$highlightLineMarker = session.addMarker(range, "ace_active_line", "background"); } - - this.renderer.addGutterDecoration(this.$lastrow = cursor.row, "ace_gutter_active_line"); } }; + + this.$updateHighlightGutterLine = function(){ + if (typeof this.$lastrow == "number") + this.renderer.removeGutterDecoration(this.$lastrow, "ace_gutter_active_line"); + + this.$lastrow = null; + + if (this.$highlightGutterLine) + this.renderer.addGutterDecoration( + this.$lastrow = this.getCursorPosition().row, "ace_gutter_active_line"); + } this.onSelectionChange = function(e) { var session = this.getSession(); @@ -370,6 +377,7 @@ var Editor = function(renderer, session) { session.$selectionMarker = session.addMarker(range, "ace_selection", style); } else { this.$updateHighlightActiveLine(); + this.$updateHighlightGutterLine(); } if (this.$highlightSelectedWord) @@ -408,6 +416,7 @@ var Editor = function(renderer, session) { // Update the active line marker as due to folding changes the current // line range on the screen might have changed. this.$updateHighlightActiveLine(); + this.$updateHighlightGutterLine(); // TODO: This might be too much updating. Okay for now. this.renderer.updateFull(); }; @@ -573,7 +582,8 @@ var Editor = function(renderer, session) { this.$highlightActiveLine = true; this.setHighlightActiveLine = function(shouldHighlight) { - if (this.$highlightActiveLine == shouldHighlight) return; + if (this.$highlightActiveLine == shouldHighlight) + return; this.$highlightActiveLine = shouldHighlight; this.$updateHighlightActiveLine(); @@ -582,6 +592,19 @@ var Editor = function(renderer, session) { this.getHighlightActiveLine = function() { return this.$highlightActiveLine; }; + + this.$highlightGutterLine = true; + this.setHighlightGutterLine = function(shouldHighlightGutterLine) { + if (this.$highlightGutterLine == shouldHighlightGutterLine) + return; + + this.$highlightGutterLine = shouldHighlightGutterLine; + this.$updateHighlightGutterLine(); + }; + + this.getHighlightGutterLine = function() { + return this.$highlightGutterLine; + }; this.$highlightSelectedWord = true; this.setHighlightSelectedWord = function(shouldHighlight) {