This commit is contained in:
Fabian Jakobs 2012-01-06 11:45:09 +01:00
commit c824e608d8
12 changed files with 4444 additions and 373 deletions

File diff suppressed because it is too large Load diff

View file

@ -11,7 +11,7 @@
Ace Ace
version 0.2.0 version 0.2.0
commit c52d1b203027b580564254c830a28dab4b8ad1b3 commit cf6f4d88d3345142a83de55bd686e8f2da74e1ce
--> -->

File diff suppressed because one or more lines are too long

View file

@ -2029,7 +2029,7 @@ function normalizeCommandKeys(callback, e, keyCode) {
exports.addCommandKeyListener = function(el, callback) { exports.addCommandKeyListener = function(el, callback) {
var addListener = exports.addListener; var addListener = exports.addListener;
if (useragent.isOldGecko) { if (useragent.isOldGecko || useragent.isOpera) {
// Old versions of Gecko aka. Firefox < 4.0 didn't repeat the keydown // Old versions of Gecko aka. Firefox < 4.0 didn't repeat the keydown
// event if the user pressed the key for a longer time. Instead, the // event if the user pressed the key for a longer time. Instead, the
// keydown event was fired once and later on only the keypress event. // keydown event was fired once and later on only the keypress event.
@ -2050,18 +2050,6 @@ exports.addCommandKeyListener = function(el, callback) {
lastDown = e.keyIdentifier || e.keyCode; lastDown = e.keyIdentifier || e.keyCode;
return normalizeCommandKeys(callback, e, e.keyCode); return normalizeCommandKeys(callback, e, e.keyCode);
}); });
// repeated keys are fired as keypress and not keydown events
if (useragent.isMac && useragent.isOpera) {
addListener(el, "keypress", function(e) {
var keyId = e.keyIdentifier || e.keyCode;
if (lastDown !== keyId) {
return normalizeCommandKeys(callback, e, lastDown);
} else {
lastDown = null;
}
});
}
} }
}; };
@ -2605,6 +2593,7 @@ var Editor = function(renderer, session) {
this.setFontSize = function(size) { this.setFontSize = function(size) {
this.container.style.fontSize = size; this.container.style.fontSize = size;
this.renderer.updateFontSize();
}; };
this.$highlightBrackets = function() { this.$highlightBrackets = function() {
@ -3589,8 +3578,7 @@ var Editor = function(renderer, session) {
var range = this.$search.find(this.session); var range = this.$search.find(this.session);
if (range) { if (range) {
this.session.unfold(range); this.session.unfold(range);
this.gotoLine(range.end.row+1, range.end.column); this.selection.setSelectionRange(range); // this scrolls selection into view
this.selection.setSelectionRange(range);
} }
}; };
@ -5334,6 +5322,11 @@ exports.commands = [{
bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"), bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
exec: function(editor) { editor.commands.replay(editor); }, exec: function(editor) { editor.commands.replay(editor); },
readOnly: true readOnly: true
}, {
name: "jumptomatching",
bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
exec: function(editor) { editor.jumpToMatching(); },
readOnly: true
}, },
// commands disabled in readOnly mode // commands disabled in readOnly mode
@ -5452,10 +5445,6 @@ exports.commands = [{
name: "tolowercase", name: "tolowercase",
bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"), bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
exec: function(editor) { editor.toLowerCase(); } exec: function(editor) { editor.toLowerCase(); }
}, {
name: "jumptomatching",
bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
exec: function(editor) { editor.jumpToMatching(); }
}]; }];
}); });
@ -10106,7 +10095,7 @@ function Folding() {
this.foldAll = function(startRow, endRow) { this.foldAll = function(startRow, endRow) {
var foldWidgets = this.foldWidgets; var foldWidgets = this.foldWidgets;
endRow = endRow || foldWidgets.length; endRow = endRow || this.getLength();
for (var row = startRow || 0; row < endRow; row++) { for (var row = startRow || 0; row < endRow; row++) {
if (foldWidgets[row] == null) if (foldWidgets[row] == null)
foldWidgets[row] = this.getFoldWidget(row); foldWidgets[row] = this.getFoldWidget(row);
@ -11678,7 +11667,7 @@ var VirtualRenderer = function(container, theme) {
column : 0 column : 0
}; };
this.$textLayer.addEventListener("changeCharaterSize", function() { this.$textLayer.addEventListener("changeCharacterSize", function() {
_self.characterWidth = textLayer.getCharacterWidth(); _self.characterWidth = textLayer.getCharacterWidth();
_self.lineHeight = textLayer.getLineHeight(); _self.lineHeight = textLayer.getLineHeight();
_self.$updatePrintMargin(); _self.$updatePrintMargin();
@ -11731,6 +11720,7 @@ var VirtualRenderer = function(container, theme) {
this.CHANGE_MARKER_BACK = 128; this.CHANGE_MARKER_BACK = 128;
this.CHANGE_MARKER_FRONT = 256; this.CHANGE_MARKER_FRONT = 256;
this.CHANGE_FULL = 512; this.CHANGE_FULL = 512;
this.CHANGE_H_SCROLL = 1024;
oop.implement(this, EventEmitter); oop.implement(this, EventEmitter);
@ -12036,6 +12026,11 @@ var VirtualRenderer = function(container, theme) {
if (changes & this.CHANGE_SIZE) if (changes & this.CHANGE_SIZE)
this.$updateScrollBar(); this.$updateScrollBar();
if (changes & this.CHANGE_H_SCROLL) {
//this.content.style.left = -this.scrollLeft + "px";
this.scroller.scrollLeft = this.scrollLeft
}
}; };
this.$computeLayerConfig = function() { this.$computeLayerConfig = function() {
@ -12102,12 +12097,6 @@ var VirtualRenderer = function(container, theme) {
this.content.style.width = longestLine + 2 * this.$padding + "px"; this.content.style.width = longestLine + 2 * this.$padding + "px";
this.content.style.height = minHeight + "px"; this.content.style.height = minHeight + "px";
// scroller.scrollWidth was smaller than scrollLeft we needed
if (this.$desiredScrollLeft) {
this.scrollToX(this.$desiredScrollLeft);
this.$desiredScrollLeft = 0;
}
// Horizontal scrollbar visibility may have changed, which changes // Horizontal scrollbar visibility may have changed, which changes
// the client height of the scroller // the client height of the scroller
if (horizScrollChanged) if (horizScrollChanged)
@ -12213,14 +12202,11 @@ var VirtualRenderer = function(container, theme) {
if (scrollLeft > left) { if (scrollLeft > left) {
if (left < this.$padding + 2 * this.layerConfig.characterWidth) if (left < this.$padding + 2 * this.layerConfig.characterWidth)
left = 0; left = 0;
this.scrollToX(left); this.session.setScrollLeft(left);
} }
if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) { if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
if (left > this.layerConfig.width + 2 * this.$padding) this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
this.$desiredScrollLeft = left;
else
this.scrollToX(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
} }
}; };
@ -12245,15 +12231,11 @@ var VirtualRenderer = function(container, theme) {
}; };
this.scrollToLine = function(line, center) { this.scrollToLine = function(line, center) {
var lineHeight = { lineHeight: this.lineHeight }; var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
var offset = 0; var offset = pos.top;
for (var l = 1; l < line; l++) { if (center)
offset += this.session.getRowHeight(lineHeight, l-1);
}
if (center) {
offset -= this.$size.scrollerHeight / 2; offset -= this.$size.scrollerHeight / 2;
}
this.session.setScrollTop(offset); this.session.setScrollTop(offset);
}; };
@ -12270,8 +12252,10 @@ var VirtualRenderer = function(container, theme) {
if (scrollLeft <= this.$padding) if (scrollLeft <= this.$padding)
scrollLeft = 0; scrollLeft = 0;
this.scroller.scrollLeft = scrollLeft; if (this.scrollLeft !== scrollLeft) {
scrollLeft = this.scroller.scrollLeft; this.$loop.schedule(this.CHANGE_H_SCROLL);
this.scrollLeft = scrollLeft;
}
}; };
this.scrollBy = function(deltaX, deltaY) { this.scrollBy = function(deltaX, deltaY) {
@ -12914,7 +12898,7 @@ var Text = function(parentEl) {
var size = this.$measureSizes(); var size = this.$measureSizes();
if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) { if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
this.$characterSize = size; this.$characterSize = size;
this._emit("changeCharaterSize", {data: size}); this._emit("changeCharacterSize", {data: size});
} }
}; };
@ -13492,7 +13476,7 @@ var Cursor = function(parentEl) {
}, 1000); }, 1000);
}; };
this.getPixelPosition = function(onScreen) { this.getPixelPosition = function(position, onScreen) {
if (!this.config || !this.session) { if (!this.config || !this.session) {
return { return {
left : 0, left : 0,
@ -13500,7 +13484,8 @@ var Cursor = function(parentEl) {
}; };
} }
var position = this.session.selection.getCursor(); if (!position)
position = this.session.selection.getCursor();
var pos = this.session.documentToScreenPosition(position); var pos = this.session.documentToScreenPosition(position);
var cursorLeft = Math.round(this.$padding + var cursorLeft = Math.round(this.$padding +
pos.column * this.config.characterWidth); pos.column * this.config.characterWidth);
@ -13516,7 +13501,7 @@ var Cursor = function(parentEl) {
this.update = function(config) { this.update = function(config) {
this.config = config; this.config = config;
this.pixelPos = this.getPixelPosition(true); this.pixelPos = this.getPixelPosition(null, true);
this.cursor.style.left = this.pixelPos.left + "px"; this.cursor.style.left = this.pixelPos.left + "px";
this.cursor.style.top = this.pixelPos.top + "px"; this.cursor.style.top = this.pixelPos.top + "px";

View file

@ -2029,7 +2029,7 @@ function normalizeCommandKeys(callback, e, keyCode) {
exports.addCommandKeyListener = function(el, callback) { exports.addCommandKeyListener = function(el, callback) {
var addListener = exports.addListener; var addListener = exports.addListener;
if (useragent.isOldGecko) { if (useragent.isOldGecko || useragent.isOpera) {
// Old versions of Gecko aka. Firefox < 4.0 didn't repeat the keydown // Old versions of Gecko aka. Firefox < 4.0 didn't repeat the keydown
// event if the user pressed the key for a longer time. Instead, the // event if the user pressed the key for a longer time. Instead, the
// keydown event was fired once and later on only the keypress event. // keydown event was fired once and later on only the keypress event.
@ -2050,18 +2050,6 @@ exports.addCommandKeyListener = function(el, callback) {
lastDown = e.keyIdentifier || e.keyCode; lastDown = e.keyIdentifier || e.keyCode;
return normalizeCommandKeys(callback, e, e.keyCode); return normalizeCommandKeys(callback, e, e.keyCode);
}); });
// repeated keys are fired as keypress and not keydown events
if (useragent.isMac && useragent.isOpera) {
addListener(el, "keypress", function(e) {
var keyId = e.keyIdentifier || e.keyCode;
if (lastDown !== keyId) {
return normalizeCommandKeys(callback, e, lastDown);
} else {
lastDown = null;
}
});
}
} }
}; };
@ -2605,6 +2593,7 @@ var Editor = function(renderer, session) {
this.setFontSize = function(size) { this.setFontSize = function(size) {
this.container.style.fontSize = size; this.container.style.fontSize = size;
this.renderer.updateFontSize();
}; };
this.$highlightBrackets = function() { this.$highlightBrackets = function() {
@ -3589,8 +3578,7 @@ var Editor = function(renderer, session) {
var range = this.$search.find(this.session); var range = this.$search.find(this.session);
if (range) { if (range) {
this.session.unfold(range); this.session.unfold(range);
this.gotoLine(range.end.row+1, range.end.column); this.selection.setSelectionRange(range); // this scrolls selection into view
this.selection.setSelectionRange(range);
} }
}; };
@ -5334,6 +5322,11 @@ exports.commands = [{
bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"), bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
exec: function(editor) { editor.commands.replay(editor); }, exec: function(editor) { editor.commands.replay(editor); },
readOnly: true readOnly: true
}, {
name: "jumptomatching",
bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
exec: function(editor) { editor.jumpToMatching(); },
readOnly: true
}, },
// commands disabled in readOnly mode // commands disabled in readOnly mode
@ -5452,10 +5445,6 @@ exports.commands = [{
name: "tolowercase", name: "tolowercase",
bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"), bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
exec: function(editor) { editor.toLowerCase(); } exec: function(editor) { editor.toLowerCase(); }
}, {
name: "jumptomatching",
bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
exec: function(editor) { editor.jumpToMatching(); }
}]; }];
}); });
@ -10106,7 +10095,7 @@ function Folding() {
this.foldAll = function(startRow, endRow) { this.foldAll = function(startRow, endRow) {
var foldWidgets = this.foldWidgets; var foldWidgets = this.foldWidgets;
endRow = endRow || foldWidgets.length; endRow = endRow || this.getLength();
for (var row = startRow || 0; row < endRow; row++) { for (var row = startRow || 0; row < endRow; row++) {
if (foldWidgets[row] == null) if (foldWidgets[row] == null)
foldWidgets[row] = this.getFoldWidget(row); foldWidgets[row] = this.getFoldWidget(row);
@ -11678,7 +11667,7 @@ var VirtualRenderer = function(container, theme) {
column : 0 column : 0
}; };
this.$textLayer.addEventListener("changeCharaterSize", function() { this.$textLayer.addEventListener("changeCharacterSize", function() {
_self.characterWidth = textLayer.getCharacterWidth(); _self.characterWidth = textLayer.getCharacterWidth();
_self.lineHeight = textLayer.getLineHeight(); _self.lineHeight = textLayer.getLineHeight();
_self.$updatePrintMargin(); _self.$updatePrintMargin();
@ -11731,6 +11720,7 @@ var VirtualRenderer = function(container, theme) {
this.CHANGE_MARKER_BACK = 128; this.CHANGE_MARKER_BACK = 128;
this.CHANGE_MARKER_FRONT = 256; this.CHANGE_MARKER_FRONT = 256;
this.CHANGE_FULL = 512; this.CHANGE_FULL = 512;
this.CHANGE_H_SCROLL = 1024;
oop.implement(this, EventEmitter); oop.implement(this, EventEmitter);
@ -12036,6 +12026,11 @@ var VirtualRenderer = function(container, theme) {
if (changes & this.CHANGE_SIZE) if (changes & this.CHANGE_SIZE)
this.$updateScrollBar(); this.$updateScrollBar();
if (changes & this.CHANGE_H_SCROLL) {
//this.content.style.left = -this.scrollLeft + "px";
this.scroller.scrollLeft = this.scrollLeft
}
}; };
this.$computeLayerConfig = function() { this.$computeLayerConfig = function() {
@ -12102,12 +12097,6 @@ var VirtualRenderer = function(container, theme) {
this.content.style.width = longestLine + 2 * this.$padding + "px"; this.content.style.width = longestLine + 2 * this.$padding + "px";
this.content.style.height = minHeight + "px"; this.content.style.height = minHeight + "px";
// scroller.scrollWidth was smaller than scrollLeft we needed
if (this.$desiredScrollLeft) {
this.scrollToX(this.$desiredScrollLeft);
this.$desiredScrollLeft = 0;
}
// Horizontal scrollbar visibility may have changed, which changes // Horizontal scrollbar visibility may have changed, which changes
// the client height of the scroller // the client height of the scroller
if (horizScrollChanged) if (horizScrollChanged)
@ -12213,14 +12202,11 @@ var VirtualRenderer = function(container, theme) {
if (scrollLeft > left) { if (scrollLeft > left) {
if (left < this.$padding + 2 * this.layerConfig.characterWidth) if (left < this.$padding + 2 * this.layerConfig.characterWidth)
left = 0; left = 0;
this.scrollToX(left); this.session.setScrollLeft(left);
} }
if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) { if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
if (left > this.layerConfig.width + 2 * this.$padding) this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
this.$desiredScrollLeft = left;
else
this.scrollToX(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
} }
}; };
@ -12245,15 +12231,11 @@ var VirtualRenderer = function(container, theme) {
}; };
this.scrollToLine = function(line, center) { this.scrollToLine = function(line, center) {
var lineHeight = { lineHeight: this.lineHeight }; var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
var offset = 0; var offset = pos.top;
for (var l = 1; l < line; l++) { if (center)
offset += this.session.getRowHeight(lineHeight, l-1);
}
if (center) {
offset -= this.$size.scrollerHeight / 2; offset -= this.$size.scrollerHeight / 2;
}
this.session.setScrollTop(offset); this.session.setScrollTop(offset);
}; };
@ -12270,8 +12252,10 @@ var VirtualRenderer = function(container, theme) {
if (scrollLeft <= this.$padding) if (scrollLeft <= this.$padding)
scrollLeft = 0; scrollLeft = 0;
this.scroller.scrollLeft = scrollLeft; if (this.scrollLeft !== scrollLeft) {
scrollLeft = this.scroller.scrollLeft; this.$loop.schedule(this.CHANGE_H_SCROLL);
this.scrollLeft = scrollLeft;
}
}; };
this.scrollBy = function(deltaX, deltaY) { this.scrollBy = function(deltaX, deltaY) {
@ -12914,7 +12898,7 @@ var Text = function(parentEl) {
var size = this.$measureSizes(); var size = this.$measureSizes();
if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) { if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
this.$characterSize = size; this.$characterSize = size;
this._emit("changeCharaterSize", {data: size}); this._emit("changeCharacterSize", {data: size});
} }
}; };
@ -13492,7 +13476,7 @@ var Cursor = function(parentEl) {
}, 1000); }, 1000);
}; };
this.getPixelPosition = function(onScreen) { this.getPixelPosition = function(position, onScreen) {
if (!this.config || !this.session) { if (!this.config || !this.session) {
return { return {
left : 0, left : 0,
@ -13500,7 +13484,8 @@ var Cursor = function(parentEl) {
}; };
} }
var position = this.session.selection.getCursor(); if (!position)
position = this.session.selection.getCursor();
var pos = this.session.documentToScreenPosition(position); var pos = this.session.documentToScreenPosition(position);
var cursorLeft = Math.round(this.$padding + var cursorLeft = Math.round(this.$padding +
pos.column * this.config.characterWidth); pos.column * this.config.characterWidth);
@ -13516,7 +13501,7 @@ var Cursor = function(parentEl) {
this.update = function(config) { this.update = function(config) {
this.config = config; this.config = config;
this.pixelPos = this.getPixelPosition(true); this.pixelPos = this.getPixelPosition(null, true);
this.cursor.style.left = this.pixelPos.left + "px"; this.cursor.style.left = this.pixelPos.left + "px";
this.cursor.style.top = this.pixelPos.top + "px"; this.cursor.style.top = this.pixelPos.top + "px";

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -981,7 +981,7 @@ function normalizeCommandKeys(callback, e, keyCode) {
exports.addCommandKeyListener = function(el, callback) { exports.addCommandKeyListener = function(el, callback) {
var addListener = exports.addListener; var addListener = exports.addListener;
if (useragent.isOldGecko) { if (useragent.isOldGecko || useragent.isOpera) {
// Old versions of Gecko aka. Firefox < 4.0 didn't repeat the keydown // Old versions of Gecko aka. Firefox < 4.0 didn't repeat the keydown
// event if the user pressed the key for a longer time. Instead, the // event if the user pressed the key for a longer time. Instead, the
// keydown event was fired once and later on only the keypress event. // keydown event was fired once and later on only the keypress event.
@ -1002,18 +1002,6 @@ exports.addCommandKeyListener = function(el, callback) {
lastDown = e.keyIdentifier || e.keyCode; lastDown = e.keyIdentifier || e.keyCode;
return normalizeCommandKeys(callback, e, e.keyCode); return normalizeCommandKeys(callback, e, e.keyCode);
}); });
// repeated keys are fired as keypress and not keydown events
if (useragent.isMac && useragent.isOpera) {
addListener(el, "keypress", function(e) {
var keyId = e.keyIdentifier || e.keyCode;
if (lastDown !== keyId) {
return normalizeCommandKeys(callback, e, lastDown);
} else {
lastDown = null;
}
});
}
} }
}; };
@ -3171,6 +3159,7 @@ var Editor = function(renderer, session) {
this.setFontSize = function(size) { this.setFontSize = function(size) {
this.container.style.fontSize = size; this.container.style.fontSize = size;
this.renderer.updateFontSize();
}; };
this.$highlightBrackets = function() { this.$highlightBrackets = function() {
@ -4155,8 +4144,7 @@ var Editor = function(renderer, session) {
var range = this.$search.find(this.session); var range = this.$search.find(this.session);
if (range) { if (range) {
this.session.unfold(range); this.session.unfold(range);
this.gotoLine(range.end.row+1, range.end.column); this.selection.setSelectionRange(range); // this scrolls selection into view
this.selection.setSelectionRange(range);
} }
}; };
@ -5900,6 +5888,11 @@ exports.commands = [{
bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"), bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
exec: function(editor) { editor.commands.replay(editor); }, exec: function(editor) { editor.commands.replay(editor); },
readOnly: true readOnly: true
}, {
name: "jumptomatching",
bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
exec: function(editor) { editor.jumpToMatching(); },
readOnly: true
}, },
// commands disabled in readOnly mode // commands disabled in readOnly mode
@ -6018,10 +6011,6 @@ exports.commands = [{
name: "tolowercase", name: "tolowercase",
bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"), bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
exec: function(editor) { editor.toLowerCase(); } exec: function(editor) { editor.toLowerCase(); }
}, {
name: "jumptomatching",
bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
exec: function(editor) { editor.jumpToMatching(); }
}]; }];
}); });
@ -10672,7 +10661,7 @@ function Folding() {
this.foldAll = function(startRow, endRow) { this.foldAll = function(startRow, endRow) {
var foldWidgets = this.foldWidgets; var foldWidgets = this.foldWidgets;
endRow = endRow || foldWidgets.length; endRow = endRow || this.getLength();
for (var row = startRow || 0; row < endRow; row++) { for (var row = startRow || 0; row < endRow; row++) {
if (foldWidgets[row] == null) if (foldWidgets[row] == null)
foldWidgets[row] = this.getFoldWidget(row); foldWidgets[row] = this.getFoldWidget(row);
@ -12244,7 +12233,7 @@ var VirtualRenderer = function(container, theme) {
column : 0 column : 0
}; };
this.$textLayer.addEventListener("changeCharaterSize", function() { this.$textLayer.addEventListener("changeCharacterSize", function() {
_self.characterWidth = textLayer.getCharacterWidth(); _self.characterWidth = textLayer.getCharacterWidth();
_self.lineHeight = textLayer.getLineHeight(); _self.lineHeight = textLayer.getLineHeight();
_self.$updatePrintMargin(); _self.$updatePrintMargin();
@ -12297,6 +12286,7 @@ var VirtualRenderer = function(container, theme) {
this.CHANGE_MARKER_BACK = 128; this.CHANGE_MARKER_BACK = 128;
this.CHANGE_MARKER_FRONT = 256; this.CHANGE_MARKER_FRONT = 256;
this.CHANGE_FULL = 512; this.CHANGE_FULL = 512;
this.CHANGE_H_SCROLL = 1024;
oop.implement(this, EventEmitter); oop.implement(this, EventEmitter);
@ -12602,6 +12592,11 @@ var VirtualRenderer = function(container, theme) {
if (changes & this.CHANGE_SIZE) if (changes & this.CHANGE_SIZE)
this.$updateScrollBar(); this.$updateScrollBar();
if (changes & this.CHANGE_H_SCROLL) {
//this.content.style.left = -this.scrollLeft + "px";
this.scroller.scrollLeft = this.scrollLeft
}
}; };
this.$computeLayerConfig = function() { this.$computeLayerConfig = function() {
@ -12668,12 +12663,6 @@ var VirtualRenderer = function(container, theme) {
this.content.style.width = longestLine + 2 * this.$padding + "px"; this.content.style.width = longestLine + 2 * this.$padding + "px";
this.content.style.height = minHeight + "px"; this.content.style.height = minHeight + "px";
// scroller.scrollWidth was smaller than scrollLeft we needed
if (this.$desiredScrollLeft) {
this.scrollToX(this.$desiredScrollLeft);
this.$desiredScrollLeft = 0;
}
// Horizontal scrollbar visibility may have changed, which changes // Horizontal scrollbar visibility may have changed, which changes
// the client height of the scroller // the client height of the scroller
if (horizScrollChanged) if (horizScrollChanged)
@ -12779,14 +12768,11 @@ var VirtualRenderer = function(container, theme) {
if (scrollLeft > left) { if (scrollLeft > left) {
if (left < this.$padding + 2 * this.layerConfig.characterWidth) if (left < this.$padding + 2 * this.layerConfig.characterWidth)
left = 0; left = 0;
this.scrollToX(left); this.session.setScrollLeft(left);
} }
if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) { if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
if (left > this.layerConfig.width + 2 * this.$padding) this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
this.$desiredScrollLeft = left;
else
this.scrollToX(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
} }
}; };
@ -12811,15 +12797,11 @@ var VirtualRenderer = function(container, theme) {
}; };
this.scrollToLine = function(line, center) { this.scrollToLine = function(line, center) {
var lineHeight = { lineHeight: this.lineHeight }; var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
var offset = 0; var offset = pos.top;
for (var l = 1; l < line; l++) { if (center)
offset += this.session.getRowHeight(lineHeight, l-1);
}
if (center) {
offset -= this.$size.scrollerHeight / 2; offset -= this.$size.scrollerHeight / 2;
}
this.session.setScrollTop(offset); this.session.setScrollTop(offset);
}; };
@ -12836,8 +12818,10 @@ var VirtualRenderer = function(container, theme) {
if (scrollLeft <= this.$padding) if (scrollLeft <= this.$padding)
scrollLeft = 0; scrollLeft = 0;
this.scroller.scrollLeft = scrollLeft; if (this.scrollLeft !== scrollLeft) {
scrollLeft = this.scroller.scrollLeft; this.$loop.schedule(this.CHANGE_H_SCROLL);
this.scrollLeft = scrollLeft;
}
}; };
this.scrollBy = function(deltaX, deltaY) { this.scrollBy = function(deltaX, deltaY) {
@ -13480,7 +13464,7 @@ var Text = function(parentEl) {
var size = this.$measureSizes(); var size = this.$measureSizes();
if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) { if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
this.$characterSize = size; this.$characterSize = size;
this._emit("changeCharaterSize", {data: size}); this._emit("changeCharacterSize", {data: size});
} }
}; };
@ -14058,7 +14042,7 @@ var Cursor = function(parentEl) {
}, 1000); }, 1000);
}; };
this.getPixelPosition = function(onScreen) { this.getPixelPosition = function(position, onScreen) {
if (!this.config || !this.session) { if (!this.config || !this.session) {
return { return {
left : 0, left : 0,
@ -14066,7 +14050,8 @@ var Cursor = function(parentEl) {
}; };
} }
var position = this.session.selection.getCursor(); if (!position)
position = this.session.selection.getCursor();
var pos = this.session.documentToScreenPosition(position); var pos = this.session.documentToScreenPosition(position);
var cursorLeft = Math.round(this.$padding + var cursorLeft = Math.round(this.$padding +
pos.column * this.config.characterWidth); pos.column * this.config.characterWidth);
@ -14082,7 +14067,7 @@ var Cursor = function(parentEl) {
this.update = function(config) { this.update = function(config) {
this.config = config; this.config = config;
this.pixelPos = this.getPixelPosition(true); this.pixelPos = this.getPixelPosition(null, true);
this.cursor.style.left = this.pixelPos.left + "px"; this.cursor.style.left = this.pixelPos.left + "px";
this.cursor.style.top = this.pixelPos.top + "px"; this.cursor.style.top = this.pixelPos.top + "px";

File diff suppressed because it is too large Load diff