Merge master, update content

This commit is contained in:
Garen Torikian 2012-04-16 21:14:50 -07:00
commit c2caee8024
79 changed files with 3178 additions and 767 deletions

View file

@ -76,13 +76,13 @@ dom.importCssString(editorCss, "ace_editor");
var VirtualRenderer = function(container, theme) {
var _self = this;
this.container = container;
// TODO: this breaks rendering in Cloud9 with multiple ace instances
// // Imports CSS once per DOM document ('ace_editor' serves as an identifier).
// dom.importCssString(editorCss, "ace_editor", container.ownerDocument);
dom.addCssClass(container, "ace_editor");
this.setTheme(theme);
@ -100,8 +100,8 @@ var VirtualRenderer = function(container, theme) {
this.scroller.appendChild(this.content);
this.$gutterLayer = new GutterLayer(this.$gutter);
this.$gutterLayer.on("changeGutterWidth", this.onResize.bind(this, true));
this.$gutterLayer.on("changeGutterWidth", this.onResize.bind(this, true));
this.$markerBack = new MarkerLayer(this.content);
var textLayer = this.$textLayer = new TextLayer(this.content);
@ -119,6 +119,8 @@ var VirtualRenderer = function(container, theme) {
this.$horizScroll = true;
this.$horizScrollAlwaysVisible = true;
this.$animatedScroll = false;
this.scrollBar = new ScrollBar(container);
this.scrollBar.addEventListener("scroll", function(e) {
_self.session.setScrollTop(e.data);
@ -126,11 +128,18 @@ var VirtualRenderer = function(container, theme) {
this.scrollTop = 0;
this.scrollLeft = 0;
event.addListener(this.scroller, "scroll", function() {
var scrollLeft = _self.scroller.scrollLeft;
_self.scrollLeft = scrollLeft;
_self.session.setScrollLeft(scrollLeft);
if (scrollLeft == 0) {
_self.$gutter.className = "ace_gutter";
}
else {
_self.$gutter.className = "ace_gutter horscroll";
}
});
this.cursorPos = {
@ -316,6 +325,26 @@ var VirtualRenderer = function(container, theme) {
return this.session.adjustWrapLimit(limit);
};
/**
* VirtualRenderer.setAnimatedScroll(shouldAnimate) -> Void
* - shouldAnimate (Boolean): Set to `true` to show animated scrolls
*
* Identifies whether you want to have an animated scroll or not.
*
**/
this.setAnimatedScroll = function(shouldAnimate){
this.$animatedScroll = shouldAnimate;
};
/**
* VirtualRenderer.getAnimatedScroll() -> Boolean
*
* Returns whether an animated scroll happens or not.
**/
this.getAnimatedScroll = function() {
return this.$animatedScroll;
};
/**
* VirtualRenderer.setShowInvisibles(showInvisibles) -> Void
* - showInvisibles (Boolean): Set to `true` to show invisibles
@ -331,7 +360,7 @@ var VirtualRenderer = function(container, theme) {
/**
* VirtualRenderer.getShowInvisibles() -> Boolean
*
* Returns whether or not invisible characters are being shown or not.
* Returns whether invisible characters are being shown or not.
**/
this.getShowInvisibles = function() {
return this.$textLayer.showInvisibles;
@ -354,7 +383,7 @@ var VirtualRenderer = function(container, theme) {
/**
* VirtualRenderer.getShowPrintMargin() -> Boolean
*
* Returns whether or not the print margin is being shown or not.
* Returns whetherthe print margin is being shown or not.
**/
this.getShowPrintMargin = function() {
return this.$showPrintMargin;
@ -377,7 +406,7 @@ var VirtualRenderer = function(container, theme) {
/**
* VirtualRenderer.getPrintMarginColumn() -> Boolean
*
* Returns whether or not the print margin column is being shown or not.
* Returns whether the print margin column is being shown or not.
**/
this.getPrintMarginColumn = function() {
return this.$printMarginColumn;
@ -464,7 +493,7 @@ var VirtualRenderer = function(container, theme) {
// this persists in IE9
if (useragent.isIE)
return;
if (this.layerConfig.lastRow === 0)
return;
@ -538,7 +567,7 @@ var VirtualRenderer = function(container, theme) {
/**
* VirtualRenderer.getHScrollBarAlwaysVisible() -> Boolean
*
* Returns whether or not the horizontal scrollbar is set to be always visible.
* Returns whether the horizontal scrollbar is set to be always visible.
**/
this.getHScrollBarAlwaysVisible = function() {
return this.$horizScrollAlwaysVisible;
@ -579,13 +608,13 @@ var VirtualRenderer = function(container, theme) {
// horizontal scrolling
if (changes & this.CHANGE_H_SCROLL) {
this.scroller.scrollLeft = this.scrollLeft;
// read the value after writing it since the value might get clipped
var scrollLeft = this.scroller.scrollLeft;
this.scrollLeft = scrollLeft;
this.session.setScrollLeft(scrollLeft);
}
// full
if (changes & this.CHANGE_FULL) {
this.$textLayer.checkForSizeChanges();
@ -937,21 +966,27 @@ var VirtualRenderer = function(container, theme) {
this.session.setScrollTop(row * this.lineHeight);
};
/**
* VirtualRenderer.scrollToLine(line, center)
* - line (Number): The line to go to
* - center (Boolean): Identifies whether you want the cursor centered or not
*
* Scrolls the editor to the `line` indicated.
*
**/
this.scrollToLine = function(line, center) {
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
var offset = pos.top;
if (center)
offset -= this.$size.scrollerHeight / 2;
if (this.$animatedScroll && Math.abs(offset - this.scrollTop) < 10000) {
var _self = this;
var steps = _self.$calcSteps(this.scrollTop, offset);
clearInterval(this.$timer);
this.$timer = setInterval(function() {
_self.session.setScrollTop(steps.shift());
if (!steps.length)
clearInterval(_self.$timer);
}, 10);
}
else {
this.session.setScrollTop(offset);
}
};
/**
@ -1013,18 +1048,6 @@ var VirtualRenderer = function(container, theme) {
// todo: handle horizontal scrolling
};
/**
* VirtualRenderer.screenToTextCoordinates(pageX, pageY) -> Object
* - pageX (Number): The x-coordinate relative to the left edge of the document
* - pageY (Number): The y-coordinate relative to the top edge of the document
*
* Returns the document position, based on the coordinates provided.
*
* #### Returns
*
* The object returned has two properties: `row` and `column`.
*
**/
this.screenToTextCoordinates = function(pageX, pageY) {
var canvasPos = this.scroller.getBoundingClientRect();
@ -1160,7 +1183,7 @@ var VirtualRenderer = function(container, theme) {
return afterLoad(module);
_self._loadTheme(moduleName, function() {
require([theme], function(module) {
require([moduleName], function(module) {
if (_self.$themeValue !== theme)
return;