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

View file

@ -981,7 +981,7 @@ function normalizeCommandKeys(callback, e, keyCode) {
exports.addCommandKeyListener = function(el, callback) {
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
// 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.
@ -1002,18 +1002,6 @@ exports.addCommandKeyListener = function(el, callback) {
lastDown = e.keyIdentifier || 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;
}
});
}
}
};
@ -1651,7 +1639,7 @@ exports.get = function (url, callback) {
var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
exports.createXhr = function () {
exports.createXhr = function() {
//Would love to dump the ActiveX crap in here. Need IE 6 to die first.
var xhr, i, progId;
if (typeof XMLHttpRequest !== "undefined") {
@ -3171,6 +3159,7 @@ var Editor = function(renderer, session) {
this.setFontSize = function(size) {
this.container.style.fontSize = size;
this.renderer.updateFontSize();
};
this.$highlightBrackets = function() {
@ -4155,8 +4144,7 @@ var Editor = function(renderer, session) {
var range = this.$search.find(this.session);
if (range) {
this.session.unfold(range);
this.gotoLine(range.end.row+1, range.end.column);
this.selection.setSelectionRange(range);
this.selection.setSelectionRange(range); // this scrolls selection into view
}
};
@ -5900,6 +5888,11 @@ exports.commands = [{
bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
exec: function(editor) { editor.commands.replay(editor); },
readOnly: true
}, {
name: "jumptomatching",
bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
exec: function(editor) { editor.jumpToMatching(); },
readOnly: true
},
// commands disabled in readOnly mode
@ -6018,10 +6011,6 @@ exports.commands = [{
name: "tolowercase",
bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
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) {
var foldWidgets = this.foldWidgets;
endRow = endRow || foldWidgets.length;
endRow = endRow || this.getLength();
for (var row = startRow || 0; row < endRow; row++) {
if (foldWidgets[row] == null)
foldWidgets[row] = this.getFoldWidget(row);
@ -12244,7 +12233,7 @@ var VirtualRenderer = function(container, theme) {
column : 0
};
this.$textLayer.addEventListener("changeCharaterSize", function() {
this.$textLayer.addEventListener("changeCharacterSize", function() {
_self.characterWidth = textLayer.getCharacterWidth();
_self.lineHeight = textLayer.getLineHeight();
_self.$updatePrintMargin();
@ -12297,6 +12286,7 @@ var VirtualRenderer = function(container, theme) {
this.CHANGE_MARKER_BACK = 128;
this.CHANGE_MARKER_FRONT = 256;
this.CHANGE_FULL = 512;
this.CHANGE_H_SCROLL = 1024;
oop.implement(this, EventEmitter);
@ -12602,6 +12592,11 @@ var VirtualRenderer = function(container, theme) {
if (changes & this.CHANGE_SIZE)
this.$updateScrollBar();
if (changes & this.CHANGE_H_SCROLL) {
//this.content.style.left = -this.scrollLeft + "px";
this.scroller.scrollLeft = this.scrollLeft
}
};
this.$computeLayerConfig = function() {
@ -12668,12 +12663,6 @@ var VirtualRenderer = function(container, theme) {
this.content.style.width = longestLine + 2 * this.$padding + "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
// the client height of the scroller
if (horizScrollChanged)
@ -12779,14 +12768,11 @@ var VirtualRenderer = function(container, theme) {
if (scrollLeft > left) {
if (left < this.$padding + 2 * this.layerConfig.characterWidth)
left = 0;
this.scrollToX(left);
this.session.setScrollLeft(left);
}
if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
if (left > this.layerConfig.width + 2 * this.$padding)
this.$desiredScrollLeft = left;
else
this.scrollToX(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
}
};
@ -12811,15 +12797,11 @@ var VirtualRenderer = function(container, theme) {
};
this.scrollToLine = function(line, center) {
var lineHeight = { lineHeight: this.lineHeight };
var offset = 0;
for (var l = 1; l < line; l++) {
offset += this.session.getRowHeight(lineHeight, l-1);
}
if (center) {
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
var offset = pos.top;
if (center)
offset -= this.$size.scrollerHeight / 2;
}
this.session.setScrollTop(offset);
};
@ -12836,8 +12818,10 @@ var VirtualRenderer = function(container, theme) {
if (scrollLeft <= this.$padding)
scrollLeft = 0;
this.scroller.scrollLeft = scrollLeft;
scrollLeft = this.scroller.scrollLeft;
if (this.scrollLeft !== scrollLeft) {
this.$loop.schedule(this.CHANGE_H_SCROLL);
this.scrollLeft = scrollLeft;
}
};
this.scrollBy = function(deltaX, deltaY) {
@ -13480,7 +13464,7 @@ var Text = function(parentEl) {
var size = this.$measureSizes();
if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
this.$characterSize = size;
this._emit("changeCharaterSize", {data: size});
this._emit("changeCharacterSize", {data: size});
}
};
@ -14058,7 +14042,7 @@ var Cursor = function(parentEl) {
}, 1000);
};
this.getPixelPosition = function(onScreen) {
this.getPixelPosition = function(position, onScreen) {
if (!this.config || !this.session) {
return {
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 cursorLeft = Math.round(this.$padding +
pos.column * this.config.characterWidth);
@ -14082,7 +14067,7 @@ var Cursor = function(parentEl) {
this.update = function(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.top = this.pixelPos.top + "px";

File diff suppressed because it is too large Load diff