Merge pull request #1198 from danyaPostfactum/whitespaces
Display spaces when showInvisibles is on
This commit is contained in:
commit
d0ff5b7d85
3 changed files with 30 additions and 18 deletions
|
|
@ -223,23 +223,25 @@ var Text = function(parentEl) {
|
|||
if (this.showInvisibles) {
|
||||
tabStr.push("<span class='ace_invisible'>"
|
||||
+ this.TAB_CHAR
|
||||
+ Array(i).join(" ")
|
||||
+ lang.stringRepeat("\xa0", i - 1)
|
||||
+ "</span>");
|
||||
} else {
|
||||
tabStr.push(new Array(i+1).join(" "));
|
||||
tabStr.push(lang.stringRepeat("\xa0", i));
|
||||
}
|
||||
}
|
||||
if (this.displayIndentGuides) {
|
||||
this.$indentGuideRe = /\s\S| \t|\t |\s$/;
|
||||
var className = "ace_indent-guide";
|
||||
var content = Array(this.tabSize + 1).join(" ");
|
||||
var tabContent = content;
|
||||
if (this.showInvisibles) {
|
||||
className += " ace_invisible";
|
||||
tabContent = this.TAB_CHAR + content.substr(6);
|
||||
var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
|
||||
var tabContent = this.TAB_CHAR + lang.stringRepeat("\xa0", this.tabSize - 1);
|
||||
} else{
|
||||
var spaceContent = lang.stringRepeat("\xa0", this.tabSize);
|
||||
var tabContent = spaceContent;
|
||||
}
|
||||
|
||||
this.$tabStrings[" "] = "<span class='" + className + "'>" + content + "</span>";
|
||||
this.$tabStrings[" "] = "<span class='" + className + "'>" + spaceContent + "</span>";
|
||||
this.$tabStrings["\t"] = "<span class='" + className + "'>" + tabContent + "</span>";
|
||||
}
|
||||
};
|
||||
|
|
@ -411,7 +413,9 @@ var Text = function(parentEl) {
|
|||
var replaceReg = /\t|&|<|( +)|([\x00-\x1f\x80-\xa0\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g;
|
||||
var replaceFunc = function(c, a, b, tabIdx, idx4) {
|
||||
if (a) {
|
||||
return new Array(c.length+1).join(" ");
|
||||
return self.showInvisibles ?
|
||||
"<span class='ace_invisible'>" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "</span>" :
|
||||
lang.stringRepeat("\xa0", c.length);
|
||||
} else if (c == "&") {
|
||||
return "&";
|
||||
} else if (c == "<") {
|
||||
|
|
@ -459,10 +463,10 @@ var Text = function(parentEl) {
|
|||
return value;
|
||||
if (value[0] == " ") {
|
||||
cols -= cols % this.tabSize;
|
||||
stringBuilder.push(Array(cols/this.tabSize + 1).join(this.$tabStrings[" "]));
|
||||
stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize));
|
||||
return value.substr(cols);
|
||||
} else if (value[0] == "\t") {
|
||||
stringBuilder.push(Array(cols + 1).join(this.$tabStrings["\t"]));
|
||||
stringBuilder.push(lang.stringRepeat(this.$tabStrings["\t"], cols));
|
||||
return value.substr(cols);
|
||||
}
|
||||
return value;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,15 @@ exports.stringReverse = function(string) {
|
|||
};
|
||||
|
||||
exports.stringRepeat = function (string, count) {
|
||||
return new Array(count + 1).join(string);
|
||||
var result = '';
|
||||
while (count > 0) {
|
||||
if (count & 1)
|
||||
result += string;
|
||||
|
||||
if (count >>= 1)
|
||||
string += string;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
var trimBeginRegexp = /^\s\s*/;
|
||||
|
|
|
|||
|
|
@ -780,23 +780,23 @@ var Editor = require("./editor").Editor;
|
|||
return m;
|
||||
}).map(isLeftAligned ? isRightAligned ? alignRight : alignLeft : unAlign);
|
||||
|
||||
function strRepeat(n, ch) {
|
||||
return Array(n + 1).join(ch)
|
||||
function spaces(n) {
|
||||
return lang.stringRepeat(" ", n);
|
||||
}
|
||||
|
||||
function alignLeft(m) {
|
||||
return !m[2] ? m[0] : strRepeat(startW, " ") + m[2]
|
||||
+ strRepeat(textW - m[2].length + endW, " ")
|
||||
return !m[2] ? m[0] : spaces(startW) + m[2]
|
||||
+ spaces(textW - m[2].length + endW)
|
||||
+ m[4].replace(/^([=:])\s+/, "$1 ")
|
||||
}
|
||||
function alignRight(m) {
|
||||
return !m[2] ? m[0] : strRepeat(startW + textW - m[2].length, " ") + m[2]
|
||||
+ strRepeat(endW, " ")
|
||||
return !m[2] ? m[0] : spaces(startW + textW - m[2].length) + m[2]
|
||||
+ spaces(endW, " ")
|
||||
+ m[4].replace(/^([=:])\s+/, "$1 ")
|
||||
}
|
||||
function unAlign(m) {
|
||||
return !m[2] ? m[0] : strRepeat(startW, " ") + m[2]
|
||||
+ strRepeat(endW, " ")
|
||||
return !m[2] ? m[0] : spaces(startW) + m[2]
|
||||
+ spaces(endW)
|
||||
+ m[4].replace(/^([=:])\s+/, "$1 ")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue