Merge pull request #1700 from ajaxorg/newclient

sync with cloud9
This commit is contained in:
Lennart Kats 2013-12-06 06:44:32 -08:00
commit 40ea516801
13 changed files with 140 additions and 101 deletions

View file

@ -127,6 +127,26 @@ exports.commands = [{
bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"), bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
exec: function(editor) { editor.findPrevious(); }, exec: function(editor) { editor.findPrevious(); },
readOnly: true readOnly: true
}, {
name: "selectOrFindNext",
bindKey: bindKey("ALt-K", "Ctrl-G"),
exec: function(editor) {
if (editor.selection.isEmpty())
editor.selection.selectWord();
else
editor.findNext();
},
readOnly: true
}, {
name: "selectOrFindPrevious",
bindKey: bindKey("Alt-Shift-K", "Ctrl-Shift-G"),
exec: function(editor) {
if (editor.selection.isEmpty())
editor.selection.selectWord();
else
editor.findPrevious();
},
readOnly: true
}, { }, {
name: "find", name: "find",
bindKey: bindKey("Ctrl-F", "Command-F"), bindKey: bindKey("Ctrl-F", "Command-F"),
@ -145,14 +165,14 @@ exports.commands = [{
exec: function(editor) { editor.getSelection().selectFileStart(); }, exec: function(editor) { editor.getSelection().selectFileStart(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
readOnly: true, readOnly: true,
group: "fileJump" aceCommandGroup: "fileJump"
}, { }, {
name: "gotostart", name: "gotostart",
bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"), bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
exec: function(editor) { editor.navigateFileStart(); }, exec: function(editor) { editor.navigateFileStart(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
readOnly: true, readOnly: true,
group: "fileJump" aceCommandGroup: "fileJump"
}, { }, {
name: "selectup", name: "selectup",
bindKey: bindKey("Shift-Up", "Shift-Up"), bindKey: bindKey("Shift-Up", "Shift-Up"),
@ -171,14 +191,14 @@ exports.commands = [{
exec: function(editor) { editor.getSelection().selectFileEnd(); }, exec: function(editor) { editor.getSelection().selectFileEnd(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
readOnly: true, readOnly: true,
group: "fileJump" aceCommandGroup: "fileJump"
}, { }, {
name: "gotoend", name: "gotoend",
bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"), bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"),
exec: function(editor) { editor.navigateFileEnd(); }, exec: function(editor) { editor.navigateFileEnd(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
readOnly: true, readOnly: true,
group: "fileJump" aceCommandGroup: "fileJump"
}, { }, {
name: "selectdown", name: "selectdown",
bindKey: bindKey("Shift-Down", "Shift-Down"), bindKey: bindKey("Shift-Down", "Shift-Down"),

View file

@ -25,6 +25,7 @@
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
cursor: text; cursor: text;
min-width: 100%;
} }
.ace_dragging, .ace_dragging * { .ace_dragging, .ace_dragging * {

View file

@ -952,8 +952,8 @@ var EditSession = function(text, mode) {
if (!$isPlaceholder) { if (!$isPlaceholder) {
this.$options.wrapMethod.set.call(this, this.$wrapMethod); this.$options.wrapMethod.set.call(this, this.$wrapMethod);
this.$setFolding(mode.foldingRules); this.$setFolding(mode.foldingRules);
this._emit("changeMode");
this.bgTokenizer.start(0); this.bgTokenizer.start(0);
this._emit("changeMode");
} }
}; };

View file

@ -128,13 +128,9 @@ function Folding() {
var folds = []; var folds = [];
var foldLines = this.$foldData; var foldLines = this.$foldData;
function addFold(fold) {
folds.push(fold);
}
for (var i = 0; i < foldLines.length; i++) for (var i = 0; i < foldLines.length; i++)
for (var j = 0; j < foldLines[i].folds.length; j++) for (var j = 0; j < foldLines[i].folds.length; j++)
addFold(foldLines[i].folds[j]); folds.push(foldLines[i].folds[j]);
return folds; return folds;
}; };
@ -655,12 +651,15 @@ function Folding() {
if (range && range.isMultiLine() if (range && range.isMultiLine()
&& range.end.row <= endRow && range.end.row <= endRow
&& range.start.row >= startRow && range.start.row >= startRow
) try { ) {
var fold = this.addFold("...", range);
fold.collapseChildren = depth;
// addFold can change the range
row = range.end.row; row = range.end.row;
} catch(e) {} try {
// addFold can change the range
var fold = this.addFold("...", range);
if (fold)
fold.collapseChildren = depth;
} catch(e) {}
}
} }
}; };
@ -753,6 +752,8 @@ function Folding() {
}; };
this.$toggleFoldWidget = function(row, options) { this.$toggleFoldWidget = function(row, options) {
if (!this.getFoldWidget)
return;
var type = this.getFoldWidget(row); var type = this.getFoldWidget(row);
var line = this.getLine(row); var line = this.getLine(row);

View file

@ -110,17 +110,17 @@ var Editor = function(renderer, session) {
oop.implement(this, EventEmitter); oop.implement(this, EventEmitter);
this.$initOperationListeners = function() { this.$initOperationListeners = function() {
function last(a) {return a[a.length - 1]}; function last(a) {return a[a.length - 1]}
this.selections = []; this.selections = [];
this.commands.on("exec", function(e) { this.commands.on("exec", function(e) {
this.startOperation(e); this.startOperation(e);
var command = e.command; var command = e.command;
if (command.group == "fileJump") { if (command.aceCommandGroup == "fileJump") {
var prev = this.prevOp; var prev = this.prevOp;
if (!prev || prev.command.group != "fileJump") { if (!prev || prev.command.aceCommandGroup != "fileJump") {
this.lastFileJumpPos = last(this.selections) this.lastFileJumpPos = last(this.selections);
} }
} else { } else {
this.lastFileJumpPos = null; this.lastFileJumpPos = null;
@ -130,10 +130,10 @@ var Editor = function(renderer, session) {
this.commands.on("afterExec", function(e) { this.commands.on("afterExec", function(e) {
var command = e.command; var command = e.command;
if (command.group == "fileJump") { if (command.aceCommandGroup == "fileJump") {
if (this.lastFileJumpPos && !this.curOp.selectionChanged) { if (this.lastFileJumpPos && !this.curOp.selectionChanged) {
this.selection.fromJSON(this.lastFileJumpPos); this.selection.fromJSON(this.lastFileJumpPos);
return return;
} }
} }
this.endOperation(e); this.endOperation(e);
@ -150,7 +150,7 @@ var Editor = function(renderer, session) {
this.curOp || this.startOperation(); this.curOp || this.startOperation();
this.curOp.selectionChanged = true; this.curOp.selectionChanged = true;
}.bind(this), true); }.bind(this), true);
} };
this.curOp = null; this.curOp = null;
this.prevOp = {}; this.prevOp = {};
@ -218,12 +218,12 @@ var Editor = function(renderer, session) {
shouldMerge = shouldMerge shouldMerge = shouldMerge
&& this.mergeNextCommand // previous command allows to coalesce with && this.mergeNextCommand // previous command allows to coalesce with
&& (!/\s/.test(text) || /\s/.test(prev.args)) // previous insertion was of same type && (!/\s/.test(text) || /\s/.test(prev.args)); // previous insertion was of same type
this.mergeNextCommand = true; this.mergeNextCommand = true;
} else { } else {
shouldMerge = shouldMerge shouldMerge = shouldMerge
&& mergeableCommands.indexOf(e.command.name) !== -1// the command is mergeable && mergeableCommands.indexOf(e.command.name) !== -1; // the command is mergeable
} }
if ( if (
@ -689,7 +689,7 @@ var Editor = function(renderer, session) {
this.$updateHighlightActiveLine(); this.$updateHighlightActiveLine();
} }
var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp() var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp();
this.session.highlight(re); this.session.highlight(re);
this._emit("changeSelection"); this._emit("changeSelection");
@ -1205,9 +1205,9 @@ var Editor = function(renderer, session) {
if (range.end.column == 0) { if (range.end.column == 0) {
var text = session.getTextRange(range); var text = session.getTextRange(range);
if (text[text.length - 1] == "\n") { if (text[text.length - 1] == "\n") {
var line = session.getLine(range.end.row) var line = session.getLine(range.end.row);
if (/^\s+$/.test(line)) { if (/^\s+$/.test(line)) {
range.end.column = line.length range.end.column = line.length;
} }
} }
} }
@ -1353,7 +1353,7 @@ var Editor = function(renderer, session) {
session.indentRows(rows.first, rows.last, "\t"); session.indentRows(rows.first, rows.last, "\t");
return; return;
} else if (range.start.column < range.end.column) { } else if (range.start.column < range.end.column) {
var text = session.getTextRange(range) var text = session.getTextRange(range);
if (!/^\s+$/.test(text)) { if (!/^\s+$/.test(text)) {
var rows = this.$getSelectedRows(); var rows = this.$getSelectedRows();
session.indentRows(rows.first, rows.last, "\t"); session.indentRows(rows.first, rows.last, "\t");
@ -1444,19 +1444,19 @@ var Editor = function(renderer, session) {
* Works like [[EditSession.getTokenAt]], except it returns a number. * Works like [[EditSession.getTokenAt]], except it returns a number.
* @returns {Number} * @returns {Number}
**/ **/
this.getNumberAt = function( row, column ) { this.getNumberAt = function(row, column) {
var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g;
_numberRx.lastIndex = 0 _numberRx.lastIndex = 0;
var s = this.session.getLine(row) var s = this.session.getLine(row);
while (_numberRx.lastIndex < column) { while (_numberRx.lastIndex < column) {
var m = _numberRx.exec(s) var m = _numberRx.exec(s);
if(m.index <= column && m.index+m[0].length >= column){ if(m.index <= column && m.index+m[0].length >= column){
var number = { var number = {
value: m[0], value: m[0],
start: m.index, start: m.index,
end: m.index+m[0].length end: m.index+m[0].length
} };
return number; return number;
} }
} }
@ -1542,7 +1542,7 @@ var Editor = function(renderer, session) {
range.start = point; range.start = point;
range.end = endPoint; range.end = endPoint;
sel.setSelectionRange(range, reverse) sel.setSelectionRange(range, reverse);
} }
}; };
@ -1827,7 +1827,7 @@ var Editor = function(renderer, session) {
var pos = { var pos = {
row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2), row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2),
column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2) column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2)
} };
this.renderer.alignCursor(pos, 0.5); this.renderer.alignCursor(pos, 0.5);
}; };

View file

@ -112,6 +112,8 @@ exports.capture = function(el, eventHandler, releaseCaptureHandler) {
exports.addListener(document, "mousemove", eventHandler, true); exports.addListener(document, "mousemove", eventHandler, true);
exports.addListener(document, "mouseup", onMouseUp, true); exports.addListener(document, "mouseup", onMouseUp, true);
exports.addListener(document, "dragstart", onMouseUp, true); exports.addListener(document, "dragstart", onMouseUp, true);
return onMouseUp;
}; };
exports.addMouseWheelListener = function(el, callback) { exports.addMouseWheelListener = function(el, callback) {

View file

@ -63,23 +63,22 @@ var C9SearchHighlightRules = function() {
var regex = stack[1]; var regex = stack[1];
var str = values[3]; var str = values[3];
if (regex && str)
values = str.split(regex); // this doesn't work on ie8 but we don't care:)
else
values = [str];
for (var i = 0, l = values.length; i < l; i+=2) { var m;
if (values[i]) var last = 0;
tokens.push({ if (regex) {
type: types[2], regex.lastIndex = 0;
value: values[i] while (m = regex.exec(str)) {
}); var skipped = str.substring(last, m.index);
if (values[i+1]) last = regex.lastIndex;
tokens.push({ if (skipped)
type: types[3], tokens.push({type: types[2], value: skipped});
value: values[i + 1] if (m[0])
}); tokens.push({type: types[3], value: m[0]});
}
} }
if (last < str.length)
tokens.push({type: types[2], value: str.substr(last)});
return tokens; return tokens;
} }
}, },
@ -102,7 +101,7 @@ var C9SearchHighlightRules = function() {
search = "\\b" + search + "\\b"; search = "\\b" + search + "\\b";
var regex = safeCreateRegexp( var regex = safeCreateRegexp(
"(" + search + ")", "(" + search + ")",
/ sensitive/.test(options) ? "" : "i" / sensitive/.test(options) ? "g" : "ig"
); );
if (regex) { if (regex) {
stack[0] = state; stack[0] = state;

View file

@ -7875,7 +7875,7 @@ Lexer.prototype = {
this.skip(); this.skip();
while (this.peek() !== quote) { outer: while (this.peek() !== quote) {
while (this.peek() === "") { // End Of Line while (this.peek() === "") { // End Of Line
// If an EOL is not preceded by a backslash, show a warning // If an EOL is not preceded by a backslash, show a warning
@ -7927,6 +7927,9 @@ Lexer.prototype = {
quote: quote quote: quote
}; };
} }
if (this.peek() == quote)
break outer;
} }
allowNewLine = false; allowNewLine = false;

View file

@ -115,6 +115,8 @@ var MouseHandler = function(editor) {
self.x = e.clientX; self.x = e.clientX;
self.y = e.clientY; self.y = e.clientY;
mouseMoveHandler && mouseMoveHandler(e); mouseMoveHandler && mouseMoveHandler(e);
self.mouseEvent = new MouseEvent(e, self.editor);
self.$mouseMoved = true;
}; };
var onCaptureEnd = function(e) { var onCaptureEnd = function(e) {
@ -127,20 +129,24 @@ var MouseHandler = function(editor) {
renderer.$moveTextAreaToCursor(); renderer.$moveTextAreaToCursor();
} }
self.isMousePressed = false; self.isMousePressed = false;
self.$onCaptureMouseMove = self.releaseMouse = null;
self.onMouseEvent("mouseup", e); self.onMouseEvent("mouseup", e);
}; };
var onCaptureInterval = function() { var onCaptureInterval = function() {
self[self.state] && self[self.state](); self[self.state] && self[self.state]();
self.$mouseMoved = false;
}; };
if (useragent.isOldIE && ev.domEvent.type == "dblclick") { if (useragent.isOldIE && ev.domEvent.type == "dblclick") {
return setTimeout(function() {onCaptureEnd(ev);}); return setTimeout(function() {onCaptureEnd(ev);});
} }
event.capture(this.editor.container, onMouseMove, onCaptureEnd); self.$onCaptureMouseMove = onMouseMove;
self.releaseMouse = event.capture(this.editor.container, onMouseMove, onCaptureEnd);
var timerId = setInterval(onCaptureInterval, 20); var timerId = setInterval(onCaptureInterval, 20);
}; };
this.releaseMouse = null;
}).call(MouseHandler.prototype); }).call(MouseHandler.prototype);
config.defineOptions(MouseHandler.prototype, "mouseHandler", { config.defineOptions(MouseHandler.prototype, "mouseHandler", {

View file

@ -696,7 +696,8 @@ var Editor = require("./editor").Editor;
range = session.getWordRange(range.start.row, range.start.column); range = session.getWordRange(range.start.row, range.start.column);
range.cursor = dir == -1 ? range.start : range.end; range.cursor = dir == -1 ? range.start : range.end;
this.multiSelect.addRange(range); this.multiSelect.addRange(range);
return; // todo add option for sublime like behavior
// return;
} }
var needle = session.getTextRange(range); var needle = session.getTextRange(range);

View file

@ -66,7 +66,7 @@ module.exports = {
MultiSelect(editor); MultiSelect(editor);
editor.navigateFileEnd(); editor.navigateFileEnd();
exec("selectMoreBefore", 4); exec("selectMoreBefore", 3);
assert.ok(editor.inMultiSelectMode); assert.ok(editor.inMultiSelectMode);
assert.equal(editor.selection.getAllRanges().length, 4); assert.equal(editor.selection.getAllRanges().length, 4);

View file

@ -95,7 +95,7 @@ var Tokenizer = function(rules) {
if (matchcount > 1) { if (matchcount > 1) {
if (/\\\d/.test(rule.regex)) { if (/\\\d/.test(rule.regex)) {
// Replace any backreferences and offset appropriately. // Replace any backreferences and offset appropriately.
adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function (match, digit) { adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function(match, digit) {
return "\\" + (parseInt(digit, 10) + matchTotal + 1); return "\\" + (parseInt(digit, 10) + matchTotal + 1);
}); });
} else { } else {
@ -222,6 +222,10 @@ var Tokenizer = function(rules) {
var currentState = startState || "start"; var currentState = startState || "start";
var state = this.states[currentState]; var state = this.states[currentState];
if (!state) {
currentState = "start";
state = this.states[currentState];
}
var mapping = this.matchMappings[currentState]; var mapping = this.matchMappings[currentState];
var re = this.regExps[currentState]; var re = this.regExps[currentState];
re.lastIndex = 0; re.lastIndex = 0;

View file

@ -228,8 +228,6 @@ var VirtualRenderer = function(container, theme) {
if (this.scrollMargin.top && session.getScrollTop() <= 0) if (this.scrollMargin.top && session.getScrollTop() <= 0)
session.setScrollTop(-this.scrollMargin.top); session.setScrollTop(-this.scrollMargin.top);
this.scroller.className = "ace_scroller";
this.$cursorLayer.setSession(session); this.$cursorLayer.setSession(session);
this.$markerBack.setSession(session); this.$markerBack.setSession(session);
this.$markerFront.setSession(session); this.$markerFront.setSession(session);
@ -359,6 +357,7 @@ var VirtualRenderer = function(container, theme) {
}; };
this.$updateCachedSize = function(force, gutterWidth, width, height) { this.$updateCachedSize = function(force, gutterWidth, width, height) {
height -= (this.$extraHeight || 0);
var changes = 0; var changes = 0;
var size = this.$size; var size = this.$size;
var oldSize = { var oldSize = {
@ -407,8 +406,7 @@ var VirtualRenderer = function(container, theme) {
changes = changes | this.CHANGE_FULL; changes = changes | this.CHANGE_FULL;
} }
if (size.$dirty) size.$dirty = !width || !height;
size.$dirty = !width && !height;
if (changes) if (changes)
this._signal("resize", oldSize); this._signal("resize", oldSize);
@ -749,13 +747,22 @@ var VirtualRenderer = function(container, theme) {
this.scrollBarH.setInnerWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h); this.scrollBarH.setInnerWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h);
this.scrollBarH.setScrollLeft(this.scrollLeft + this.scrollMargin.left); this.scrollBarH.setScrollLeft(this.scrollLeft + this.scrollMargin.left);
}; };
this.$frozen = false;
this.freeze = function() {
this.$frozen = true;
};
this.unfreeze = function() {
this.$frozen = false;
};
this.$renderChanges = function(changes, force) { this.$renderChanges = function(changes, force) {
if (this.$changes) { if (this.$changes) {
changes |= this.$changes; changes |= this.$changes;
this.$changes = 0; this.$changes = 0;
} }
if ((!this.session || !this.container.offsetWidth) || (!changes && !force)) { if ((!this.session || !this.container.offsetWidth || this.$frozen) || (!changes && !force)) {
this.$changes |= changes; this.$changes |= changes;
return; return;
} }
@ -769,6 +776,7 @@ var VirtualRenderer = function(container, theme) {
// this.$logChanges(changes); // this.$logChanges(changes);
this._signal("beforeRender"); this._signal("beforeRender");
var config = this.layerConfig;
// text, scrolling and resize changes can cause the view port size to change // text, scrolling and resize changes can cause the view port size to change
if (changes & this.CHANGE_FULL || if (changes & this.CHANGE_FULL ||
changes & this.CHANGE_SIZE || changes & this.CHANGE_SIZE ||
@ -776,27 +784,33 @@ var VirtualRenderer = function(container, theme) {
changes & this.CHANGE_LINES || changes & this.CHANGE_LINES ||
changes & this.CHANGE_SCROLL || changes & this.CHANGE_SCROLL ||
changes & this.CHANGE_H_SCROLL changes & this.CHANGE_H_SCROLL
) ) {
changes |= this.$computeLayerConfig(); changes |= this.$computeLayerConfig();
config = this.layerConfig;
// update scrollbar first to not lose scroll position when gutter calls resize
this.$updateScrollBarV();
if (changes & this.CHANGE_H_SCROLL)
this.$updateScrollBarH();
this.$gutterLayer.element.style.marginTop = (-config.offset) + "px";
this.content.style.marginTop = (-config.offset) + "px";
this.content.style.width = config.width + 2 * this.$padding + "px";
this.content.style.height = config.minHeight + "px";
}
// horizontal scrolling // horizontal scrolling
if (changes & this.CHANGE_H_SCROLL) { if (changes & this.CHANGE_H_SCROLL) {
this.$updateScrollBarH();
this.content.style.marginLeft = -this.scrollLeft + "px"; this.content.style.marginLeft = -this.scrollLeft + "px";
this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left"; this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left";
} }
// full // full
if (changes & this.CHANGE_FULL) { if (changes & this.CHANGE_FULL) {
// update scrollbar first to not lose scroll position when gutter calls resize this.$textLayer.update(config);
this.$updateScrollBarV();
this.$updateScrollBarH();
this.$textLayer.update(this.layerConfig);
if (this.$showGutter) if (this.$showGutter)
this.$gutterLayer.update(this.layerConfig); this.$gutterLayer.update(config);
this.$markerBack.update(this.layerConfig); this.$markerBack.update(config);
this.$markerFront.update(this.layerConfig); this.$markerFront.update(config);
this.$cursorLayer.update(this.layerConfig); this.$cursorLayer.update(config);
this.$moveTextAreaToCursor(); this.$moveTextAreaToCursor();
this.$highlightGutterLine && this.$updateGutterLineHighlight(); this.$highlightGutterLine && this.$updateGutterLineHighlight();
this._signal("afterRender"); this._signal("afterRender");
@ -805,17 +819,16 @@ var VirtualRenderer = function(container, theme) {
// scrolling // scrolling
if (changes & this.CHANGE_SCROLL) { if (changes & this.CHANGE_SCROLL) {
this.$updateScrollBarV();
if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES) if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES)
this.$textLayer.update(this.layerConfig); this.$textLayer.update(config);
else else
this.$textLayer.scrollLines(this.layerConfig); this.$textLayer.scrollLines(config);
if (this.$showGutter) if (this.$showGutter)
this.$gutterLayer.update(this.layerConfig); this.$gutterLayer.update(config);
this.$markerBack.update(this.layerConfig); this.$markerBack.update(config);
this.$markerFront.update(this.layerConfig); this.$markerFront.update(config);
this.$cursorLayer.update(this.layerConfig); this.$cursorLayer.update(config);
this.$highlightGutterLine && this.$updateGutterLineHighlight(); this.$highlightGutterLine && this.$updateGutterLineHighlight();
this.$moveTextAreaToCursor(); this.$moveTextAreaToCursor();
this._signal("afterRender"); this._signal("afterRender");
@ -823,49 +836,44 @@ var VirtualRenderer = function(container, theme) {
} }
if (changes & this.CHANGE_TEXT) { if (changes & this.CHANGE_TEXT) {
this.$textLayer.update(this.layerConfig); this.$textLayer.update(config);
if (this.$showGutter) if (this.$showGutter)
this.$gutterLayer.update(this.layerConfig); this.$gutterLayer.update(config);
} }
else if (changes & this.CHANGE_LINES) { else if (changes & this.CHANGE_LINES) {
if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.$showGutter) if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.$showGutter)
this.$gutterLayer.update(this.layerConfig); this.$gutterLayer.update(config);
} }
else if (changes & this.CHANGE_TEXT || changes & this.CHANGE_GUTTER) { else if (changes & this.CHANGE_TEXT || changes & this.CHANGE_GUTTER) {
if (this.$showGutter) if (this.$showGutter)
this.$gutterLayer.update(this.layerConfig); this.$gutterLayer.update(config);
} }
if (changes & this.CHANGE_CURSOR) { if (changes & this.CHANGE_CURSOR) {
this.$cursorLayer.update(this.layerConfig); this.$cursorLayer.update(config);
this.$moveTextAreaToCursor(); this.$moveTextAreaToCursor();
this.$highlightGutterLine && this.$updateGutterLineHighlight(); this.$highlightGutterLine && this.$updateGutterLineHighlight();
} }
if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) { if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) {
this.$markerFront.update(this.layerConfig); this.$markerFront.update(config);
} }
if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) { if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) {
this.$markerBack.update(this.layerConfig); this.$markerBack.update(config);
}
if (changes & this.CHANGE_SIZE || changes & this.CHANGE_LINES) {
this.$updateScrollBarV();
this.$updateScrollBarH();
} }
this._signal("afterRender"); this._signal("afterRender");
}; };
this.$autosize = function(height, width) { this.$autosize = function() {
var height = this.session.getScreenLength() * this.lineHeight; var height = this.session.getScreenLength() * this.lineHeight;
var maxHeight = this.$maxLines * this.lineHeight; var maxHeight = this.$maxLines * this.lineHeight;
var desiredHeight = Math.max( var desiredHeight = Math.max(
(this.$minLines||1) * this.lineHeight, (this.$minLines||1) * this.lineHeight,
Math.min(maxHeight, height) Math.min(maxHeight, height)
); ) + this.scrollMargin.v + (this.$extraHeight || 0);
var vScroll = height > maxHeight; var vScroll = height > maxHeight;
if (desiredHeight != this.desiredHeight || if (desiredHeight != this.desiredHeight ||
@ -890,7 +898,7 @@ var VirtualRenderer = function(container, theme) {
var session = this.session; var session = this.session;
var hideScrollbars = this.$size.height <= 2 * this.lineHeight; var hideScrollbars = this.$size.height <= 2 * this.lineHeight;
var screenLines = this.session.getScreenLength() var screenLines = this.session.getScreenLength();
var maxHeight = screenLines * this.lineHeight; var maxHeight = screenLines * this.lineHeight;
var offset = this.scrollTop % this.lineHeight; var offset = this.scrollTop % this.lineHeight;
@ -981,12 +989,6 @@ var VirtualRenderer = function(container, theme) {
// For debugging. // For debugging.
// console.log(JSON.stringify(this.layerConfig)); // console.log(JSON.stringify(this.layerConfig));
this.$gutterLayer.element.style.marginTop = (-offset) + "px";
this.content.style.marginTop = (-offset) + "px";
this.content.style.width = longestLine + 2 * this.$padding + "px";
this.content.style.height = minHeight + "px";
return changes;
return changes; return changes;
}; };