* Added ability to force ace to resize

* Automatically size the width via css
This commit is contained in:
Ruben Daniels 2012-06-13 22:18:15 -07:00
commit d9c0212fa1
3 changed files with 32 additions and 11 deletions

View file

@ -9,6 +9,7 @@
.ace_scroller {
position: absolute;
overflow: hidden;
width : 100%;
}
.ace_content {

View file

@ -249,8 +249,8 @@ var Editor = function(renderer, session) {
*
* {:VirtualRenderer.onResize}
**/
this.resize = function() {
this.renderer.onResize();
this.resize = function(force) {
this.renderer.onResize(force);
};
/**

View file

@ -264,8 +264,13 @@ var VirtualRenderer = function(container, theme) {
*
* Triggers a full update of all the layers, for all the rows.
**/
this.updateFull = function() {
this.$loop.schedule(this.CHANGE_FULL);
this.updateFull = function(force) {
if (force){
this.$renderChanges(this.CHANGE_FULL, true);
}
else {
this.$loop.schedule(this.CHANGE_FULL);
}
};
/**
@ -283,11 +288,19 @@ var VirtualRenderer = function(container, theme) {
*
* [Triggers a resize of the editor.]{: #VirtualRenderer.onResize}
**/
this.onResize = function(force) {
this.onResize = function(force, gutterWidth, width, height) {
var changes = this.CHANGE_SIZE;
var size = this.$size;
var height = dom.getInnerHeight(this.container);
if (this.resizing) {
force = 2;
height = size.height;
width = size.width;
}
this.resizing = force;
if (!height)
height = dom.getInnerHeight(this.container);
if (force || size.height != height) {
size.height = height;
@ -301,20 +314,27 @@ var VirtualRenderer = function(container, theme) {
}
}
var width = dom.getInnerWidth(this.container);
if (!width)
width = dom.getInnerWidth(this.container);
if (force || size.width != width) {
size.width = width;
var gutterWidth = this.showGutter ? this.$gutter.offsetWidth : 0;
this.scroller.style.left = gutterWidth + "px";
size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBar.getWidth());
this.scroller.style.width = size.scrollerWidth + "px";
//this.scroller.style.width = size.scrollerWidth + "px";
if (this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
changes = changes | this.CHANGE_FULL;
}
this.$loop.schedule(changes);
if (force || this.resizing)
this.$renderChanges(changes, true);
else
this.$loop.schedule(changes);
if (force === true)
delete this.resizing;
};
/**
@ -630,8 +650,8 @@ var VirtualRenderer = function(container, theme) {
this.scrollBar.setScrollTop(this.scrollTop);
};
this.$renderChanges = function(changes) {
if (!changes || !this.session || !this.container.offsetWidth)
this.$renderChanges = function(changes, force) {
if (!force && (!changes || !this.session || !this.container.offsetWidth))
return;
// text, scrolling and resize changes can cause the view port size to change