зеркало из https://github.com/mozilla/ace.git
fix multi byte rendering (cursor position, selection)
This commit is contained in:
Родитель
38bc952daf
Коммит
4e21d9edd8
|
@ -78,7 +78,7 @@
|
|||
<option value="js">JS Document</option>
|
||||
<option value="html">HTML Document</option>
|
||||
<option value="css">CSS Document</option>
|
||||
<option value="python">Python Document</option>
|
||||
<option value="python" selected>Python Document</option>
|
||||
<option value="php">PHP Document</option>
|
||||
</select>
|
||||
</td>
|
||||
|
@ -90,7 +90,7 @@
|
|||
<option value="xml">XML</option>
|
||||
<option value="html">HTML</option>
|
||||
<option value="css">CSS</option>
|
||||
<option value="python">Python</option>
|
||||
<option value="python" selected>Python</option>
|
||||
<option value="php">PHP</option>
|
||||
</select>
|
||||
</td>
|
||||
|
@ -100,7 +100,7 @@
|
|||
<option value="ace/theme/textmate">TextMate</option>
|
||||
<option value="ace/theme/eclipse">Eclipse</option>
|
||||
<option value="ace/theme/dawn">Dawn</option>
|
||||
<option value="ace/theme/idle_fingers">idleFingers</option>
|
||||
<option value="ace/theme/idle_fingers" selected>idleFingers</option>
|
||||
<option value="ace/theme/pastel_on_dark">Pastel on dark</option>
|
||||
<option value="ace/theme/twilight">Twilight</option>
|
||||
</select>
|
||||
|
@ -118,7 +118,9 @@
|
|||
<input type="checkbox" name="show_hidden" id="show_hidden">
|
||||
</td>
|
||||
<td align="right">
|
||||
<img src="demo/logo.png">
|
||||
<div id="debuger" style="color: #fff;font-weight:bold;">
|
||||
info
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -163,6 +165,7 @@ import string, sys
|
|||
if len(sys.argv)==1:
|
||||
print 'Usage: celsius temp1 temp2 ...'
|
||||
sys.exit(0)
|
||||
print '这里是中文'
|
||||
|
||||
# Loop over the arguments
|
||||
for i in sys.argv[1:]:
|
||||
|
@ -200,6 +203,9 @@ echo $output;
|
|||
<script src="demo/require.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="demo/boot.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script type="text/javascript">
|
||||
window['debug'] = function(t){
|
||||
document.getElementById('debuger').innerHTML = t;
|
||||
}
|
||||
require("demo/boot");
|
||||
</script>
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ var EditSession = function(text, mode) {
|
|||
};
|
||||
|
||||
this.tokenRe = /^[\w\d]+/g;
|
||||
this.nonTokenRe = /^[^\w\d]+/g;
|
||||
this.nonTokenRe = /^[^\w\d|\x00-\xff]+/g;
|
||||
|
||||
this.getWordRange = function(row, column) {
|
||||
var line = this.getLine(row);
|
||||
|
@ -633,19 +633,23 @@ var EditSession = function(text, mode) {
|
|||
|
||||
var screenColumn = 0;
|
||||
var remaining = docColumn;
|
||||
|
||||
var line = this.getLine(row).split("\t");
|
||||
for (var i=0; i<line.length; i++) {
|
||||
var len = line[i].length;
|
||||
if (remaining > len) {
|
||||
remaining -= (len + 1);
|
||||
screenColumn += len + tabSize;
|
||||
}
|
||||
else {
|
||||
screenColumn += remaining;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var line = this.getLine(row);
|
||||
|
||||
for(var i=0; i<line.length; i++){
|
||||
var c = line[i];
|
||||
if(remaining > 0){
|
||||
remaining -= 1;
|
||||
if(c == '\t'){
|
||||
screenColumn += tabSize;
|
||||
} else if(/[^\x00-\xff]/.exec(c)){
|
||||
screenColumn += 2;
|
||||
} else {
|
||||
screenColumn += 1;
|
||||
}
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return screenColumn;
|
||||
};
|
||||
|
@ -655,23 +659,24 @@ var EditSession = function(text, mode) {
|
|||
|
||||
var docColumn = 0;
|
||||
var remaining = screenColumn;
|
||||
|
||||
var line = this.getLine(row).split("\t");
|
||||
for (var i=0; i<line.length; i++) {
|
||||
var len = line[i].length;
|
||||
if (remaining >= len + tabSize) {
|
||||
remaining -= (len + tabSize);
|
||||
docColumn += (len + 1);
|
||||
}
|
||||
else if (remaining > len){
|
||||
docColumn += len;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
docColumn += remaining;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var line = this.getLine(row);
|
||||
|
||||
for(var i=0; i<line.length; i++){
|
||||
var c = line[i];
|
||||
if(remaining > 0){
|
||||
docColumn += 1;
|
||||
if(c == '\t'){
|
||||
remaining -= tabSize;
|
||||
} else if(/[^\x00-\xff]/.exec(c)){
|
||||
remaining -= 2;
|
||||
} else {
|
||||
remaining -= 1;
|
||||
}
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return docColumn;
|
||||
};
|
||||
|
||||
|
|
|
@ -274,6 +274,17 @@ var Text = function(parentEl) {
|
|||
.replace(/</g, "<")
|
||||
.replace(spaceRe, spaceReplace)
|
||||
.replace(/\t/g, this.$tabString);
|
||||
|
||||
var buffer = '';
|
||||
for (var j=0;j<output.length;j++){
|
||||
var w = output.charAt(j);
|
||||
if(/[^\x00-\xff]/.exec(w)){
|
||||
buffer = buffer + "<span style='width: "+ this.config.characterWidth * 2 +"px; display: inline-block; text-align: center;'>" + w + "</span>";
|
||||
}else{
|
||||
buffer = buffer + w;
|
||||
}
|
||||
}
|
||||
output = buffer;
|
||||
|
||||
if (!this.$textToken[token.type]) {
|
||||
var classes = "ace_" + token.type.replace(/\./g, " ace_");
|
||||
|
|
|
@ -591,12 +591,35 @@ var VirtualRenderer = function(container, theme) {
|
|||
};
|
||||
|
||||
this.showComposition = function(position) {
|
||||
var cur = this.$cursorLayer.element.firstChild;
|
||||
var scroll = this.scroller;
|
||||
var top = (parseInt(cur.style.top) || 0) + (parseInt(scroll.style.top) || 0);
|
||||
var left = (parseInt(cur.style.left) || 0) + (parseInt(scroll.style.left) || 0);
|
||||
|
||||
var edit = document.getElementById("editor").lastChild;
|
||||
edit.style.color = '#66ff33';
|
||||
edit.style.top = (top - 1) + "px";
|
||||
edit.style.left = (left + 3) + "px";
|
||||
edit.style.background = "transparent";
|
||||
edit.style.border = "none";
|
||||
edit.style.resize = "none";
|
||||
edit.style.outline = "none";
|
||||
edit.style.width = "10000px";
|
||||
edit.style.height = "10000px";
|
||||
edit.style.fontSize = "12px";
|
||||
|
||||
this.hideCursor();
|
||||
};
|
||||
|
||||
this.setCompositionText = function(text) {
|
||||
};
|
||||
|
||||
this.hideComposition = function() {
|
||||
this.showCursor();
|
||||
var edit = document.getElementById("editor").lastChild;
|
||||
edit.className = '';
|
||||
edit.style.top = "-10000px";
|
||||
edit.style.left = "-10000px";
|
||||
};
|
||||
|
||||
this.setTheme = function(theme) {
|
||||
|
|
|
@ -231,7 +231,7 @@ def test():
|
|||
app = Cling(getcwd())
|
||||
try:
|
||||
print "Serving " + getcwd() + " to http://localhost:9999"
|
||||
make_server('localhost', 9999, validator(app)).serve_forever()
|
||||
make_server('0.0.0.0', 9999, validator(app)).serve_forever()
|
||||
except KeyboardInterrupt, ki:
|
||||
print ""
|
||||
print "Ciao, baby!"
|
||||
|
|
Загрузка…
Ссылка в новой задаче