fix toggle show invisibles and add it to the demo

This commit is contained in:
Fabian Jakobs 2011-01-10 11:18:57 +01:00
commit 1c432b976c
4 changed files with 64 additions and 42 deletions

View file

@ -129,14 +129,18 @@ var Text = function(parentEl) {
this.doc = doc;
};
this.$showInvisibles = false;
this.showInvisibles = false;
this.setShowInvisibles = function(showInvisibles) {
this.$showInvisibles = showInvisibles;
if (this.showInvisibles == showInvisibles)
return false;
this.showInvisibles = showInvisibles;
return true;
};
this.$computeTabString = function() {
var tabSize = this.doc.getTabSize();
if (this.$showInvisibles) {
if (this.showInvisibles) {
var halfTab = (tabSize) / 2;
this.$tabString = "<span class='ace_invisible'>"
+ new Array(Math.floor(halfTab)).join("&nbsp;")
@ -263,7 +267,7 @@ var Text = function(parentEl) {
};
this.$renderLine = function(stringBuilder, row, tokens) {
// if (this.$showInvisibles) {
// if (this.showInvisibles) {
// var self = this;
// var spaceRe = /[\v\f \u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000]+/g;
// var spaceReplace = function(space) {
@ -294,7 +298,7 @@ var Text = function(parentEl) {
}
};
if (this.$showInvisibles) {
if (this.showInvisibles) {
if (row !== this.doc.getLength() - 1) {
stringBuilder.push("<span class='ace_invisible'>" + this.EOL_CHAR + "</span>");
} else {

View file

@ -229,16 +229,13 @@ var VirtualRenderer = function(container, theme) {
});
};
this.$showInvisibles = true;
this.setShowInvisibles = function(showInvisibles) {
this.$showInvisibles = showInvisibles;
this.$textLayer.setShowInvisibles(showInvisibles);
this.$loop.schedule(this.CHANGE_TEXT);
if (this.$textLayer.setShowInvisibles(showInvisibles))
this.$loop.schedule(this.CHANGE_TEXT);
};
this.getShowInvisibles = function() {
return this.$showInvisibles;
return this.$textLayer.showInvisibles;
};
this.$showPrintMargin = true;
@ -453,7 +450,7 @@ var VirtualRenderer = function(container, theme) {
this.$getLongestLine = function() {
var charCount = this.doc.getScreenWidth();
if (this.$showInvisibles)
if (this.$textLayer.showInvisibles)
charCount += 1;
return Math.max(this.$size.scrollerWidth - this.$padding * 2, Math.round(charCount * this.characterWidth));