prefix privates with $ instead of _
This commit is contained in:
parent
1b37c1c6f2
commit
cd27cb7554
13 changed files with 172 additions and 172 deletions
|
|
@ -8,7 +8,7 @@ ace.BackgroundTokenizer = function(tokenizer) {
|
|||
this.tokenizer = tokenizer;
|
||||
|
||||
var self = this;
|
||||
this._worker = function() {
|
||||
this.$worker = function() {
|
||||
if (!self.running) { return; }
|
||||
|
||||
var workerStart = new Date();
|
||||
|
|
@ -28,7 +28,7 @@ ace.BackgroundTokenizer = function(tokenizer) {
|
|||
processedLines += 1;
|
||||
if ((processedLines % 30 == 0) && (new Date() - workerStart) > 20) {
|
||||
self.fireUpdateEvent(startLine, self.currentLine);
|
||||
return setTimeout(self._worker, 10);
|
||||
return setTimeout(self.$worker, 10);
|
||||
}
|
||||
|
||||
self.currentLine++;
|
||||
|
|
@ -77,7 +77,7 @@ ace.BackgroundTokenizer = function(tokenizer) {
|
|||
if (!this.running) {
|
||||
clearTimeout(this.running);
|
||||
// pretty long delay to prevent the tokenizer from interfering with the user
|
||||
this.running = setTimeout(this._worker, 200);
|
||||
this.running = setTimeout(this.$worker, 200);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -86,14 +86,14 @@ ace.BackgroundTokenizer = function(tokenizer) {
|
|||
};
|
||||
|
||||
this.getTokens = function(row) {
|
||||
return this._tokenizeRow(row).tokens;
|
||||
return this.$tokenizeRow(row).tokens;
|
||||
};
|
||||
|
||||
this.getState = function(row) {
|
||||
return this._tokenizeRow(row).state;
|
||||
return this.$tokenizeRow(row).state;
|
||||
};
|
||||
|
||||
this._tokenizeRow = function(row) {
|
||||
this.$tokenizeRow = function(row) {
|
||||
if (!this.lines[row]) {
|
||||
var state = "start";
|
||||
if (row > 0 && this.lines[row - 1]) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ ace.provide("ace.Document");
|
|||
ace.Document = function(text, mode) {
|
||||
this.$initEvents();
|
||||
|
||||
this.lines = this._split(text);
|
||||
this.lines = this.$split(text);
|
||||
this.modified = true;
|
||||
this.selection = new ace.Selection(this);
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ ace.Document = function(text, mode) {
|
|||
|
||||
ace.implement(this, ace.MEventEmitter);
|
||||
|
||||
this._split = function(text) {
|
||||
this.$split = function(text) {
|
||||
return text.split(/\r\n|\r|\n/);
|
||||
};
|
||||
|
||||
|
|
@ -44,54 +44,54 @@ ace.Document = function(text, mode) {
|
|||
return "\t";
|
||||
};
|
||||
|
||||
this._useSoftTabs = false;
|
||||
this.$useSoftTabs = false;
|
||||
this.setUseSoftTabs = function(useSoftTabs) {
|
||||
if (this._useSoftTabs === useSoftTabs) return;
|
||||
if (this.$useSoftTabs === useSoftTabs) return;
|
||||
|
||||
this._useSoftTabs = useSoftTabs;
|
||||
this.$useSoftTabs = useSoftTabs;
|
||||
};
|
||||
|
||||
this.getUseSoftTabs = function() {
|
||||
return this._useSoftTabs;
|
||||
return this.$useSoftTabs;
|
||||
};
|
||||
|
||||
this._tabSize = 4;
|
||||
this.$tabSize = 4;
|
||||
this.setTabSize = function(tabSize) {
|
||||
if (this._tabSize === tabSize) return;
|
||||
if (this.$tabSize === tabSize) return;
|
||||
|
||||
this._tabSize = tabSize;
|
||||
this.$tabSize = tabSize;
|
||||
this.$dispatchEvent("changeTabSize");
|
||||
};
|
||||
|
||||
this.getTabSize = function() {
|
||||
return this._tabSize;
|
||||
return this.$tabSize;
|
||||
};
|
||||
|
||||
this._mode = null;
|
||||
this.$mode = null;
|
||||
this.setMode = function(mode) {
|
||||
if (this._mode === mode) return;
|
||||
if (this.$mode === mode) return;
|
||||
|
||||
this._mode = mode;
|
||||
this.$mode = mode;
|
||||
this.$dispatchEvent("changeMode");
|
||||
};
|
||||
|
||||
this.getMode = function() {
|
||||
if (!this._mode) {
|
||||
this._mode = new ace.mode.Text();
|
||||
if (!this.$mode) {
|
||||
this.$mode = new ace.mode.Text();
|
||||
}
|
||||
return this._mode;
|
||||
return this.$mode;
|
||||
};
|
||||
|
||||
this._scrollTop = 0;
|
||||
this.$scrollTop = 0;
|
||||
this.setScrollTopRow = function(scrollTopRow) {
|
||||
if (this._scrollTop === scrollTopRow) return;
|
||||
if (this.$scrollTop === scrollTopRow) return;
|
||||
|
||||
this._scrollTop = scrollTopRow;
|
||||
this.$scrollTop = scrollTopRow;
|
||||
this.$dispatchEvent("changeScrollTop");
|
||||
};
|
||||
|
||||
this.getScrollTopRow = function() {
|
||||
return this._scrollTop;
|
||||
return this.$scrollTop;
|
||||
};
|
||||
|
||||
this.getWidth = function() {
|
||||
|
|
@ -146,13 +146,13 @@ ace.Document = function(text, mode) {
|
|||
}
|
||||
|
||||
if (match[1]) {
|
||||
return this._findClosingBracket(match[1], position);
|
||||
return this.$findClosingBracket(match[1], position);
|
||||
} else {
|
||||
return this._findOpeningBracket(match[2], position);
|
||||
return this.$findOpeningBracket(match[2], position);
|
||||
}
|
||||
};
|
||||
|
||||
this._brackets = {
|
||||
this.$brackets = {
|
||||
")": "(",
|
||||
"(": ")",
|
||||
"]": "[",
|
||||
|
|
@ -161,8 +161,8 @@ ace.Document = function(text, mode) {
|
|||
"}": "{"
|
||||
};
|
||||
|
||||
this._findOpeningBracket = function(bracket, position) {
|
||||
var openBracket = this._brackets[bracket];
|
||||
this.$findOpeningBracket = function(bracket, position) {
|
||||
var openBracket = this.$brackets[bracket];
|
||||
|
||||
var column = position.column - 2;
|
||||
var row = position.row;
|
||||
|
|
@ -193,8 +193,8 @@ ace.Document = function(text, mode) {
|
|||
return null;
|
||||
};
|
||||
|
||||
this._findClosingBracket = function(bracket, position) {
|
||||
var closingBracket = this._brackets[bracket];
|
||||
this.$findClosingBracket = function(bracket, position) {
|
||||
var closingBracket = this.$brackets[bracket];
|
||||
|
||||
var column = position.column;
|
||||
var row = position.row;
|
||||
|
|
@ -227,24 +227,24 @@ ace.Document = function(text, mode) {
|
|||
};
|
||||
|
||||
this.insert = function(position, text) {
|
||||
var end = this._insert(position, text);
|
||||
var end = this.$insert(position, text);
|
||||
this.fireChangeEvent(position.row, position.row == end.row ? position.row
|
||||
: undefined);
|
||||
return end;
|
||||
};
|
||||
|
||||
this._insertLines = function(row, lines) {
|
||||
this.$insertLines = function(row, lines) {
|
||||
var args = [row, 0];
|
||||
args.push.apply(args, lines);
|
||||
this.lines.splice.apply(this.lines, args);
|
||||
},
|
||||
|
||||
this._insert = function(position, text) {
|
||||
this.$insert = function(position, text) {
|
||||
this.modified = true;
|
||||
|
||||
var newLines = this._split(text);
|
||||
var newLines = this.$split(text);
|
||||
|
||||
if (this._isNewLine(text)) {
|
||||
if (this.$isNewLine(text)) {
|
||||
var line = this.lines[position.row] || "";
|
||||
this.lines[position.row] = line.substring(0, position.column);
|
||||
this.lines.splice(position.row + 1, 0, line.substring(position.column));
|
||||
|
|
@ -273,7 +273,7 @@ ace.Document = function(text, mode) {
|
|||
+ line.substring(position.column);
|
||||
|
||||
if (newLines.length > 2) {
|
||||
this._insertLines(position.row + 1, newLines.slice(1, -1));
|
||||
this.$insertLines(position.row + 1, newLines.slice(1, -1));
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
@ -283,12 +283,12 @@ ace.Document = function(text, mode) {
|
|||
}
|
||||
};
|
||||
|
||||
this._isNewLine = function(text) {
|
||||
this.$isNewLine = function(text) {
|
||||
return (text == "\r\n" || text == "\r" || text == "\n");
|
||||
};
|
||||
|
||||
this.remove = function(range) {
|
||||
this._remove(range);
|
||||
this.$remove(range);
|
||||
|
||||
this.fireChangeEvent(range.start.row,
|
||||
range.end.row == range.start.row ? range.start.row
|
||||
|
|
@ -296,7 +296,7 @@ ace.Document = function(text, mode) {
|
|||
return range.start;
|
||||
};
|
||||
|
||||
this._remove = function(range) {
|
||||
this.$remove = function(range) {
|
||||
this.modified = true;
|
||||
|
||||
var firstRow = range.start.row;
|
||||
|
|
@ -311,9 +311,9 @@ ace.Document = function(text, mode) {
|
|||
};
|
||||
|
||||
this.replace = function(range, text) {
|
||||
this._remove(range);
|
||||
this.$remove(range);
|
||||
if (text) {
|
||||
var end = this._insert(range.start, text);
|
||||
var end = this.$insert(range.start, text);
|
||||
}
|
||||
else {
|
||||
end = range.start;
|
||||
|
|
@ -356,7 +356,7 @@ ace.Document = function(text, mode) {
|
|||
if (firstRow <= 0) return 0;
|
||||
|
||||
var removed = this.lines.splice(firstRow, lastRow-firstRow+1);
|
||||
this._insertLines(firstRow-1, removed);
|
||||
this.$insertLines(firstRow-1, removed);
|
||||
|
||||
this.fireChangeEvent(firstRow-1, lastRow);
|
||||
return -1;
|
||||
|
|
@ -366,18 +366,18 @@ ace.Document = function(text, mode) {
|
|||
if (lastRow >= this.lines.length-1) return 0;
|
||||
|
||||
var removed = this.lines.splice(firstRow, lastRow-firstRow+1);
|
||||
this._insertLines(firstRow+1, removed);
|
||||
this.$insertLines(firstRow+1, removed);
|
||||
|
||||
this.fireChangeEvent(firstRow, lastRow+1);
|
||||
return 1;
|
||||
};
|
||||
|
||||
this.duplicateLines = function(firstRow, lastRow) {
|
||||
var firstRow = this._clipRowToDocument(firstRow);
|
||||
var lastRow = this._clipRowToDocument(lastRow);
|
||||
var firstRow = this.$clipRowToDocument(firstRow);
|
||||
var lastRow = this.$clipRowToDocument(lastRow);
|
||||
|
||||
var lines = this.getLines(firstRow, lastRow);
|
||||
this._insertLines(firstRow, lines);
|
||||
this.$insertLines(firstRow, lines);
|
||||
|
||||
var addedRows = lastRow - firstRow + 1;
|
||||
this.fireChangeEvent(firstRow, lastRow+addedRows);
|
||||
|
|
@ -385,7 +385,7 @@ ace.Document = function(text, mode) {
|
|||
return addedRows;
|
||||
};
|
||||
|
||||
this._clipRowToDocument = function(row) {
|
||||
this.$clipRowToDocument = function(row) {
|
||||
return Math.max(0, Math.min(row, this.lines.length-1));
|
||||
};
|
||||
|
||||
|
|
|
|||
118
src/Editor.js
118
src/Editor.js
|
|
@ -19,9 +19,9 @@ ace.Editor = function(renderer, doc) {
|
|||
ace.addTripleClickListener(mouseTarget, ace.bind(this.onMouseTripleClick, this));
|
||||
ace.addMouseWheelListener(mouseTarget, ace.bind(this.onMouseWheel, this));
|
||||
|
||||
this._selectionMarker = null;
|
||||
this._highlightLineMarker = null;
|
||||
this._blockScrolling = false;
|
||||
this.$selectionMarker = null;
|
||||
this.$highlightLineMarker = null;
|
||||
this.$blockScrolling = false;
|
||||
|
||||
this.setDocument(doc || new ace.Document(""));
|
||||
};
|
||||
|
|
@ -32,36 +32,36 @@ ace.Editor = function(renderer, doc) {
|
|||
if (this.doc == doc) return;
|
||||
|
||||
if (this.doc) {
|
||||
this.doc.removeEventListener("change", this._onDocumentChange);
|
||||
this.doc.removeEventListener("changeMode", this._onDocumentModeChange);
|
||||
this.doc.removeEventListener("changeTabSize", this._onDocumentChangeTabSize);
|
||||
this.doc.removeEventListener("change", this.$onDocumentChange);
|
||||
this.doc.removeEventListener("changeMode", this.$onDocumentModeChange);
|
||||
this.doc.removeEventListener("changeTabSize", this.$onDocumentChangeTabSize);
|
||||
|
||||
var selection = this.doc.getSelection();
|
||||
this.selection.removeEventListener("changeCursor", this._onCursorChange);
|
||||
this.selection.removeEventListener("changeSelection", this._onSelectionChange);
|
||||
this.selection.removeEventListener("changeCursor", this.$onCursorChange);
|
||||
this.selection.removeEventListener("changeSelection", this.$onSelectionChange);
|
||||
|
||||
this.doc.setScrollTopRow(this.renderer.getScrollTopRow());
|
||||
}
|
||||
|
||||
this.doc = doc;
|
||||
|
||||
this._onDocumentChange = ace.bind(this.onDocumentChange, this);
|
||||
doc.addEventListener("change", this._onDocumentChange);
|
||||
this.$onDocumentChange = ace.bind(this.onDocumentChange, this);
|
||||
doc.addEventListener("change", this.$onDocumentChange);
|
||||
this.renderer.setDocument(doc);
|
||||
|
||||
this._onDocumentModeChange = ace.bind(this.onDocumentModeChange, this);
|
||||
doc.addEventListener("changeMode", this._onDocumentModeChange);
|
||||
this.$onDocumentModeChange = ace.bind(this.onDocumentModeChange, this);
|
||||
doc.addEventListener("changeMode", this.$onDocumentModeChange);
|
||||
|
||||
this._onDocumentChangeTabSize = ace.bind(this.renderer.draw, this.renderer);
|
||||
doc.addEventListener("changeTabSize", this._onDocumentChangeTabSize);
|
||||
this.$onDocumentChangeTabSize = ace.bind(this.renderer.draw, this.renderer);
|
||||
doc.addEventListener("changeTabSize", this.$onDocumentChangeTabSize);
|
||||
|
||||
this.selection = doc.getSelection();
|
||||
|
||||
this._onCursorChange = ace.bind(this.onCursorChange, this);
|
||||
this.selection.addEventListener("changeCursor", this._onCursorChange);
|
||||
this.$onCursorChange = ace.bind(this.onCursorChange, this);
|
||||
this.selection.addEventListener("changeCursor", this.$onCursorChange);
|
||||
|
||||
this._onSelectionChange = ace.bind(this.onSelectionChange, this);
|
||||
this.selection.addEventListener("changeSelection", this._onSelectionChange);
|
||||
this.$onSelectionChange = ace.bind(this.onSelectionChange, this);
|
||||
this.selection.addEventListener("changeSelection", this.$onSelectionChange);
|
||||
|
||||
this.onDocumentModeChange();
|
||||
this.bgTokenizer.setLines(this.doc.lines);
|
||||
|
|
@ -84,21 +84,21 @@ ace.Editor = function(renderer, doc) {
|
|||
this.renderer.onResize();
|
||||
};
|
||||
|
||||
this._highlightBrackets = function() {
|
||||
if (this._bracketHighlight) {
|
||||
this.renderer.removeMarker(this._bracketHighlight);
|
||||
this._bracketHighlight = null;
|
||||
this.$highlightBrackets = function() {
|
||||
if (this.$bracketHighlight) {
|
||||
this.renderer.removeMarker(this.$bracketHighlight);
|
||||
this.$bracketHighlight = null;
|
||||
}
|
||||
|
||||
if (this._highlightPending) {
|
||||
if (this.$highlightPending) {
|
||||
return;
|
||||
}
|
||||
|
||||
// perform highlight async to not block the browser during navigation
|
||||
var self = this;
|
||||
this._highlightPending = true;
|
||||
this.$highlightPending = true;
|
||||
setTimeout(function() {
|
||||
self._highlightPending = false;
|
||||
self.$highlightPending = false;
|
||||
|
||||
var pos = self.doc.findMatchingBracket(self.getCursorPosition());
|
||||
if (pos) {
|
||||
|
|
@ -109,7 +109,7 @@ ace.Editor = function(renderer, doc) {
|
|||
column: pos.column+1
|
||||
}
|
||||
};
|
||||
self._bracketHighlight = self.renderer.addMarker(range, "bracket");
|
||||
self.$bracketHighlight = self.renderer.addMarker(range, "bracket");
|
||||
}
|
||||
}, 10);
|
||||
};
|
||||
|
|
@ -144,20 +144,20 @@ ace.Editor = function(renderer, doc) {
|
|||
};
|
||||
|
||||
this.onCursorChange = function() {
|
||||
this._highlightBrackets();
|
||||
this.$highlightBrackets();
|
||||
this.renderer.updateCursor(this.getCursorPosition());
|
||||
|
||||
if (!this._blockScrolling) {
|
||||
if (!this.$blockScrolling) {
|
||||
this.renderer.scrollCursorIntoView();
|
||||
}
|
||||
this._updateHighlightActiveLine();
|
||||
this.$updateHighlightActiveLine();
|
||||
};
|
||||
|
||||
this._updateHighlightActiveLine = function() {
|
||||
if (this._highlightLineMarker) {
|
||||
this.renderer.removeMarker(this._highlightLineMarker);
|
||||
this.$updateHighlightActiveLine = function() {
|
||||
if (this.$highlightLineMarker) {
|
||||
this.renderer.removeMarker(this.$highlightLineMarker);
|
||||
}
|
||||
this._highlightLineMarker = null;
|
||||
this.$highlightLineMarker = null;
|
||||
|
||||
if (this.getHighlightActiveLine() && !this.selection.isMultiLine()) {
|
||||
var cursor = this.getCursorPosition();
|
||||
|
|
@ -171,20 +171,20 @@ ace.Editor = function(renderer, doc) {
|
|||
column: 0
|
||||
}
|
||||
};
|
||||
this._highlightLineMarker = this.renderer.addMarker(range, "active_line", "line");
|
||||
this.$highlightLineMarker = this.renderer.addMarker(range, "active_line", "line");
|
||||
}
|
||||
};
|
||||
|
||||
this.onSelectionChange = function() {
|
||||
if (this._selectionMarker) {
|
||||
this.renderer.removeMarker(this._selectionMarker);
|
||||
if (this.$selectionMarker) {
|
||||
this.renderer.removeMarker(this.$selectionMarker);
|
||||
}
|
||||
this._selectionMarker = null;
|
||||
this.$selectionMarker = null;
|
||||
|
||||
if (!this.selection.isEmpty()) {
|
||||
var range = this.selection.getRange();
|
||||
var style = this.getSelectionStyle();
|
||||
this._selectionMarker = this.renderer.addMarker(range, "selection", style);
|
||||
this.$selectionMarker = this.renderer.addMarker(range, "selection", style);
|
||||
}
|
||||
|
||||
this.onCursorChange();
|
||||
|
|
@ -314,28 +314,28 @@ ace.Editor = function(renderer, doc) {
|
|||
this.renderer.scrollCursorIntoView();
|
||||
};
|
||||
|
||||
this._selectionStyle = "line";
|
||||
this.$selectionStyle = "line";
|
||||
this.setSelectionStyle = function(style) {
|
||||
if (this._selectionStyle == style) return;
|
||||
if (this.$selectionStyle == style) return;
|
||||
|
||||
this._selectionStyle = style;
|
||||
this.$selectionStyle = style;
|
||||
this.onSelectionChange();
|
||||
};
|
||||
|
||||
this.getSelectionStyle = function() {
|
||||
return this._selectionStyle;
|
||||
return this.$selectionStyle;
|
||||
};
|
||||
|
||||
this._highlightActiveLine = true;
|
||||
this.$highlightActiveLine = true;
|
||||
this.setHighlightActiveLine = function(shouldHighlight) {
|
||||
if (this._highlightActiveLine == shouldHighlight) return;
|
||||
if (this.$highlightActiveLine == shouldHighlight) return;
|
||||
|
||||
this._highlightActiveLine = shouldHighlight;
|
||||
this._updateHighlightActiveLine();
|
||||
this.$highlightActiveLine = shouldHighlight;
|
||||
this.$updateHighlightActiveLine();
|
||||
};
|
||||
|
||||
this.getHighlightActiveLine = function() {
|
||||
return this._highlightActiveLine;
|
||||
return this.$highlightActiveLine;
|
||||
};
|
||||
|
||||
this.removeRight = function() {
|
||||
|
|
@ -369,7 +369,7 @@ ace.Editor = function(renderer, doc) {
|
|||
};
|
||||
|
||||
this.toggleCommentLines = function() {
|
||||
var rows = this._getSelectedRows();
|
||||
var rows = this.$getSelectedRows();
|
||||
|
||||
var range = {
|
||||
start: {
|
||||
|
|
@ -388,7 +388,7 @@ ace.Editor = function(renderer, doc) {
|
|||
};
|
||||
|
||||
this.removeLines = function() {
|
||||
var rows = this._getSelectedRows();
|
||||
var rows = this.$getSelectedRows();
|
||||
this.selection.setSelectionAnchor(rows.last+1, 0);
|
||||
this.selection.selectTo(rows.first, 0);
|
||||
|
||||
|
|
@ -397,44 +397,44 @@ ace.Editor = function(renderer, doc) {
|
|||
};
|
||||
|
||||
this.moveLinesDown = function() {
|
||||
this._moveLines(function(firstRow, lastRow) {
|
||||
this.$moveLines(function(firstRow, lastRow) {
|
||||
return this.doc.moveLinesDown(firstRow, lastRow);
|
||||
});
|
||||
};
|
||||
|
||||
this.moveLinesUp = function() {
|
||||
this._moveLines(function(firstRow, lastRow) {
|
||||
this.$moveLines(function(firstRow, lastRow) {
|
||||
return this.doc.moveLinesUp(firstRow, lastRow);
|
||||
});
|
||||
};
|
||||
|
||||
this.copyLinesUp = function() {
|
||||
this._moveLines(function(firstRow, lastRow) {
|
||||
this.$moveLines(function(firstRow, lastRow) {
|
||||
this.doc.duplicateLines(firstRow, lastRow);
|
||||
return 0;
|
||||
});
|
||||
};
|
||||
|
||||
this.copyLinesDown = function() {
|
||||
this._moveLines(function(firstRow, lastRow) {
|
||||
this.$moveLines(function(firstRow, lastRow) {
|
||||
return this.doc.duplicateLines(firstRow, lastRow);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
this._moveLines = function(mover) {
|
||||
var rows = this._getSelectedRows();
|
||||
this.$moveLines = function(mover) {
|
||||
var rows = this.$getSelectedRows();
|
||||
|
||||
var linesMoved = mover.call(this, rows.first, rows.last);
|
||||
|
||||
var selection = this.selection;
|
||||
selection.setSelectionAnchor(rows.last+linesMoved+1, 0);
|
||||
selection._moveSelection(function() {
|
||||
selection.$moveSelection(function() {
|
||||
selection.moveCursorTo(rows.first+linesMoved, 0);
|
||||
});
|
||||
};
|
||||
|
||||
this._getSelectedRows = function() {
|
||||
this.$getSelectedRows = function() {
|
||||
var range = this.getSelectionRange();
|
||||
var firstRow = range.start.row;
|
||||
var lastRow = range.end.row;
|
||||
|
|
@ -526,9 +526,9 @@ ace.Editor = function(renderer, doc) {
|
|||
|
||||
|
||||
this.gotoLine = function(lineNumber) {
|
||||
this._blockScrolling = true;
|
||||
this.$blockScrolling = true;
|
||||
this.moveCursorTo(lineNumber-1, 0);
|
||||
this._blockScrolling = false;
|
||||
this.$blockScrolling = false;
|
||||
|
||||
if (!this.isRowVisible(this.getCursorPosition().row)) {
|
||||
this.scrollToRow(lineNumber - 1 - Math.floor(this.getVisibleRowCount() / 2));
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ ace.provide("ace.MEventEmitter");
|
|||
ace.MEventEmitter = function() {
|
||||
|
||||
this.$initEvents = function() {
|
||||
this._eventRegistry = {};
|
||||
this.$eventRegistry = {};
|
||||
};
|
||||
|
||||
this.$dispatchEvent = function(eventName, e) {
|
||||
var listeners = this._eventRegistry[eventName];
|
||||
var listeners = this.$eventRegistry[eventName];
|
||||
if (!listeners || !listeners.length) return;
|
||||
|
||||
var e = e || {};
|
||||
|
|
@ -19,9 +19,9 @@ ace.MEventEmitter = function() {
|
|||
};
|
||||
|
||||
this.addEventListener = function(eventName, callback) {
|
||||
var listeners = this._eventRegistry[eventName];
|
||||
var listeners = this.$eventRegistry[eventName];
|
||||
if (!listeners) {
|
||||
var listeners = this._eventRegistry[eventName] = [];
|
||||
var listeners = this.$eventRegistry[eventName] = [];
|
||||
}
|
||||
if (ace.arrayIndexOf(listeners, callback) == -1) {
|
||||
listeners.push(callback);
|
||||
|
|
@ -29,7 +29,7 @@ ace.MEventEmitter = function() {
|
|||
};
|
||||
|
||||
this.removeEventListener = function(eventName, callback) {
|
||||
var listeners = this._eventRegistry[eventName];
|
||||
var listeners = this.$eventRegistry[eventName];
|
||||
if (!listeners) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,19 +44,19 @@ ace.Selection = function(doc) {
|
|||
this.setSelectionAnchor = function(row, column) {
|
||||
this.clearSelection();
|
||||
|
||||
this.selectionAnchor = this._clipPositionToDocument(row, column);
|
||||
this.selectionAnchor = this.$clipPositionToDocument(row, column);
|
||||
};
|
||||
|
||||
this.getSelectionAnchor = function() {
|
||||
if (this.selectionAnchor) {
|
||||
return this._clone(this.selectionAnchor);
|
||||
return this.$clone(this.selectionAnchor);
|
||||
} else {
|
||||
return this._clone(this.selectionLead);
|
||||
return this.$clone(this.selectionLead);
|
||||
}
|
||||
};
|
||||
|
||||
this.getSelectionLead = function() {
|
||||
return this._clone(this.selectionLead);
|
||||
return this.$clone(this.selectionLead);
|
||||
};
|
||||
|
||||
this.shiftSelection = function(columns) {
|
||||
|
|
@ -69,7 +69,7 @@ ace.Selection = function(doc) {
|
|||
var lead = this.getSelectionLead();
|
||||
|
||||
this.setSelectionAnchor(anchor.row, anchor.column + columns);
|
||||
this._moveSelection(function() {
|
||||
this.$moveSelection(function() {
|
||||
this.moveCursorTo(lead.row, lead.column + columns);
|
||||
});
|
||||
};
|
||||
|
|
@ -103,14 +103,14 @@ ace.Selection = function(doc) {
|
|||
var lastRow = this.doc.getLength() - 1;
|
||||
this.setSelectionAnchor(lastRow, this.doc.getLine(lastRow).length);
|
||||
|
||||
this._moveSelection(function() {
|
||||
this.$moveSelection(function() {
|
||||
this.moveCursorTo(0, 0);
|
||||
});
|
||||
};
|
||||
|
||||
this._moveSelection = function(mover) {
|
||||
this.$moveSelection = function(mover) {
|
||||
if (!this.selectionAnchor) {
|
||||
this.selectionAnchor = this._clone(this.selectionLead);
|
||||
this.selectionAnchor = this.$clone(this.selectionLead);
|
||||
}
|
||||
|
||||
mover.call(this);
|
||||
|
|
@ -118,39 +118,39 @@ ace.Selection = function(doc) {
|
|||
};
|
||||
|
||||
this.selectTo = function(row, column) {
|
||||
this._moveSelection(function() {
|
||||
this.$moveSelection(function() {
|
||||
this.moveCursorTo(row, column);
|
||||
});
|
||||
};
|
||||
|
||||
this.selectToPosition = function(pos) {
|
||||
this._moveSelection(function() {
|
||||
this.$moveSelection(function() {
|
||||
this.moveCursorToPosition(pos);
|
||||
});
|
||||
};
|
||||
|
||||
this.selectUp = function() {
|
||||
this._moveSelection(this.moveCursorUp);
|
||||
this.$moveSelection(this.moveCursorUp);
|
||||
};
|
||||
|
||||
this.selectDown = function() {
|
||||
this._moveSelection(this.moveCursorDown);
|
||||
this.$moveSelection(this.moveCursorDown);
|
||||
};
|
||||
|
||||
this.selectRight = function() {
|
||||
this._moveSelection(this.moveCursorRight);
|
||||
this.$moveSelection(this.moveCursorRight);
|
||||
};
|
||||
|
||||
this.selectLeft = function() {
|
||||
this._moveSelection(this.moveCursorLeft);
|
||||
this.$moveSelection(this.moveCursorLeft);
|
||||
};
|
||||
|
||||
this.selectLineStart = function() {
|
||||
this._moveSelection(this.moveCursorLineStart);
|
||||
this.$moveSelection(this.moveCursorLineStart);
|
||||
};
|
||||
|
||||
this.selectLineEnd = function() {
|
||||
this._moveSelection(this.moveCursorLineEnd);
|
||||
this.$moveSelection(this.moveCursorLineEnd);
|
||||
};
|
||||
|
||||
this.selectPageDown = function() {
|
||||
|
|
@ -158,7 +158,7 @@ ace.Selection = function(doc) {
|
|||
|
||||
this.scrollPageDown();
|
||||
|
||||
this._moveSelection(function() {
|
||||
this.$moveSelection(function() {
|
||||
this.moveCursorTo(row, this.selectionLead.column);
|
||||
});
|
||||
};
|
||||
|
|
@ -169,28 +169,28 @@ ace.Selection = function(doc) {
|
|||
|
||||
this.scrollPageUp();
|
||||
|
||||
this._moveSelection(function() {
|
||||
this.$moveSelection(function() {
|
||||
this.moveCursorTo(row, this.selectionLead.column);
|
||||
});
|
||||
};
|
||||
|
||||
this.selectFileEnd = function() {
|
||||
this._moveSelection(this.moveCursorFileEnd);
|
||||
this.$moveSelection(this.moveCursorFileEnd);
|
||||
};
|
||||
|
||||
this.selectFileStart = function() {
|
||||
this._moveSelection(this.moveCursorFileStart);
|
||||
this.$moveSelection(this.moveCursorFileStart);
|
||||
};
|
||||
|
||||
this.tokenRe = /^[\w\d]+/g;
|
||||
this.nonTokenRe = /^[^\w\d]+/g;
|
||||
|
||||
this.selectWordRight = function() {
|
||||
this._moveSelection(this.moveCursorWordRight);
|
||||
this.$moveSelection(this.moveCursorWordRight);
|
||||
};
|
||||
|
||||
this.selectWordLeft = function() {
|
||||
this._moveSelection(this.moveCursorWordLeft);
|
||||
this.$moveSelection(this.moveCursorWordLeft);
|
||||
};
|
||||
|
||||
this.selectWord = function() {
|
||||
|
|
@ -225,14 +225,14 @@ ace.Selection = function(doc) {
|
|||
}
|
||||
|
||||
this.setSelectionAnchor(cursor.row, start);
|
||||
this._moveSelection(function() {
|
||||
this.$moveSelection(function() {
|
||||
this.moveCursorTo(cursor.row, end);
|
||||
});
|
||||
};
|
||||
|
||||
this.selectLine = function() {
|
||||
this.setSelectionAnchor(this.selectionLead.row, 0);
|
||||
this._moveSelection(function() {
|
||||
this.$moveSelection(function() {
|
||||
this.moveCursorTo(this.selectionLead.row + 1, 0);
|
||||
});
|
||||
};
|
||||
|
|
@ -349,7 +349,7 @@ ace.Selection = function(doc) {
|
|||
};
|
||||
|
||||
this.moveCursorTo = function(row, column) {
|
||||
this.selectionLead = this._clipPositionToDocument(row, column);
|
||||
this.selectionLead = this.$clipPositionToDocument(row, column);
|
||||
this.updateCursor();
|
||||
};
|
||||
|
||||
|
|
@ -357,7 +357,7 @@ ace.Selection = function(doc) {
|
|||
this.moveCursorBy(-1, 0);
|
||||
};
|
||||
|
||||
this._clipPositionToDocument = function(row, column) {
|
||||
this.$clipPositionToDocument = function(row, column) {
|
||||
var pos = {};
|
||||
|
||||
if (row >= this.doc.getLength()) {
|
||||
|
|
@ -376,7 +376,7 @@ ace.Selection = function(doc) {
|
|||
return pos;
|
||||
};
|
||||
|
||||
this._clone = function(pos) {
|
||||
this.$clone = function(pos) {
|
||||
return {
|
||||
row: pos.row,
|
||||
column: pos.column
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ ace.VirtualRenderer = function(container) {
|
|||
this.scroller.style.width = Math.max(0, width - gutterWidth - this.scrollBar.getWidth()) + "px";
|
||||
|
||||
if (this.doc) {
|
||||
this._updateScrollBar();
|
||||
this.$updateScrollBar();
|
||||
this.scrollToY(this.getScrollTop());
|
||||
this.draw();
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ ace.VirtualRenderer = function(container) {
|
|||
this.scrollToY(e.data);
|
||||
};
|
||||
|
||||
this._updateScrollBar = function() {
|
||||
this.$updateScrollBar = function() {
|
||||
this.scrollBar.setInnerHeight(this.doc.getLength() * this.lineHeight);
|
||||
this.scrollBar.setScrollTop(this.scrollTop);
|
||||
};
|
||||
|
|
@ -146,7 +146,7 @@ ace.VirtualRenderer = function(container) {
|
|||
this.gutterLayer.element.style.height = minHeight + "px";
|
||||
this.gutterLayer.update(layerConfig);
|
||||
|
||||
this._updateScrollBar();
|
||||
this.$updateScrollBar();
|
||||
};
|
||||
|
||||
this.addMarker = function(range, clazz, type) {
|
||||
|
|
@ -215,7 +215,7 @@ ace.VirtualRenderer = function(container) {
|
|||
|
||||
if (this.scrollTop !== scrollTop) {
|
||||
this.scrollTop = scrollTop;
|
||||
this._updateScrollBar();
|
||||
this.$updateScrollBar();
|
||||
this.draw();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ ace.layer.Marker = function(parentEl) {
|
|||
parentEl.appendChild(this.element);
|
||||
|
||||
this.markers = {};
|
||||
this._markerId = 1;
|
||||
this.$markerId = 1;
|
||||
};
|
||||
|
||||
(function() {
|
||||
|
|
@ -16,7 +16,7 @@ ace.layer.Marker = function(parentEl) {
|
|||
};
|
||||
|
||||
this.addMarker = function(range, clazz, type) {
|
||||
var id = this._markerId++;
|
||||
var id = this.$markerId++;
|
||||
this.markers[id] = {
|
||||
range : range,
|
||||
type : type || "line",
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ ace.layer.Text = function(parentEl) {
|
|||
this.element.className = "layer text-layer";
|
||||
parentEl.appendChild(this.element);
|
||||
|
||||
this._measureSizes();
|
||||
this._tabString = " ";
|
||||
this.$measureSizes();
|
||||
this.$tabString = " ";
|
||||
};
|
||||
|
||||
(function() {
|
||||
|
|
@ -23,7 +23,7 @@ ace.layer.Text = function(parentEl) {
|
|||
return this.characterWidth;
|
||||
};
|
||||
|
||||
this._measureSizes = function() {
|
||||
this.$measureSizes = function() {
|
||||
var measureNode = document.createElement("div");
|
||||
var style = measureNode.style;
|
||||
style.width = style.height = "auto";
|
||||
|
|
@ -45,7 +45,7 @@ ace.layer.Text = function(parentEl) {
|
|||
};
|
||||
|
||||
this.setTabSize = function(tabSize) {
|
||||
this._tabString = new Array(tabSize+1).join(" ");
|
||||
this.$tabString = new Array(tabSize+1).join(" ");
|
||||
};
|
||||
|
||||
this.updateLines = function(layerConfig, firstRow, lastRow) {
|
||||
|
|
@ -83,7 +83,7 @@ ace.layer.Text = function(parentEl) {
|
|||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
//.replace(/\t/g, "‣ ")
|
||||
.replace(/\t/g, this._tabString)
|
||||
.replace(/\t/g, this.$tabString)
|
||||
.replace(/\s/g, " ");
|
||||
|
||||
if (token.type !== "text") {
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ ace.mode.CssHighlightRules = function() {
|
|||
return re.join("");
|
||||
}
|
||||
|
||||
this._rules = {
|
||||
this.$rules = {
|
||||
"start" : [ {
|
||||
token : "comment", // multi line comment
|
||||
regex : "\\/\\*",
|
||||
|
|
@ -178,7 +178,7 @@ ace.mode.CssHighlightRules = function() {
|
|||
(function() {
|
||||
|
||||
this.getRules = function() {
|
||||
return this._rules;
|
||||
return this.$rules;
|
||||
};
|
||||
|
||||
}).call(ace.mode.CssHighlightRules.prototype);
|
||||
|
|
@ -3,8 +3,8 @@ ace.provide("ace.mode.Html");
|
|||
ace.mode.Html = function() {
|
||||
this.$tokenizer = new ace.Tokenizer(new ace.mode.HtmlHighlightRules().getRules());
|
||||
|
||||
this._js = new ace.mode.JavaScript();
|
||||
this._css = new ace.mode.Css();
|
||||
this.$js = new ace.mode.JavaScript();
|
||||
this.$css = new ace.mode.Css();
|
||||
};
|
||||
ace.inherits(ace.mode.Html, ace.mode.Text);
|
||||
|
||||
|
|
@ -13,12 +13,12 @@ ace.inherits(ace.mode.Html, ace.mode.Text);
|
|||
this.toggleCommentLines = function(doc, range, state) {
|
||||
var split = state.split("js-");
|
||||
if (!split[0] && split[1]) {
|
||||
return this._js.toggleCommentLines(doc, range, state);
|
||||
return this.$js.toggleCommentLines(doc, range, state);
|
||||
}
|
||||
|
||||
var split = state.split("css-");
|
||||
if (!split[0] && split[1]) {
|
||||
return this._css.toggleCommentLines(doc, range, state);
|
||||
return this.$css.toggleCommentLines(doc, range, state);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -27,12 +27,12 @@ ace.inherits(ace.mode.Html, ace.mode.Text);
|
|||
this.getNextLineIndent = function(line, state, tab) {
|
||||
var split = state.split("js-");
|
||||
if (!split[0] && split[1]) {
|
||||
return this._js.getNextLineIndent(line, split[1], tab);
|
||||
return this.$js.getNextLineIndent(line, split[1], tab);
|
||||
}
|
||||
|
||||
var split = state.split("css-");
|
||||
if (!split[0] && split[1]) {
|
||||
return this._css.getNextLineIndent(line, split[1], tab);
|
||||
return this.$css.getNextLineIndent(line, split[1], tab);
|
||||
}
|
||||
|
||||
return "";
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ ace.mode.HtmlHighlightRules = function() {
|
|||
// regexp must not have capturing parentheses
|
||||
// regexps are ordered -> the first match is used
|
||||
|
||||
this._rules = {
|
||||
this.$rules = {
|
||||
start : [ {
|
||||
token : "text",
|
||||
regex : "<\\!\\[CDATA\\[",
|
||||
|
|
@ -114,16 +114,16 @@ ace.mode.HtmlHighlightRules = function() {
|
|||
};
|
||||
|
||||
var jsRules = new ace.mode.JavaScriptHighlightRules().getRules();
|
||||
this._addRules(jsRules, "js-");
|
||||
this._rules["js-start"].unshift({
|
||||
this.$addRules(jsRules, "js-");
|
||||
this.$rules["js-start"].unshift({
|
||||
token: "text",
|
||||
regex: "<\\/(?=script)",
|
||||
next: "tag"
|
||||
});
|
||||
|
||||
var cssRules = new ace.mode.CssHighlightRules().getRules();
|
||||
this._addRules(cssRules, "css-");
|
||||
this._rules["css-start"].unshift({
|
||||
this.$addRules(cssRules, "css-");
|
||||
this.$rules["css-start"].unshift({
|
||||
token: "text",
|
||||
regex: "<\\/(?=style)",
|
||||
next: "tag"
|
||||
|
|
@ -132,7 +132,7 @@ ace.mode.HtmlHighlightRules = function() {
|
|||
|
||||
(function() {
|
||||
|
||||
this._addRules = function(rules, prefix) {
|
||||
this.$addRules = function(rules, prefix) {
|
||||
for (var key in rules) {
|
||||
var state = rules[key];
|
||||
for (var i=0; i<state.length; i++) {
|
||||
|
|
@ -141,12 +141,12 @@ ace.mode.HtmlHighlightRules = function() {
|
|||
rule.next = prefix + rule.next;
|
||||
}
|
||||
}
|
||||
this._rules[prefix + key] = state;
|
||||
this.$rules[prefix + key] = state;
|
||||
}
|
||||
};
|
||||
|
||||
this.getRules = function() {
|
||||
return this._rules;
|
||||
return this.$rules;
|
||||
};
|
||||
|
||||
}).call(ace.mode.HtmlHighlightRules.prototype);
|
||||
|
|
@ -31,7 +31,7 @@ ace.mode.JavaScriptHighlightRules = function() {
|
|||
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||
// regexps are ordered -> the first match is used
|
||||
|
||||
this._rules = {
|
||||
this.$rules = {
|
||||
"start" : [ {
|
||||
token : "comment",
|
||||
regex : "\\/\\/.*$"
|
||||
|
|
@ -130,7 +130,7 @@ ace.mode.JavaScriptHighlightRules = function() {
|
|||
(function() {
|
||||
|
||||
this.getRules = function() {
|
||||
return this._rules;
|
||||
return this.$rules;
|
||||
};
|
||||
|
||||
}).call(ace.mode.JavaScriptHighlightRules.prototype);
|
||||
|
|
@ -5,7 +5,7 @@ ace.mode.XmlHighlightRules = function() {
|
|||
// regexp must not have capturing parentheses
|
||||
// regexps are ordered -> the first match is used
|
||||
|
||||
this._rules = {
|
||||
this.$rules = {
|
||||
start : [ {
|
||||
token : "text",
|
||||
regex : "<\\!\\[CDATA\\[",
|
||||
|
|
@ -73,7 +73,7 @@ ace.mode.XmlHighlightRules = function() {
|
|||
(function() {
|
||||
|
||||
this.getRules = function() {
|
||||
return this._rules;
|
||||
return this.$rules;
|
||||
};
|
||||
|
||||
}).call(ace.mode.XmlHighlightRules.prototype);
|
||||
Loading…
Add table
Add a link
Reference in a new issue