tweak "show invisibles"
This commit is contained in:
parent
b5679cb6b6
commit
539aa4669c
1 changed files with 19 additions and 7 deletions
|
|
@ -10,9 +10,11 @@ ace.layer.Text = function(parentEl) {
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
// this.ENTER_CHAR = "¶";
|
// this.EOF_CHAR = "¶";
|
||||||
this.ENTER_CHAR = "¬";
|
this.EOF_CHAR = "¶";
|
||||||
this.TAB_CHAR = "‣";
|
this.EOL_CHAR = "¬";
|
||||||
|
// this.TAB_CHAR = "‣";
|
||||||
|
this.TAB_CHAR = "→";
|
||||||
|
|
||||||
this.setTokenizer = function(tokenizer) {
|
this.setTokenizer = function(tokenizer) {
|
||||||
this.tokenizer = tokenizer;
|
this.tokenizer = tokenizer;
|
||||||
|
|
@ -59,7 +61,12 @@ ace.layer.Text = function(parentEl) {
|
||||||
this.$computeTabString = function() {
|
this.$computeTabString = function() {
|
||||||
var tabSize = this.doc.getTabSize();
|
var tabSize = this.doc.getTabSize();
|
||||||
if (this.$showInvisibles) {
|
if (this.$showInvisibles) {
|
||||||
this.$tabString = "<span class='invisible'>" + this.TAB_CHAR + new Array(tabSize).join(" ") + "</span>";
|
var halfTab = (tabSize) / 2;
|
||||||
|
this.$tabString = "<span class='invisible'>"
|
||||||
|
+ new Array(Math.floor(halfTab)).join(" ")
|
||||||
|
+ this.TAB_CHAR
|
||||||
|
+ new Array(Math.ceil(halfTab)+1).join(" ")
|
||||||
|
+ "</span>";
|
||||||
} else {
|
} else {
|
||||||
this.$tabString = new Array(tabSize+1).join(" ");
|
this.$tabString = new Array(tabSize+1).join(" ");
|
||||||
}
|
}
|
||||||
|
|
@ -103,7 +110,7 @@ ace.layer.Text = function(parentEl) {
|
||||||
var output = token.value
|
var output = token.value
|
||||||
.replace(/&/g, "&")
|
.replace(/&/g, "&")
|
||||||
.replace(/</g, "<")
|
.replace(/</g, "<")
|
||||||
.replace(/\v\f \u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000/g, " ")
|
.replace(/[\v\f \u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000]/g, " ")
|
||||||
.replace(/\t/g, this.$tabString);
|
.replace(/\t/g, this.$tabString);
|
||||||
|
|
||||||
if (token.type !== "text") {
|
if (token.type !== "text") {
|
||||||
|
|
@ -114,8 +121,13 @@ ace.layer.Text = function(parentEl) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.$showInvisibles && row !== this.doc.getLength() - 1)
|
if (this.$showInvisibles) {
|
||||||
stringBuilder.push("<span class='invisible'>" + this.ENTER_CHAR + "</span>");
|
if (row !== this.doc.getLength() - 1) {
|
||||||
|
stringBuilder.push("<span class='invisible'>" + this.EOL_CHAR + "</span>");
|
||||||
|
} else {
|
||||||
|
stringBuilder.push("<span class='invisible'>" + this.EOF_CHAR + "</span>");
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}).call(ace.layer.Text.prototype);
|
}).call(ace.layer.Text.prototype);
|
||||||
Loading…
Add table
Add a link
Reference in a new issue