code style

This commit is contained in:
nightwing 2014-08-01 21:31:40 +04:00
commit 1bd38560b4
4 changed files with 51 additions and 51 deletions

View file

@ -52,6 +52,7 @@ var $singleLineEditor = function(el) {
editor.renderer.setHighlightGutterLine(false); editor.renderer.setHighlightGutterLine(false);
editor.$mouseHandler.$focusWaitTimout = 0; editor.$mouseHandler.$focusWaitTimout = 0;
editor.$highlightTagPending = true;
return editor; return editor;
}; };
@ -103,7 +104,7 @@ var AcePopup = function(parentNode) {
popup.session.removeMarker(hoverMarker.id); popup.session.removeMarker(hoverMarker.id);
hoverMarker.id = null; hoverMarker.id = null;
} }
} };
popup.setSelectOnHover(false); popup.setSelectOnHover(false);
popup.on("mousemove", function(e) { popup.on("mousemove", function(e) {
if (!lastMouseEvent) { if (!lastMouseEvent) {
@ -171,8 +172,8 @@ var AcePopup = function(parentNode) {
}; };
var bgTokenizer = popup.session.bgTokenizer; var bgTokenizer = popup.session.bgTokenizer;
bgTokenizer.$tokenizeRow = function(i) { bgTokenizer.$tokenizeRow = function(row) {
var data = popup.data[i]; var data = popup.data[row];
var tokens = []; var tokens = [];
if (!data) if (!data)
return tokens; return tokens;
@ -206,7 +207,7 @@ var AcePopup = function(parentNode) {
popup.session.$computeWidth = function() { popup.session.$computeWidth = function() {
return this.screenWidth = 0; return this.screenWidth = 0;
} };
// public // public
popup.isOpen = false; popup.isOpen = false;

View file

@ -44,7 +44,7 @@ function FoldLine(foldData, folds) {
folds = this.folds = [ folds ]; folds = this.folds = [ folds ];
} }
var last = folds[folds.length - 1] var last = folds[folds.length - 1];
this.range = new Range(folds[0].start.row, folds[0].start.column, this.range = new Range(folds[0].start.row, folds[0].start.column,
last.end.row, last.end.column); last.end.row, last.end.column);
this.start = this.range.start; this.start = this.range.start;
@ -66,7 +66,7 @@ function FoldLine(foldData, folds) {
fold.start.row += shift; fold.start.row += shift;
fold.end.row += shift; fold.end.row += shift;
}); });
} };
this.addFold = function(fold) { this.addFold = function(fold) {
if (fold.sameRow) { if (fold.sameRow) {
@ -96,17 +96,17 @@ function FoldLine(foldData, folds) {
throw new Error("Trying to add fold to FoldRow that doesn't have a matching row"); throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");
} }
fold.foldLine = this; fold.foldLine = this;
} };
this.containsRow = function(row) { this.containsRow = function(row) {
return row >= this.start.row && row <= this.end.row; return row >= this.start.row && row <= this.end.row;
} };
this.walk = function(callback, endRow, endColumn) { this.walk = function(callback, endRow, endColumn) {
var lastEnd = 0, var lastEnd = 0,
folds = this.folds, folds = this.folds,
fold, fold,
comp, stop, isNewRow = true; cmp, stop, isNewRow = true;
if (endRow == null) { if (endRow == null) {
endRow = this.end.row; endRow = this.end.row;
@ -116,9 +116,9 @@ function FoldLine(foldData, folds) {
for (var i = 0; i < folds.length; i++) { for (var i = 0; i < folds.length; i++) {
fold = folds[i]; fold = folds[i];
comp = fold.range.compareStart(endRow, endColumn); cmp = fold.range.compareStart(endRow, endColumn);
// This fold is after the endRow/Column. // This fold is after the endRow/Column.
if (comp == -1) { if (cmp == -1) {
callback(null, endRow, endColumn, lastEnd, isNewRow); callback(null, endRow, endColumn, lastEnd, isNewRow);
return; return;
} }
@ -127,8 +127,8 @@ function FoldLine(foldData, folds) {
stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd); stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd);
// If the user requested to stop the walk or endRow/endColumn is // If the user requested to stop the walk or endRow/endColumn is
// inside of this fold (comp == 0), then end here. // inside of this fold (cmp == 0), then end here.
if (stop || comp == 0) { if (stop || cmp === 0) {
return; return;
} }
@ -138,7 +138,7 @@ function FoldLine(foldData, folds) {
lastEnd = fold.end.column; lastEnd = fold.end.column;
} }
callback(null, endRow, endColumn, lastEnd, isNewRow); callback(null, endRow, endColumn, lastEnd, isNewRow);
} };
this.getNextFoldTo = function(row, column) { this.getNextFoldTo = function(row, column) {
var fold, cmp; var fold, cmp;
@ -150,15 +150,15 @@ function FoldLine(foldData, folds) {
fold: fold, fold: fold,
kind: "after" kind: "after"
}; };
} else if (cmp == 0) { } else if (cmp === 0) {
return { return {
fold: fold, fold: fold,
kind: "inside" kind: "inside"
} };
} }
} }
return null; return null;
} };
this.addRemoveChars = function(row, column, len) { this.addRemoveChars = function(row, column, len) {
var ret = this.getNextFoldTo(row, column), var ret = this.getNextFoldTo(row, column),
@ -175,7 +175,7 @@ function FoldLine(foldData, folds) {
} else if (fold.start.row == row) { } else if (fold.start.row == row) {
folds = this.folds; folds = this.folds;
var i = folds.indexOf(fold); var i = folds.indexOf(fold);
if (i == 0) { if (i === 0) {
this.start.column += len; this.start.column += len;
} }
for (i; i < folds.length; i++) { for (i; i < folds.length; i++) {
@ -189,7 +189,7 @@ function FoldLine(foldData, folds) {
this.end.column += len; this.end.column += len;
} }
} }
} };
this.split = function(row, column) { this.split = function(row, column) {
var fold = this.getNextFoldTo(row, column).fold; var fold = this.getNextFoldTo(row, column).fold;
@ -211,7 +211,7 @@ function FoldLine(foldData, folds) {
var newFoldLine = new FoldLine(foldData, folds); var newFoldLine = new FoldLine(foldData, folds);
foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine); foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine);
return newFoldLine; return newFoldLine;
} };
this.merge = function(foldLineNext) { this.merge = function(foldLineNext) {
var folds = foldLineNext.folds; var folds = foldLineNext.folds;
@ -222,7 +222,7 @@ function FoldLine(foldData, folds) {
// it's merged now with foldLineNext. // it's merged now with foldLineNext.
var foldData = this.foldData; var foldData = this.foldData;
foldData.splice(foldData.indexOf(foldLineNext), 1); foldData.splice(foldData.indexOf(foldLineNext), 1);
} };
this.toString = function() { this.toString = function() {
var ret = [this.range.toString() + ": [" ]; var ret = [this.range.toString() + ": [" ];
@ -230,13 +230,12 @@ function FoldLine(foldData, folds) {
this.folds.forEach(function(fold) { this.folds.forEach(function(fold) {
ret.push(" " + fold.toString()); ret.push(" " + fold.toString());
}); });
ret.push("]") ret.push("]");
return ret.join("\n"); return ret.join("\n");
} };
this.idxToPosition = function(idx) { this.idxToPosition = function(idx) {
var lastFoldEndColumn = 0; var lastFoldEndColumn = 0;
var fold;
for (var i = 0; i < this.folds.length; i++) { for (var i = 0; i < this.folds.length; i++) {
var fold = this.folds[i]; var fold = this.folds[i];
@ -261,7 +260,7 @@ function FoldLine(foldData, folds) {
row: this.end.row, row: this.end.row,
column: this.end.column + idx column: this.end.column + idx
}; };
} };
}).call(FoldLine.prototype); }).call(FoldLine.prototype);
exports.FoldLine = FoldLine; exports.FoldLine = FoldLine;

View file

@ -572,28 +572,28 @@ var Editor = function(renderer, session) {
token = iterator.stepForward(); token = iterator.stepForward();
if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) { if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value==='<'){ if (prevToken.value === '<'){
depth++; depth++;
} else if (prevToken.value==='</'){ } else if (prevToken.value === '</'){
depth--; depth--;
} }
} }
} while (token && depth>=0); } while (token && depth >= 0);
}else{ } else {
//find opening tag //find opening tag
do { do {
token = prevToken; token = prevToken;
prevToken = iterator.stepBackward(); prevToken = iterator.stepBackward();
if(token && token.value === tag && token.type.indexOf('tag-name') !== -1) { if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value==='<') { if (prevToken.value === '<') {
depth++; depth++;
} else if( prevToken.value==='</') { } else if (prevToken.value === '</') {
depth--; depth--;
} }
} }
} while (prevToken && depth<=0); } while (prevToken && depth <= 0);
//select tag again //select tag again
iterator.stepForward(); iterator.stepForward();

View file

@ -143,7 +143,7 @@ var Selection = function(session) {
**/ **/
this.getSelectionAnchor = function() { this.getSelectionAnchor = function() {
if (this.$isEmpty) if (this.$isEmpty)
return this.getSelectionLead() return this.getSelectionLead();
else else
return this.anchor.getPosition(); return this.anchor.getPosition();
}; };
@ -168,7 +168,7 @@ var Selection = function(session) {
if (this.$isEmpty) { if (this.$isEmpty) {
this.moveCursorTo(this.lead.row, this.lead.column + columns); this.moveCursorTo(this.lead.row, this.lead.column + columns);
return; return;
}; }
var anchor = this.getSelectionAnchor(); var anchor = this.getSelectionAnchor();
var lead = this.getSelectionLead(); var lead = this.getSelectionLead();
@ -474,7 +474,7 @@ var Selection = function(session) {
if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) { if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) {
this.moveCursorTo(fold.start.row, fold.start.column); this.moveCursorTo(fold.start.row, fold.start.column);
} else if (cursor.column == 0) { } else if (cursor.column === 0) {
// cursor is a line (start // cursor is a line (start
if (cursor.row > 0) { if (cursor.row > 0) {
this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length); this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length);
@ -639,7 +639,7 @@ var Selection = function(session) {
var str = this.session.getFoldStringAt(row, column, -1); var str = this.session.getFoldStringAt(row, column, -1);
if (str == null) { if (str == null) {
str = this.doc.getLine(row).substring(0, column) str = this.doc.getLine(row).substring(0, column);
} }
var leftOfCursor = lang.stringReverse(str); var leftOfCursor = lang.stringReverse(str);
@ -691,13 +691,13 @@ var Selection = function(session) {
index ++; index ++;
if (whitespaceRe.test(ch)) { if (whitespaceRe.test(ch)) {
if (index > 2) { if (index > 2) {
index-- index--;
break; break;
} else { } else {
while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch)) while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
index ++; index ++;
if (index > 2) if (index > 2)
break break;
} }
} }
} }
@ -722,11 +722,11 @@ var Selection = function(session) {
var l = this.doc.getLength(); var l = this.doc.getLength();
do { do {
row++; row++;
rightOfCursor = this.doc.getLine(row) rightOfCursor = this.doc.getLine(row);
} while (row < l && /^\s*$/.test(rightOfCursor)) } while (row < l && /^\s*$/.test(rightOfCursor));
if (!/^\s+/.test(rightOfCursor)) if (!/^\s+/.test(rightOfCursor))
rightOfCursor = "" rightOfCursor = "";
column = 0; column = 0;
} }
@ -744,15 +744,15 @@ var Selection = function(session) {
return this.moveCursorTo(fold.start.row, fold.start.column); return this.moveCursorTo(fold.start.row, fold.start.column);
var line = this.session.getLine(row).substring(0, column); var line = this.session.getLine(row).substring(0, column);
if (column == 0) { if (column === 0) {
do { do {
row--; row--;
line = this.doc.getLine(row); line = this.doc.getLine(row);
} while (row > 0 && /^\s*$/.test(line)) } while (row > 0 && /^\s*$/.test(line));
column = line.length; column = line.length;
if (!/\s+$/.test(line)) if (!/\s+$/.test(line))
line = "" line = "";
} }
var leftOfCursor = lang.stringReverse(line); var leftOfCursor = lang.stringReverse(line);
@ -859,12 +859,12 @@ var Selection = function(session) {
this.lead.detach(); this.lead.detach();
this.anchor.detach(); this.anchor.detach();
this.session = this.doc = null; this.session = this.doc = null;
} };
this.fromOrientedRange = function(range) { this.fromOrientedRange = function(range) {
this.setSelectionRange(range, range.cursor == range.start); this.setSelectionRange(range, range.cursor == range.start);
this.$desiredColumn = range.desiredColumn || this.$desiredColumn; this.$desiredColumn = range.desiredColumn || this.$desiredColumn;
} };
this.toOrientedRange = function(range) { this.toOrientedRange = function(range) {
var r = this.getRange(); var r = this.getRange();
@ -880,7 +880,7 @@ var Selection = function(session) {
range.cursor = this.isBackwards() ? range.start : range.end; range.cursor = this.isBackwards() ? range.start : range.end;
range.desiredColumn = this.$desiredColumn; range.desiredColumn = this.$desiredColumn;
return range; return range;
} };
/** /**
* Saves the current cursor position and calls `func` that can change the cursor * Saves the current cursor position and calls `func` that can change the cursor
@ -901,7 +901,7 @@ var Selection = function(session) {
} finally { } finally {
this.moveCursorToPosition(start); this.moveCursorToPosition(start);
} }
} };
this.toJSON = function() { this.toJSON = function() {
if (this.rangeCount) { if (this.rangeCount) {
@ -944,10 +944,10 @@ var Selection = function(session) {
for (var i = this.ranges.length; i--; ) { for (var i = this.ranges.length; i--; ) {
if (!this.ranges[i].isEqual(data[i])) if (!this.ranges[i].isEqual(data[i]))
return false return false;
} }
return true; return true;
} };
}).call(Selection.prototype); }).call(Selection.prototype);