prefix privates with $ instead of _

This commit is contained in:
Fabian Jakobs 2010-04-22 13:44:11 +02:00
commit cd27cb7554
13 changed files with 172 additions and 172 deletions

View file

@ -8,7 +8,7 @@ ace.BackgroundTokenizer = function(tokenizer) {
this.tokenizer = tokenizer; this.tokenizer = tokenizer;
var self = this; var self = this;
this._worker = function() { this.$worker = function() {
if (!self.running) { return; } if (!self.running) { return; }
var workerStart = new Date(); var workerStart = new Date();
@ -28,7 +28,7 @@ ace.BackgroundTokenizer = function(tokenizer) {
processedLines += 1; processedLines += 1;
if ((processedLines % 30 == 0) && (new Date() - workerStart) > 20) { if ((processedLines % 30 == 0) && (new Date() - workerStart) > 20) {
self.fireUpdateEvent(startLine, self.currentLine); self.fireUpdateEvent(startLine, self.currentLine);
return setTimeout(self._worker, 10); return setTimeout(self.$worker, 10);
} }
self.currentLine++; self.currentLine++;
@ -77,7 +77,7 @@ ace.BackgroundTokenizer = function(tokenizer) {
if (!this.running) { if (!this.running) {
clearTimeout(this.running); clearTimeout(this.running);
// pretty long delay to prevent the tokenizer from interfering with the user // 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) { this.getTokens = function(row) {
return this._tokenizeRow(row).tokens; return this.$tokenizeRow(row).tokens;
}; };
this.getState = function(row) { 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]) { if (!this.lines[row]) {
var state = "start"; var state = "start";
if (row > 0 && this.lines[row - 1]) { if (row > 0 && this.lines[row - 1]) {

View file

@ -3,7 +3,7 @@ ace.provide("ace.Document");
ace.Document = function(text, mode) { ace.Document = function(text, mode) {
this.$initEvents(); this.$initEvents();
this.lines = this._split(text); this.lines = this.$split(text);
this.modified = true; this.modified = true;
this.selection = new ace.Selection(this); this.selection = new ace.Selection(this);
@ -17,7 +17,7 @@ ace.Document = function(text, mode) {
ace.implement(this, ace.MEventEmitter); ace.implement(this, ace.MEventEmitter);
this._split = function(text) { this.$split = function(text) {
return text.split(/\r\n|\r|\n/); return text.split(/\r\n|\r|\n/);
}; };
@ -44,54 +44,54 @@ ace.Document = function(text, mode) {
return "\t"; return "\t";
}; };
this._useSoftTabs = false; this.$useSoftTabs = false;
this.setUseSoftTabs = function(useSoftTabs) { this.setUseSoftTabs = function(useSoftTabs) {
if (this._useSoftTabs === useSoftTabs) return; if (this.$useSoftTabs === useSoftTabs) return;
this._useSoftTabs = useSoftTabs; this.$useSoftTabs = useSoftTabs;
}; };
this.getUseSoftTabs = function() { this.getUseSoftTabs = function() {
return this._useSoftTabs; return this.$useSoftTabs;
}; };
this._tabSize = 4; this.$tabSize = 4;
this.setTabSize = function(tabSize) { this.setTabSize = function(tabSize) {
if (this._tabSize === tabSize) return; if (this.$tabSize === tabSize) return;
this._tabSize = tabSize; this.$tabSize = tabSize;
this.$dispatchEvent("changeTabSize"); this.$dispatchEvent("changeTabSize");
}; };
this.getTabSize = function() { this.getTabSize = function() {
return this._tabSize; return this.$tabSize;
}; };
this._mode = null; this.$mode = null;
this.setMode = function(mode) { this.setMode = function(mode) {
if (this._mode === mode) return; if (this.$mode === mode) return;
this._mode = mode; this.$mode = mode;
this.$dispatchEvent("changeMode"); this.$dispatchEvent("changeMode");
}; };
this.getMode = function() { this.getMode = function() {
if (!this._mode) { if (!this.$mode) {
this._mode = new ace.mode.Text(); this.$mode = new ace.mode.Text();
} }
return this._mode; return this.$mode;
}; };
this._scrollTop = 0; this.$scrollTop = 0;
this.setScrollTopRow = function(scrollTopRow) { this.setScrollTopRow = function(scrollTopRow) {
if (this._scrollTop === scrollTopRow) return; if (this.$scrollTop === scrollTopRow) return;
this._scrollTop = scrollTopRow; this.$scrollTop = scrollTopRow;
this.$dispatchEvent("changeScrollTop"); this.$dispatchEvent("changeScrollTop");
}; };
this.getScrollTopRow = function() { this.getScrollTopRow = function() {
return this._scrollTop; return this.$scrollTop;
}; };
this.getWidth = function() { this.getWidth = function() {
@ -146,13 +146,13 @@ ace.Document = function(text, mode) {
} }
if (match[1]) { if (match[1]) {
return this._findClosingBracket(match[1], position); return this.$findClosingBracket(match[1], position);
} else { } 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) { this.$findOpeningBracket = function(bracket, position) {
var openBracket = this._brackets[bracket]; var openBracket = this.$brackets[bracket];
var column = position.column - 2; var column = position.column - 2;
var row = position.row; var row = position.row;
@ -193,8 +193,8 @@ ace.Document = function(text, mode) {
return null; return null;
}; };
this._findClosingBracket = function(bracket, position) { this.$findClosingBracket = function(bracket, position) {
var closingBracket = this._brackets[bracket]; var closingBracket = this.$brackets[bracket];
var column = position.column; var column = position.column;
var row = position.row; var row = position.row;
@ -227,24 +227,24 @@ ace.Document = function(text, mode) {
}; };
this.insert = function(position, text) { 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 this.fireChangeEvent(position.row, position.row == end.row ? position.row
: undefined); : undefined);
return end; return end;
}; };
this._insertLines = function(row, lines) { this.$insertLines = function(row, lines) {
var args = [row, 0]; var args = [row, 0];
args.push.apply(args, lines); args.push.apply(args, lines);
this.lines.splice.apply(this.lines, args); this.lines.splice.apply(this.lines, args);
}, },
this._insert = function(position, text) { this.$insert = function(position, text) {
this.modified = true; 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] || ""; var line = this.lines[position.row] || "";
this.lines[position.row] = line.substring(0, position.column); this.lines[position.row] = line.substring(0, position.column);
this.lines.splice(position.row + 1, 0, line.substring(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); + line.substring(position.column);
if (newLines.length > 2) { if (newLines.length > 2) {
this._insertLines(position.row + 1, newLines.slice(1, -1)); this.$insertLines(position.row + 1, newLines.slice(1, -1));
} }
return { 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"); return (text == "\r\n" || text == "\r" || text == "\n");
}; };
this.remove = function(range) { this.remove = function(range) {
this._remove(range); this.$remove(range);
this.fireChangeEvent(range.start.row, this.fireChangeEvent(range.start.row,
range.end.row == range.start.row ? range.start.row range.end.row == range.start.row ? range.start.row
@ -296,7 +296,7 @@ ace.Document = function(text, mode) {
return range.start; return range.start;
}; };
this._remove = function(range) { this.$remove = function(range) {
this.modified = true; this.modified = true;
var firstRow = range.start.row; var firstRow = range.start.row;
@ -311,9 +311,9 @@ ace.Document = function(text, mode) {
}; };
this.replace = function(range, text) { this.replace = function(range, text) {
this._remove(range); this.$remove(range);
if (text) { if (text) {
var end = this._insert(range.start, text); var end = this.$insert(range.start, text);
} }
else { else {
end = range.start; end = range.start;
@ -356,7 +356,7 @@ ace.Document = function(text, mode) {
if (firstRow <= 0) return 0; if (firstRow <= 0) return 0;
var removed = this.lines.splice(firstRow, lastRow-firstRow+1); var removed = this.lines.splice(firstRow, lastRow-firstRow+1);
this._insertLines(firstRow-1, removed); this.$insertLines(firstRow-1, removed);
this.fireChangeEvent(firstRow-1, lastRow); this.fireChangeEvent(firstRow-1, lastRow);
return -1; return -1;
@ -366,18 +366,18 @@ ace.Document = function(text, mode) {
if (lastRow >= this.lines.length-1) return 0; if (lastRow >= this.lines.length-1) return 0;
var removed = this.lines.splice(firstRow, lastRow-firstRow+1); var removed = this.lines.splice(firstRow, lastRow-firstRow+1);
this._insertLines(firstRow+1, removed); this.$insertLines(firstRow+1, removed);
this.fireChangeEvent(firstRow, lastRow+1); this.fireChangeEvent(firstRow, lastRow+1);
return 1; return 1;
}; };
this.duplicateLines = function(firstRow, lastRow) { this.duplicateLines = function(firstRow, lastRow) {
var firstRow = this._clipRowToDocument(firstRow); var firstRow = this.$clipRowToDocument(firstRow);
var lastRow = this._clipRowToDocument(lastRow); var lastRow = this.$clipRowToDocument(lastRow);
var lines = this.getLines(firstRow, lastRow); var lines = this.getLines(firstRow, lastRow);
this._insertLines(firstRow, lines); this.$insertLines(firstRow, lines);
var addedRows = lastRow - firstRow + 1; var addedRows = lastRow - firstRow + 1;
this.fireChangeEvent(firstRow, lastRow+addedRows); this.fireChangeEvent(firstRow, lastRow+addedRows);
@ -385,7 +385,7 @@ ace.Document = function(text, mode) {
return addedRows; return addedRows;
}; };
this._clipRowToDocument = function(row) { this.$clipRowToDocument = function(row) {
return Math.max(0, Math.min(row, this.lines.length-1)); return Math.max(0, Math.min(row, this.lines.length-1));
}; };

View file

@ -19,9 +19,9 @@ ace.Editor = function(renderer, doc) {
ace.addTripleClickListener(mouseTarget, ace.bind(this.onMouseTripleClick, this)); ace.addTripleClickListener(mouseTarget, ace.bind(this.onMouseTripleClick, this));
ace.addMouseWheelListener(mouseTarget, ace.bind(this.onMouseWheel, this)); ace.addMouseWheelListener(mouseTarget, ace.bind(this.onMouseWheel, this));
this._selectionMarker = null; this.$selectionMarker = null;
this._highlightLineMarker = null; this.$highlightLineMarker = null;
this._blockScrolling = false; this.$blockScrolling = false;
this.setDocument(doc || new ace.Document("")); this.setDocument(doc || new ace.Document(""));
}; };
@ -32,36 +32,36 @@ ace.Editor = function(renderer, doc) {
if (this.doc == doc) return; if (this.doc == doc) return;
if (this.doc) { if (this.doc) {
this.doc.removeEventListener("change", this._onDocumentChange); this.doc.removeEventListener("change", this.$onDocumentChange);
this.doc.removeEventListener("changeMode", this._onDocumentModeChange); this.doc.removeEventListener("changeMode", this.$onDocumentModeChange);
this.doc.removeEventListener("changeTabSize", this._onDocumentChangeTabSize); this.doc.removeEventListener("changeTabSize", this.$onDocumentChangeTabSize);
var selection = this.doc.getSelection(); var selection = this.doc.getSelection();
this.selection.removeEventListener("changeCursor", this._onCursorChange); this.selection.removeEventListener("changeCursor", this.$onCursorChange);
this.selection.removeEventListener("changeSelection", this._onSelectionChange); this.selection.removeEventListener("changeSelection", this.$onSelectionChange);
this.doc.setScrollTopRow(this.renderer.getScrollTopRow()); this.doc.setScrollTopRow(this.renderer.getScrollTopRow());
} }
this.doc = doc; this.doc = doc;
this._onDocumentChange = ace.bind(this.onDocumentChange, this); this.$onDocumentChange = ace.bind(this.onDocumentChange, this);
doc.addEventListener("change", this._onDocumentChange); doc.addEventListener("change", this.$onDocumentChange);
this.renderer.setDocument(doc); this.renderer.setDocument(doc);
this._onDocumentModeChange = ace.bind(this.onDocumentModeChange, this); this.$onDocumentModeChange = ace.bind(this.onDocumentModeChange, this);
doc.addEventListener("changeMode", this._onDocumentModeChange); doc.addEventListener("changeMode", this.$onDocumentModeChange);
this._onDocumentChangeTabSize = ace.bind(this.renderer.draw, this.renderer); this.$onDocumentChangeTabSize = ace.bind(this.renderer.draw, this.renderer);
doc.addEventListener("changeTabSize", this._onDocumentChangeTabSize); doc.addEventListener("changeTabSize", this.$onDocumentChangeTabSize);
this.selection = doc.getSelection(); this.selection = doc.getSelection();
this._onCursorChange = ace.bind(this.onCursorChange, this); this.$onCursorChange = ace.bind(this.onCursorChange, this);
this.selection.addEventListener("changeCursor", this._onCursorChange); this.selection.addEventListener("changeCursor", this.$onCursorChange);
this._onSelectionChange = ace.bind(this.onSelectionChange, this); this.$onSelectionChange = ace.bind(this.onSelectionChange, this);
this.selection.addEventListener("changeSelection", this._onSelectionChange); this.selection.addEventListener("changeSelection", this.$onSelectionChange);
this.onDocumentModeChange(); this.onDocumentModeChange();
this.bgTokenizer.setLines(this.doc.lines); this.bgTokenizer.setLines(this.doc.lines);
@ -84,21 +84,21 @@ ace.Editor = function(renderer, doc) {
this.renderer.onResize(); this.renderer.onResize();
}; };
this._highlightBrackets = function() { this.$highlightBrackets = function() {
if (this._bracketHighlight) { if (this.$bracketHighlight) {
this.renderer.removeMarker(this._bracketHighlight); this.renderer.removeMarker(this.$bracketHighlight);
this._bracketHighlight = null; this.$bracketHighlight = null;
} }
if (this._highlightPending) { if (this.$highlightPending) {
return; return;
} }
// perform highlight async to not block the browser during navigation // perform highlight async to not block the browser during navigation
var self = this; var self = this;
this._highlightPending = true; this.$highlightPending = true;
setTimeout(function() { setTimeout(function() {
self._highlightPending = false; self.$highlightPending = false;
var pos = self.doc.findMatchingBracket(self.getCursorPosition()); var pos = self.doc.findMatchingBracket(self.getCursorPosition());
if (pos) { if (pos) {
@ -109,7 +109,7 @@ ace.Editor = function(renderer, doc) {
column: pos.column+1 column: pos.column+1
} }
}; };
self._bracketHighlight = self.renderer.addMarker(range, "bracket"); self.$bracketHighlight = self.renderer.addMarker(range, "bracket");
} }
}, 10); }, 10);
}; };
@ -144,20 +144,20 @@ ace.Editor = function(renderer, doc) {
}; };
this.onCursorChange = function() { this.onCursorChange = function() {
this._highlightBrackets(); this.$highlightBrackets();
this.renderer.updateCursor(this.getCursorPosition()); this.renderer.updateCursor(this.getCursorPosition());
if (!this._blockScrolling) { if (!this.$blockScrolling) {
this.renderer.scrollCursorIntoView(); this.renderer.scrollCursorIntoView();
} }
this._updateHighlightActiveLine(); this.$updateHighlightActiveLine();
}; };
this._updateHighlightActiveLine = function() { this.$updateHighlightActiveLine = function() {
if (this._highlightLineMarker) { if (this.$highlightLineMarker) {
this.renderer.removeMarker(this._highlightLineMarker); this.renderer.removeMarker(this.$highlightLineMarker);
} }
this._highlightLineMarker = null; this.$highlightLineMarker = null;
if (this.getHighlightActiveLine() && !this.selection.isMultiLine()) { if (this.getHighlightActiveLine() && !this.selection.isMultiLine()) {
var cursor = this.getCursorPosition(); var cursor = this.getCursorPosition();
@ -171,20 +171,20 @@ ace.Editor = function(renderer, doc) {
column: 0 column: 0
} }
}; };
this._highlightLineMarker = this.renderer.addMarker(range, "active_line", "line"); this.$highlightLineMarker = this.renderer.addMarker(range, "active_line", "line");
} }
}; };
this.onSelectionChange = function() { this.onSelectionChange = function() {
if (this._selectionMarker) { if (this.$selectionMarker) {
this.renderer.removeMarker(this._selectionMarker); this.renderer.removeMarker(this.$selectionMarker);
} }
this._selectionMarker = null; this.$selectionMarker = null;
if (!this.selection.isEmpty()) { if (!this.selection.isEmpty()) {
var range = this.selection.getRange(); var range = this.selection.getRange();
var style = this.getSelectionStyle(); var style = this.getSelectionStyle();
this._selectionMarker = this.renderer.addMarker(range, "selection", style); this.$selectionMarker = this.renderer.addMarker(range, "selection", style);
} }
this.onCursorChange(); this.onCursorChange();
@ -314,28 +314,28 @@ ace.Editor = function(renderer, doc) {
this.renderer.scrollCursorIntoView(); this.renderer.scrollCursorIntoView();
}; };
this._selectionStyle = "line"; this.$selectionStyle = "line";
this.setSelectionStyle = function(style) { this.setSelectionStyle = function(style) {
if (this._selectionStyle == style) return; if (this.$selectionStyle == style) return;
this._selectionStyle = style; this.$selectionStyle = style;
this.onSelectionChange(); this.onSelectionChange();
}; };
this.getSelectionStyle = function() { this.getSelectionStyle = function() {
return this._selectionStyle; return this.$selectionStyle;
}; };
this._highlightActiveLine = true; this.$highlightActiveLine = true;
this.setHighlightActiveLine = function(shouldHighlight) { this.setHighlightActiveLine = function(shouldHighlight) {
if (this._highlightActiveLine == shouldHighlight) return; if (this.$highlightActiveLine == shouldHighlight) return;
this._highlightActiveLine = shouldHighlight; this.$highlightActiveLine = shouldHighlight;
this._updateHighlightActiveLine(); this.$updateHighlightActiveLine();
}; };
this.getHighlightActiveLine = function() { this.getHighlightActiveLine = function() {
return this._highlightActiveLine; return this.$highlightActiveLine;
}; };
this.removeRight = function() { this.removeRight = function() {
@ -369,7 +369,7 @@ ace.Editor = function(renderer, doc) {
}; };
this.toggleCommentLines = function() { this.toggleCommentLines = function() {
var rows = this._getSelectedRows(); var rows = this.$getSelectedRows();
var range = { var range = {
start: { start: {
@ -388,7 +388,7 @@ ace.Editor = function(renderer, doc) {
}; };
this.removeLines = function() { this.removeLines = function() {
var rows = this._getSelectedRows(); var rows = this.$getSelectedRows();
this.selection.setSelectionAnchor(rows.last+1, 0); this.selection.setSelectionAnchor(rows.last+1, 0);
this.selection.selectTo(rows.first, 0); this.selection.selectTo(rows.first, 0);
@ -397,44 +397,44 @@ ace.Editor = function(renderer, doc) {
}; };
this.moveLinesDown = function() { this.moveLinesDown = function() {
this._moveLines(function(firstRow, lastRow) { this.$moveLines(function(firstRow, lastRow) {
return this.doc.moveLinesDown(firstRow, lastRow); return this.doc.moveLinesDown(firstRow, lastRow);
}); });
}; };
this.moveLinesUp = function() { this.moveLinesUp = function() {
this._moveLines(function(firstRow, lastRow) { this.$moveLines(function(firstRow, lastRow) {
return this.doc.moveLinesUp(firstRow, lastRow); return this.doc.moveLinesUp(firstRow, lastRow);
}); });
}; };
this.copyLinesUp = function() { this.copyLinesUp = function() {
this._moveLines(function(firstRow, lastRow) { this.$moveLines(function(firstRow, lastRow) {
this.doc.duplicateLines(firstRow, lastRow); this.doc.duplicateLines(firstRow, lastRow);
return 0; return 0;
}); });
}; };
this.copyLinesDown = function() { this.copyLinesDown = function() {
this._moveLines(function(firstRow, lastRow) { this.$moveLines(function(firstRow, lastRow) {
return this.doc.duplicateLines(firstRow, lastRow); return this.doc.duplicateLines(firstRow, lastRow);
}); });
}; };
this._moveLines = function(mover) { this.$moveLines = function(mover) {
var rows = this._getSelectedRows(); var rows = this.$getSelectedRows();
var linesMoved = mover.call(this, rows.first, rows.last); var linesMoved = mover.call(this, rows.first, rows.last);
var selection = this.selection; var selection = this.selection;
selection.setSelectionAnchor(rows.last+linesMoved+1, 0); selection.setSelectionAnchor(rows.last+linesMoved+1, 0);
selection._moveSelection(function() { selection.$moveSelection(function() {
selection.moveCursorTo(rows.first+linesMoved, 0); selection.moveCursorTo(rows.first+linesMoved, 0);
}); });
}; };
this._getSelectedRows = function() { this.$getSelectedRows = function() {
var range = this.getSelectionRange(); var range = this.getSelectionRange();
var firstRow = range.start.row; var firstRow = range.start.row;
var lastRow = range.end.row; var lastRow = range.end.row;
@ -526,9 +526,9 @@ ace.Editor = function(renderer, doc) {
this.gotoLine = function(lineNumber) { this.gotoLine = function(lineNumber) {
this._blockScrolling = true; this.$blockScrolling = true;
this.moveCursorTo(lineNumber-1, 0); this.moveCursorTo(lineNumber-1, 0);
this._blockScrolling = false; this.$blockScrolling = false;
if (!this.isRowVisible(this.getCursorPosition().row)) { if (!this.isRowVisible(this.getCursorPosition().row)) {
this.scrollToRow(lineNumber - 1 - Math.floor(this.getVisibleRowCount() / 2)); this.scrollToRow(lineNumber - 1 - Math.floor(this.getVisibleRowCount() / 2));

View file

@ -3,11 +3,11 @@ ace.provide("ace.MEventEmitter");
ace.MEventEmitter = function() { ace.MEventEmitter = function() {
this.$initEvents = function() { this.$initEvents = function() {
this._eventRegistry = {}; this.$eventRegistry = {};
}; };
this.$dispatchEvent = function(eventName, e) { this.$dispatchEvent = function(eventName, e) {
var listeners = this._eventRegistry[eventName]; var listeners = this.$eventRegistry[eventName];
if (!listeners || !listeners.length) return; if (!listeners || !listeners.length) return;
var e = e || {}; var e = e || {};
@ -19,9 +19,9 @@ ace.MEventEmitter = function() {
}; };
this.addEventListener = function(eventName, callback) { this.addEventListener = function(eventName, callback) {
var listeners = this._eventRegistry[eventName]; var listeners = this.$eventRegistry[eventName];
if (!listeners) { if (!listeners) {
var listeners = this._eventRegistry[eventName] = []; var listeners = this.$eventRegistry[eventName] = [];
} }
if (ace.arrayIndexOf(listeners, callback) == -1) { if (ace.arrayIndexOf(listeners, callback) == -1) {
listeners.push(callback); listeners.push(callback);
@ -29,7 +29,7 @@ ace.MEventEmitter = function() {
}; };
this.removeEventListener = function(eventName, callback) { this.removeEventListener = function(eventName, callback) {
var listeners = this._eventRegistry[eventName]; var listeners = this.$eventRegistry[eventName];
if (!listeners) { if (!listeners) {
return; return;
} }

View file

@ -44,19 +44,19 @@ ace.Selection = function(doc) {
this.setSelectionAnchor = function(row, column) { this.setSelectionAnchor = function(row, column) {
this.clearSelection(); this.clearSelection();
this.selectionAnchor = this._clipPositionToDocument(row, column); this.selectionAnchor = this.$clipPositionToDocument(row, column);
}; };
this.getSelectionAnchor = function() { this.getSelectionAnchor = function() {
if (this.selectionAnchor) { if (this.selectionAnchor) {
return this._clone(this.selectionAnchor); return this.$clone(this.selectionAnchor);
} else { } else {
return this._clone(this.selectionLead); return this.$clone(this.selectionLead);
} }
}; };
this.getSelectionLead = function() { this.getSelectionLead = function() {
return this._clone(this.selectionLead); return this.$clone(this.selectionLead);
}; };
this.shiftSelection = function(columns) { this.shiftSelection = function(columns) {
@ -69,7 +69,7 @@ ace.Selection = function(doc) {
var lead = this.getSelectionLead(); var lead = this.getSelectionLead();
this.setSelectionAnchor(anchor.row, anchor.column + columns); this.setSelectionAnchor(anchor.row, anchor.column + columns);
this._moveSelection(function() { this.$moveSelection(function() {
this.moveCursorTo(lead.row, lead.column + columns); this.moveCursorTo(lead.row, lead.column + columns);
}); });
}; };
@ -103,14 +103,14 @@ ace.Selection = function(doc) {
var lastRow = this.doc.getLength() - 1; var lastRow = this.doc.getLength() - 1;
this.setSelectionAnchor(lastRow, this.doc.getLine(lastRow).length); this.setSelectionAnchor(lastRow, this.doc.getLine(lastRow).length);
this._moveSelection(function() { this.$moveSelection(function() {
this.moveCursorTo(0, 0); this.moveCursorTo(0, 0);
}); });
}; };
this._moveSelection = function(mover) { this.$moveSelection = function(mover) {
if (!this.selectionAnchor) { if (!this.selectionAnchor) {
this.selectionAnchor = this._clone(this.selectionLead); this.selectionAnchor = this.$clone(this.selectionLead);
} }
mover.call(this); mover.call(this);
@ -118,39 +118,39 @@ ace.Selection = function(doc) {
}; };
this.selectTo = function(row, column) { this.selectTo = function(row, column) {
this._moveSelection(function() { this.$moveSelection(function() {
this.moveCursorTo(row, column); this.moveCursorTo(row, column);
}); });
}; };
this.selectToPosition = function(pos) { this.selectToPosition = function(pos) {
this._moveSelection(function() { this.$moveSelection(function() {
this.moveCursorToPosition(pos); this.moveCursorToPosition(pos);
}); });
}; };
this.selectUp = function() { this.selectUp = function() {
this._moveSelection(this.moveCursorUp); this.$moveSelection(this.moveCursorUp);
}; };
this.selectDown = function() { this.selectDown = function() {
this._moveSelection(this.moveCursorDown); this.$moveSelection(this.moveCursorDown);
}; };
this.selectRight = function() { this.selectRight = function() {
this._moveSelection(this.moveCursorRight); this.$moveSelection(this.moveCursorRight);
}; };
this.selectLeft = function() { this.selectLeft = function() {
this._moveSelection(this.moveCursorLeft); this.$moveSelection(this.moveCursorLeft);
}; };
this.selectLineStart = function() { this.selectLineStart = function() {
this._moveSelection(this.moveCursorLineStart); this.$moveSelection(this.moveCursorLineStart);
}; };
this.selectLineEnd = function() { this.selectLineEnd = function() {
this._moveSelection(this.moveCursorLineEnd); this.$moveSelection(this.moveCursorLineEnd);
}; };
this.selectPageDown = function() { this.selectPageDown = function() {
@ -158,7 +158,7 @@ ace.Selection = function(doc) {
this.scrollPageDown(); this.scrollPageDown();
this._moveSelection(function() { this.$moveSelection(function() {
this.moveCursorTo(row, this.selectionLead.column); this.moveCursorTo(row, this.selectionLead.column);
}); });
}; };
@ -169,28 +169,28 @@ ace.Selection = function(doc) {
this.scrollPageUp(); this.scrollPageUp();
this._moveSelection(function() { this.$moveSelection(function() {
this.moveCursorTo(row, this.selectionLead.column); this.moveCursorTo(row, this.selectionLead.column);
}); });
}; };
this.selectFileEnd = function() { this.selectFileEnd = function() {
this._moveSelection(this.moveCursorFileEnd); this.$moveSelection(this.moveCursorFileEnd);
}; };
this.selectFileStart = function() { this.selectFileStart = function() {
this._moveSelection(this.moveCursorFileStart); this.$moveSelection(this.moveCursorFileStart);
}; };
this.tokenRe = /^[\w\d]+/g; this.tokenRe = /^[\w\d]+/g;
this.nonTokenRe = /^[^\w\d]+/g; this.nonTokenRe = /^[^\w\d]+/g;
this.selectWordRight = function() { this.selectWordRight = function() {
this._moveSelection(this.moveCursorWordRight); this.$moveSelection(this.moveCursorWordRight);
}; };
this.selectWordLeft = function() { this.selectWordLeft = function() {
this._moveSelection(this.moveCursorWordLeft); this.$moveSelection(this.moveCursorWordLeft);
}; };
this.selectWord = function() { this.selectWord = function() {
@ -225,14 +225,14 @@ ace.Selection = function(doc) {
} }
this.setSelectionAnchor(cursor.row, start); this.setSelectionAnchor(cursor.row, start);
this._moveSelection(function() { this.$moveSelection(function() {
this.moveCursorTo(cursor.row, end); this.moveCursorTo(cursor.row, end);
}); });
}; };
this.selectLine = function() { this.selectLine = function() {
this.setSelectionAnchor(this.selectionLead.row, 0); this.setSelectionAnchor(this.selectionLead.row, 0);
this._moveSelection(function() { this.$moveSelection(function() {
this.moveCursorTo(this.selectionLead.row + 1, 0); this.moveCursorTo(this.selectionLead.row + 1, 0);
}); });
}; };
@ -349,7 +349,7 @@ ace.Selection = function(doc) {
}; };
this.moveCursorTo = function(row, column) { this.moveCursorTo = function(row, column) {
this.selectionLead = this._clipPositionToDocument(row, column); this.selectionLead = this.$clipPositionToDocument(row, column);
this.updateCursor(); this.updateCursor();
}; };
@ -357,7 +357,7 @@ ace.Selection = function(doc) {
this.moveCursorBy(-1, 0); this.moveCursorBy(-1, 0);
}; };
this._clipPositionToDocument = function(row, column) { this.$clipPositionToDocument = function(row, column) {
var pos = {}; var pos = {};
if (row >= this.doc.getLength()) { if (row >= this.doc.getLength()) {
@ -376,7 +376,7 @@ ace.Selection = function(doc) {
return pos; return pos;
}; };
this._clone = function(pos) { this.$clone = function(pos) {
return { return {
row: pos.row, row: pos.row,
column: pos.column column: pos.column

View file

@ -80,7 +80,7 @@ ace.VirtualRenderer = function(container) {
this.scroller.style.width = Math.max(0, width - gutterWidth - this.scrollBar.getWidth()) + "px"; this.scroller.style.width = Math.max(0, width - gutterWidth - this.scrollBar.getWidth()) + "px";
if (this.doc) { if (this.doc) {
this._updateScrollBar(); this.$updateScrollBar();
this.scrollToY(this.getScrollTop()); this.scrollToY(this.getScrollTop());
this.draw(); this.draw();
} }
@ -90,7 +90,7 @@ ace.VirtualRenderer = function(container) {
this.scrollToY(e.data); this.scrollToY(e.data);
}; };
this._updateScrollBar = function() { this.$updateScrollBar = function() {
this.scrollBar.setInnerHeight(this.doc.getLength() * this.lineHeight); this.scrollBar.setInnerHeight(this.doc.getLength() * this.lineHeight);
this.scrollBar.setScrollTop(this.scrollTop); this.scrollBar.setScrollTop(this.scrollTop);
}; };
@ -146,7 +146,7 @@ ace.VirtualRenderer = function(container) {
this.gutterLayer.element.style.height = minHeight + "px"; this.gutterLayer.element.style.height = minHeight + "px";
this.gutterLayer.update(layerConfig); this.gutterLayer.update(layerConfig);
this._updateScrollBar(); this.$updateScrollBar();
}; };
this.addMarker = function(range, clazz, type) { this.addMarker = function(range, clazz, type) {
@ -215,7 +215,7 @@ ace.VirtualRenderer = function(container) {
if (this.scrollTop !== scrollTop) { if (this.scrollTop !== scrollTop) {
this.scrollTop = scrollTop; this.scrollTop = scrollTop;
this._updateScrollBar(); this.$updateScrollBar();
this.draw(); this.draw();
} }
}; };

View file

@ -6,7 +6,7 @@ ace.layer.Marker = function(parentEl) {
parentEl.appendChild(this.element); parentEl.appendChild(this.element);
this.markers = {}; this.markers = {};
this._markerId = 1; this.$markerId = 1;
}; };
(function() { (function() {
@ -16,7 +16,7 @@ ace.layer.Marker = function(parentEl) {
}; };
this.addMarker = function(range, clazz, type) { this.addMarker = function(range, clazz, type) {
var id = this._markerId++; var id = this.$markerId++;
this.markers[id] = { this.markers[id] = {
range : range, range : range,
type : type || "line", type : type || "line",

View file

@ -5,8 +5,8 @@ ace.layer.Text = function(parentEl) {
this.element.className = "layer text-layer"; this.element.className = "layer text-layer";
parentEl.appendChild(this.element); parentEl.appendChild(this.element);
this._measureSizes(); this.$measureSizes();
this._tabString = " "; this.$tabString = " ";
}; };
(function() { (function() {
@ -23,7 +23,7 @@ ace.layer.Text = function(parentEl) {
return this.characterWidth; return this.characterWidth;
}; };
this._measureSizes = function() { this.$measureSizes = function() {
var measureNode = document.createElement("div"); var measureNode = document.createElement("div");
var style = measureNode.style; var style = measureNode.style;
style.width = style.height = "auto"; style.width = style.height = "auto";
@ -45,7 +45,7 @@ ace.layer.Text = function(parentEl) {
}; };
this.setTabSize = function(tabSize) { this.setTabSize = function(tabSize) {
this._tabString = new Array(tabSize+1).join("&nbsp;"); this.$tabString = new Array(tabSize+1).join("&nbsp;");
}; };
this.updateLines = function(layerConfig, firstRow, lastRow) { this.updateLines = function(layerConfig, firstRow, lastRow) {
@ -83,7 +83,7 @@ ace.layer.Text = function(parentEl) {
.replace(/&/g, "&amp;") .replace(/&/g, "&amp;")
.replace(/</g, "&lt;") .replace(/</g, "&lt;")
//.replace(/\t/g, "&#x2023; ") //.replace(/\t/g, "&#x2023; ")
.replace(/\t/g, this._tabString) .replace(/\t/g, this.$tabString)
.replace(/\s/g, "&nbsp;"); .replace(/\s/g, "&nbsp;");
if (token.type !== "text") { if (token.type !== "text") {

View file

@ -73,7 +73,7 @@ ace.mode.CssHighlightRules = function() {
return re.join(""); return re.join("");
} }
this._rules = { this.$rules = {
"start" : [ { "start" : [ {
token : "comment", // multi line comment token : "comment", // multi line comment
regex : "\\/\\*", regex : "\\/\\*",
@ -178,7 +178,7 @@ ace.mode.CssHighlightRules = function() {
(function() { (function() {
this.getRules = function() { this.getRules = function() {
return this._rules; return this.$rules;
}; };
}).call(ace.mode.CssHighlightRules.prototype); }).call(ace.mode.CssHighlightRules.prototype);

View file

@ -3,8 +3,8 @@ ace.provide("ace.mode.Html");
ace.mode.Html = function() { ace.mode.Html = function() {
this.$tokenizer = new ace.Tokenizer(new ace.mode.HtmlHighlightRules().getRules()); this.$tokenizer = new ace.Tokenizer(new ace.mode.HtmlHighlightRules().getRules());
this._js = new ace.mode.JavaScript(); this.$js = new ace.mode.JavaScript();
this._css = new ace.mode.Css(); this.$css = new ace.mode.Css();
}; };
ace.inherits(ace.mode.Html, ace.mode.Text); 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) { this.toggleCommentLines = function(doc, range, state) {
var split = state.split("js-"); var split = state.split("js-");
if (!split[0] && split[1]) { if (!split[0] && split[1]) {
return this._js.toggleCommentLines(doc, range, state); return this.$js.toggleCommentLines(doc, range, state);
} }
var split = state.split("css-"); var split = state.split("css-");
if (!split[0] && split[1]) { if (!split[0] && split[1]) {
return this._css.toggleCommentLines(doc, range, state); return this.$css.toggleCommentLines(doc, range, state);
} }
return 0; return 0;
@ -27,12 +27,12 @@ ace.inherits(ace.mode.Html, ace.mode.Text);
this.getNextLineIndent = function(line, state, tab) { this.getNextLineIndent = function(line, state, tab) {
var split = state.split("js-"); var split = state.split("js-");
if (!split[0] && split[1]) { 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-"); var split = state.split("css-");
if (!split[0] && split[1]) { if (!split[0] && split[1]) {
return this._css.getNextLineIndent(line, split[1], tab); return this.$css.getNextLineIndent(line, split[1], tab);
} }
return ""; return "";

View file

@ -5,7 +5,7 @@ ace.mode.HtmlHighlightRules = function() {
// regexp must not have capturing parentheses // regexp must not have capturing parentheses
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
this._rules = { this.$rules = {
start : [ { start : [ {
token : "text", token : "text",
regex : "<\\!\\[CDATA\\[", regex : "<\\!\\[CDATA\\[",
@ -114,16 +114,16 @@ ace.mode.HtmlHighlightRules = function() {
}; };
var jsRules = new ace.mode.JavaScriptHighlightRules().getRules(); var jsRules = new ace.mode.JavaScriptHighlightRules().getRules();
this._addRules(jsRules, "js-"); this.$addRules(jsRules, "js-");
this._rules["js-start"].unshift({ this.$rules["js-start"].unshift({
token: "text", token: "text",
regex: "<\\/(?=script)", regex: "<\\/(?=script)",
next: "tag" next: "tag"
}); });
var cssRules = new ace.mode.CssHighlightRules().getRules(); var cssRules = new ace.mode.CssHighlightRules().getRules();
this._addRules(cssRules, "css-"); this.$addRules(cssRules, "css-");
this._rules["css-start"].unshift({ this.$rules["css-start"].unshift({
token: "text", token: "text",
regex: "<\\/(?=style)", regex: "<\\/(?=style)",
next: "tag" next: "tag"
@ -132,7 +132,7 @@ ace.mode.HtmlHighlightRules = function() {
(function() { (function() {
this._addRules = function(rules, prefix) { this.$addRules = function(rules, prefix) {
for (var key in rules) { for (var key in rules) {
var state = rules[key]; var state = rules[key];
for (var i=0; i<state.length; i++) { for (var i=0; i<state.length; i++) {
@ -141,12 +141,12 @@ ace.mode.HtmlHighlightRules = function() {
rule.next = prefix + rule.next; rule.next = prefix + rule.next;
} }
} }
this._rules[prefix + key] = state; this.$rules[prefix + key] = state;
} }
}; };
this.getRules = function() { this.getRules = function() {
return this._rules; return this.$rules;
}; };
}).call(ace.mode.HtmlHighlightRules.prototype); }).call(ace.mode.HtmlHighlightRules.prototype);

View file

@ -31,7 +31,7 @@ ace.mode.JavaScriptHighlightRules = function() {
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
this._rules = { this.$rules = {
"start" : [ { "start" : [ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : "\\/\\/.*$"
@ -130,7 +130,7 @@ ace.mode.JavaScriptHighlightRules = function() {
(function() { (function() {
this.getRules = function() { this.getRules = function() {
return this._rules; return this.$rules;
}; };
}).call(ace.mode.JavaScriptHighlightRules.prototype); }).call(ace.mode.JavaScriptHighlightRules.prototype);

View file

@ -5,7 +5,7 @@ ace.mode.XmlHighlightRules = function() {
// regexp must not have capturing parentheses // regexp must not have capturing parentheses
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
this._rules = { this.$rules = {
start : [ { start : [ {
token : "text", token : "text",
regex : "<\\!\\[CDATA\\[", regex : "<\\!\\[CDATA\\[",
@ -73,7 +73,7 @@ ace.mode.XmlHighlightRules = function() {
(function() { (function() {
this.getRules = function() { this.getRules = function() {
return this._rules; return this.$rules;
}; };
}).call(ace.mode.XmlHighlightRules.prototype); }).call(ace.mode.XmlHighlightRules.prototype);