parent
f7786930e9
commit
dfe918e339
2 changed files with 39 additions and 26 deletions
|
|
@ -375,14 +375,7 @@ var EditSession = function(text, mode) {
|
|||
token.start = c - token.value.length;
|
||||
return token;
|
||||
};
|
||||
|
||||
this.highlight = function(re) {
|
||||
if (!this.$searchHighlight) {
|
||||
var highlight = new SearchHighlight(null, "ace_selected-word", "text");
|
||||
this.$searchHighlight = this.addDynamicMarker(highlight);
|
||||
}
|
||||
this.$searchHighlight.setRegexp(re);
|
||||
}
|
||||
|
||||
/**
|
||||
* EditSession.setUndoManager(undoManager)
|
||||
* - undoManager (UndoManager): The new undo manager
|
||||
|
|
@ -736,6 +729,30 @@ var EditSession = function(text, mode) {
|
|||
return inFront ? this.$frontMarkers : this.$backMarkers;
|
||||
};
|
||||
|
||||
this.highlight = function(re) {
|
||||
if (!this.$searchHighlight) {
|
||||
var highlight = new SearchHighlight(null, "ace_selected-word", "text");
|
||||
this.$searchHighlight = this.addDynamicMarker(highlight);
|
||||
}
|
||||
this.$searchHighlight.setRegexp(re);
|
||||
}
|
||||
|
||||
// experimental
|
||||
this.highlightLines = function(startRow, endRow, clazz, inFront) {
|
||||
if (typeof endRow != "number") {
|
||||
clazz = endRow;
|
||||
endRow = startRow;
|
||||
}
|
||||
if (!clazz)
|
||||
clazz = "ace_step";
|
||||
|
||||
var range = new Range(startRow, 0, endRow, Infinity);
|
||||
|
||||
var id = this.addMarker(range, clazz, "fullLine", inFront);
|
||||
range.id = id;
|
||||
return range;
|
||||
},
|
||||
|
||||
/*
|
||||
* Error:
|
||||
* {
|
||||
|
|
|
|||
|
|
@ -481,28 +481,24 @@ var Editor = function(renderer, session) {
|
|||
this.$updateHighlightActiveLine = function() {
|
||||
var session = this.getSession();
|
||||
|
||||
if (session.$highlightLineMarker)
|
||||
session.removeMarker(session.$highlightLineMarker);
|
||||
|
||||
session.$highlightLineMarker = null;
|
||||
|
||||
var highlight;
|
||||
if (this.$highlightActiveLine) {
|
||||
var cursor = this.getCursorPosition();
|
||||
var foldLine = this.session.getFoldLine(cursor.row);
|
||||
if ((this.$selectionStyle != "line" || !this.selection.isMultiLine()))
|
||||
highlight = this.getCursorPosition();
|
||||
}
|
||||
|
||||
if ((this.getSelectionStyle() != "line" || !this.selection.isMultiLine())) {
|
||||
var range;
|
||||
if (foldLine) {
|
||||
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");
|
||||
}
|
||||
if (session.$highlightLineMarker && !highlight) {
|
||||
session.removeMarker(session.$highlightLineMarker.id);
|
||||
session.$highlightLineMarker = null;
|
||||
} else if (!session.$highlightLineMarker && highlight) {
|
||||
session.$highlightLineMarker = session.highlightLines(highlight.row, highlight.row, "ace_active-line");
|
||||
} else if (highlight) {
|
||||
session.$highlightLineMarker.start.row = highlight.row;
|
||||
session.$highlightLineMarker.end.row = highlight.row;
|
||||
session._emit("changeBackMarker");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.onSelectionChange = function(e) {
|
||||
var session = this.session;
|
||||
|
||||
|
|
@ -2126,4 +2122,4 @@ var Editor = function(renderer, session) {
|
|||
|
||||
|
||||
exports.Editor = Editor;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue